rbern: Random Sample from Bernoulli Distribution

Description Usage Arguments Value Examples

View source: R/distributions.R

Description

Wrapper for Bernoulli node distribution.

Usage

1
rbern(n, prob)

Arguments

n

Sample size.

prob

A vector of success probabilities.

Value

Binary vector of length n.

Examples

1
2
3
4
5
6
7
8
9
#---------------------------------------------------------------------------------------
# Specifying and simulating from a DAG with 3 Bernoulli nodes
#---------------------------------------------------------------------------------------
D <- DAG.empty()
D <- D + node("W1", distr="rbern", prob=0.05)
D <- D + node("W2", distr="rbern", prob=ifelse(W1==1,0.5,0.1))
D <- D + node("W3", distr="rbern", prob=ifelse(W1==1,0.5,0.1))
Dset <- set.DAG(D)
simdat <- sim(Dset, n=200, rndseed=1)

simcausal documentation built on Oct. 9, 2017, 1:03 a.m.