graph_est.Rd
Estimates the graph of a linear SEM with assumed equal variance of the noise terms.
graph_est(X, method = "TD", measure = "deviance", which = "1se", ...)
X | A matrix containing the observed variables |
---|---|
method | The estimation method. Possible choises are "TD", "BU", "HTD" and "HBU". |
measure | Either "mse", "mae" |
which | Either "min" or "1se" |
... | Terms passed to the method specific estimation steps. If the method "HBU" is specified it is possible to specify a tuning
parameter If the method "HTD" is specified it is posible to specify a
The "full" search method simply looks at all possible subsets of the
current ansestreal set of size |
The graph_est
function returns a vector top_order
with the estimated topological ordering of the causal graph, a matrix
G
of the estimated causal graph, and lastly a matrix B
of the
estimated regression matrix.
graph_est
is a simple wrapper function which given data will fist
estimate the topological ordering of the causal graph using the function
top_order
, and then estimate the causal graph itself using the
function graph_from_top
.
graph_est
is simply a wrapper functio for the two functions
top_order
and graph_from_top
which givem data
will estimate the topological ordering of the causal graph and estimates
the causal graph itself given an ordering respectivly.
# we create some data from the graph B n <- 1000 B <- matrix(c(0,1,0,1, 0,0,2,0, 0,0,0,1, 0,0,0,0), ncol = 4, nrow = 4, byrow = TRUE) X <- matrix(0, ncol = 4, nrow = n) for (i in 1:4) { X[ ,i] <- X %*% B[ ,i] + rnorm(n) } # from the simulated data we etimate in two different way to illustrate graph_est(X, method = "TD", measure = "deviance", which = "1se")#> $top_order #> [1] 1 2 3 4 #> #> $graph #> [,1] [,2] [,3] [,4] #> [1,] 0 1 0 1 #> [2,] 0 0 1 0 #> [3,] 0 0 0 1 #> [4,] 0 0 0 0 #> #> $B #> [,1] [,2] [,3] [,4] #> [1,] 0 0.8276971 0.000000 1.0078577 #> [2,] 0 0.0000000 1.898111 0.0000000 #> [3,] 0 0.0000000 0.000000 0.9344701 #> [4,] 0 0.0000000 0.000000 0.0000000 #> #> attr(,"class") #> [1] "graph_est"graph_est(X, method = "HTD", measure = "deviance", which = "1se", max.degree = 2L, search = "full")#> $top_order #> [1] 1 2 3 4 #> #> $graph #> [,1] [,2] [,3] [,4] #> [1,] 0 1 0 1 #> [2,] 0 0 1 0 #> [3,] 0 0 0 1 #> [4,] 0 0 0 0 #> #> $B #> [,1] [,2] [,3] [,4] #> [1,] 0 0.8467335 0.000000 1.0428946 #> [2,] 0 0.0000000 1.898111 0.0000000 #> [3,] 0 0.0000000 0.000000 0.9458375 #> [4,] 0 0.0000000 0.000000 0.0000000 #> #> attr(,"class") #> [1] "graph_est"