node_poisson {simDAG} | R Documentation |
Simulate a Node Using Poisson Regression
Description
Data from the parents is used to generate the node using poisson regression by predicting the covariate specific lambda and sampling from a poisson distribution accordingly.
Usage
node_poisson(data, parents, formula=NULL, betas, intercept)
Arguments
data |
A |
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 |
formula |
An optional |
betas |
A numeric vector with length equal to |
intercept |
A single number specifying the intercept that should be used when generating the node. |
Details
Essentially, this function simply calculates the linear predictor defined by the betas
-coefficients, the intercept
and the values of the parents
. The exponential function is then applied to this predictor and the result is passed to the rpois
function. The result is a draw from a subject-specific poisson distribution, resembling the user-defined poisson regression model.
Value
Returns a numeric vector of length nrow(data)
.
Author(s)
Robin Denz
See Also
empty_dag
, node
, node_td
, sim_from_dag
, sim_discrete_time
Examples
library(simDAG)
set.seed(345345)
dag <- empty_dag() +
node("age", type="rnorm", mean=50, sd=4) +
node("sex", type="rbernoulli", p=0.5) +
node("smoking", type="poisson", parents=c("sex", "age"),
betas=c(1.1, 0.4), intercept=-2)
sim_dat <- sim_from_dag(dag=dag, n_sim=100)