Skip to contents

Bugs code for Categorical response

Usage

categorical_bugs(
  nodename,
  nodesCatIdx,
  parentnames,
  nodesintercepts,
  parentcoefs
)

categorical_bugsGroup(
  nodename,
  nodesCatIdx,
  nodesintercepts,
  parentnames,
  parentcoefs,
  sigma,
  sigma_alpha
)

Arguments

nodename

character string of response variable name.

nodesCatIdx

integer vector of length \(|K-1|\) and starting at \(k+1\) (see Examples).

parentnames

single character string (for one parent) or vector of characters (for multiple parent nodes) with parent node (predictor variables) names.

nodesintercepts

overall mean of response. Parameter from fixed-effects intercept.

parentcoefs

overall slope for each predictor (parent node) variable (fixed-effects).

sigma

within-group variance. Parameter from random-effects residual.

sigma_alpha

between-group variance-covariance matrix. Parameters from random-effects intercept.

Value

Bugs model returned as stdout.

Details

The output of fitAbn with method = "mle" is based on the output of logistic regression models fit with either lm, glm, glmer, multinom, mblogit or internal irls methods. They all use the first factor level as reference level. Therefore, nodesCatIdx starts with index \(2\) and not \(1\). nodesintercepts and parentcoefs refer to the values of (Intercept) and Estimate of the respective model output. Predictor names build the keys in parentcoef.

Functions

  • categorical_bugsGroup(): Bugs code for Categorical response with varying intercept

Examples

# A -> B
# Where B is a categorical variable with 4 levels.
categorical_bugs(nodename = "b",
                 nodesCatIdx = c(2, 3, 4),
                 parentnames = "a",
                 nodesintercepts = c(2.188650, 3.133928, 3.138531),
                 parentcoefs = list("a"=c(a=1.686432, a=3.134161, a=5.052104)))
#> b ~ dcat(p.b) # Categorical response
#> p.b[1] <- phi.b[1]/sum(phi.b) # soft-max
#> log(phi.b[1]) <- 0 # Reference category
#> p.b[2] <- phi.b[2]/sum(phi.b) # soft-max
#> log(phi.b[2]) <- 2.18865 + 1.686432*a
#> p.b[3] <- phi.b[3]/sum(phi.b) # soft-max
#> log(phi.b[3]) <- 3.133928 + 3.134161*a
#> p.b[4] <- phi.b[4]/sum(phi.b) # soft-max
#> log(phi.b[4]) <- 3.138531 + 5.052104*a