simcausal (version 0.2.0)

rconst: Constant (Degenerate) Node Distribution

Description

Wrapper for a constant value (degenerate) distribution.

Usage

rconst(n, const)

Arguments

n
Sample size.
const
A vector of constant values.

Value

  • A vector of constants of length n.

Examples

Run this code
#---------------------------------------------------------------------------------------
# Specifying and simulating from a DAG with 1 Bernoulli and 2 constant nodes
#---------------------------------------------------------------------------------------
D <- DAG.empty()
D <- D + node("W1", distr="rbern", prob=0.05)
D <- D + node("W2", distr="rconst", const=1)
D <- D + node("W3", distr="rconst", const=ifelse(W1==1,5,10))
Dset <- set.DAG(D)
simdat <- simobs(Dset, n=200, rndseed=1)

Run the code above in your browser using DataCamp Workspace