test_run_over | R Documentation |
This function tests the goodness-of-fit of a given Gaussian latent tree model to observed data.
The parameter space is characterized by polynomial constraints. The involved polynomials are
estimated by considering overlapping subsets of the data
({X_1, X_2, X_3, X_4}, {X_2, X_3, X_4, X_5}, ...
). Each subset is used to form an
unbiased estimate of all polynomials. The test statistic
is the maximum of the average of the m-dependent studentized estimates.
A Gaussian multiplier bootstrap is used to estimate the limiting distribution of the
test statistic and to compute the p-value of the test.
test_run_over(X, ind_eq, ind_ineq1 = NULL, ind_ineq2 = NULL, B = 5, E = 1000)
X |
Matrix with observed data. The number of columns has to be equal to the number of leaves of the postulated tree (i.e. number of observed variables). Each row corresponds to one sample. |
ind_eq |
Representation of the equality constraints that have to be tested.
Create this object using the function |
ind_ineq1 |
Representation of the inequality constraints in three variables that have to be tested.
Create this object using the function |
ind_ineq2 |
Representation of the inequality constraints in four variables that have to be tested.
Create this object using the function |
B |
Integer, batch size for the estimate of the covariance matrix. |
E |
Integer, number of bootstrap iterations. |
Named list with two entries: Test statistic (TSTAT
) and p-value (PVAL
).
# Create tree
vertices <- data.frame(name=seq(1,8), type=c(rep(1,5), rep(2,3))) # 1=observed, 2=latent
edges <- data.frame(from=c(1,2,3,4,5,6,7), to=c(8,8,6,6,7,7,8))
tree <- igraph::graph_from_data_frame(edges, directed=FALSE, vertices=vertices)
# Sample data from tree
igraph::V(tree)$var = rep(1,8)
igraph::E(tree)$corr = rep(0.7,7)
X = sample_from_tree(tree, m=5, n=500)
# Determine the representation of the polynomials that have to be tested
res = collect_indices(tree, m=5)
ind_eq = res$ind_eq
ind_ineq1 = res$ind_ineq1
ind_ineq2 = res$ind_ineq2
# Apply the test
test_run_over(X, ind_eq, ind_ineq1, ind_ineq2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.