simGibbs: Generate binary (*Y*, *A*, *C*) from chain graph model under...

Description Usage Arguments Value Examples

View source: R/simGibbs.R

Description

Generate binary (Y, A, C) from chain graph model under simplest scenario.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
simGibbs(
  n.unit,
  n.gibbs,
  n.sample,
  weight.matrix,
  treat.matrix,
  cov.matrix,
  init.prob = 0.5,
  treat.prob = 0.5,
  cov.prob = 0.5,
  n.burn = 100,
  yvalues = c(1, 0)
)

Arguments

n.unit

the number of units (m).

n.gibbs

the number of independent Gibbs sampler.

n.sample

the number of samples from each Gibbs sampling (n = n.gibbs x n.sample).

weight.matrix

a [m x m] symmetric relational matrix where W_ij = 1 indicates the existence of undirected edges between Y_i and Y_j and its magnitude. Here W_ii represents the main effect of Y_i.

treat.matrix

a [m x m] matrix where treat.matrix_ij indicates the magnitude of direct effect from A_i to Y_j.

cov.matrix

a [m x m] matrix where treat.matrix_ij indicates the magnitude of direct effect from C_i to Y_j.

init.prob

an initial probability generating (Y, A, C) from Bernoulli distribution.

treat.prob

a probability updating A in Gibbs sampling procedure.

cov.prob

a probability updating C in Gibbs sampling procedure.

n.burn

the number of burn-in sample in Gibbs sampling ( n.obs).

yvalues

a vector of distinct binary outcome values. Defaults to c(0,1).

Value

a list of [n.gibbs] x [n.sample] independent observations:

inputY

a [([n.gibbs] x [n.sample]) x m] matrix for outcomes.

inputA

a [([n.gibbs] x [n.sample]) x m] matrix for treatments.

inputC

a [([n.gibbs] x [n.sample]) x m] matrix for confounders.

Examples

1
2
3
4
5
6
7
8
library(netchain)
weight.matrix <- matrix(c(0.5, 1, 0, 1, 0.3, 0.5, 0, 0.5, -0.5), 3, 3)
simobs <- simGibbs(n.unit = 3, n.gibbs = 200, n.sample = 10, 
                  weight.matrix,
                  treat.matrix = 0.5*diag(3), cov.matrix= (-0.3)*diag(3) )
inputY <- simobs$inputY
inputA <- simobs$inputA
inputC <- simobs$inputC

netchain documentation built on Feb. 17, 2020, 9:11 a.m.