This is an internal simulation function for simulating data from a graph.

sim_X(B, n, sigma, alpha = rep(1, ncol(B)))

Arguments

B

a upper triangular matrix encoding a graph

n

number of observations from the graph

sigma

the common standard error

alpha

a vector of length equal to the number of parameters given by B. These alphas are multiplied to the common sigma.

Value

The sim_X function returns a matrix with data from the graph B with columns equal to the number of columns in B and rows equal to n.

Details

The sim_B function simulates a causal graph with regression coefficients. The graph must be encoded as an upper triangular matrix.

Examples

# The matrix encoding the graph with arrows: # 1 -> 2, 1 -> 3 and 2 -> 3 (B <- matrix(c(0,0,0,1,0,0,1,1,0), ncol = 3))
#> [,1] [,2] [,3] #> [1,] 0 1 1 #> [2,] 0 0 1 #> [3,] 0 0 0
# simulate data sim_X(B, 10, 1)
#> [,1] [,2] [,3] #> [1,] 1.4042666 -0.11557251 1.85101596 #> [2,] 0.1829870 0.22260223 1.29144096 #> [3,] -1.6301959 -0.09758402 -0.02428655 #> [4,] -1.1166533 -2.71256681 -3.18815300 #> [5,] 1.4044707 2.53788974 4.26109873 #> [6,] 0.7196067 1.76121066 2.58829278 #> [7,] 0.1590067 -0.12270970 1.59750968 #> [8,] 1.2461201 0.60113403 1.54382357 #> [9,] -1.8667717 -2.31795402 -2.89937683 #> [10,] -0.1723211 -0.72949045 0.35088010