
Generate Data from a Negative Binomial Regression Model
node_negative_binomial.RdData from the parents is used to generate the node using negative binomial regression by applying the betas to the design matrix and sampling from the rnbinom function.
Arguments
- data
A
data.table(or something that can be coerced to adata.table) containing all columns specified byparents.- parents
A character vector specifying the names of the parents that this particular child node has. If non-linear combinations or interaction effects should be included, the user may specify the
formulaargument instead.- formula
An optional
formulaobject to describe how the node should be generated orNULL(default). If supplied it should start with~, having nothing else on the left hand side. The right hand side may contain any valid formula syntax, such asA + BorA + B + I(A^2), allowing non-linear effects. If this argument is defined, there is no need to define theparentsargument. For example, usingparents=c("A", "B")is equal to usingformula= ~ A + B. Contrary to thenode_gaussian,node_binomialandnode_poissonnode types, random effects and random slopes are currently not supported here.- betas
A numeric vector with length equal to
parents, specifying the causal beta coefficients used to generate the node.- intercept
A single number specifying the intercept that should be used when generating the node.
- theta
A single number specifying the theta parameter (
sizeargument inrnbinom).- link
The link function used to transform the linear predictor to the
muvalue used inrnbinom. For a standard negative binomial regression model, this should be set to"log"(which is the default). Other allowed values are"identity"and"sqrt".
Details
This function uses the linear predictor defined by the betas and the input design matrix to sample from a subject-specific negative binomial distribution. It does to by calculating the linear predictor using the data, betas and intercept, applying the inverse of the link function to it and passing it to the mu argument of the rnbinom function of the stats package.
This node type currently does not support inclusion of random effects or random slopes in the formula.