Description Usage Arguments Value References Examples
Determine the A matrix associated with a hierarchical model on a contingency table. In algebraic statistics, the A matrix of a log-linear model is the transpose of the design matrix of the (cell-means parameterized) ANOVA corresponding to the model.
1 | hmat(varlvls, facets)
|
varlvls |
a vector containing the number of levels of each variable |
facets |
the facets generating the hierarchical model, a list of vectors of variable indices |
a named matrix
Drton, M., B. Sturmfels, and S. Sullivant (2009). Lectures on Algebraic Statistics, Basel: Birkhauser Verlag AG.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # LAS example 1.2.11, p.16
varlvls <- c(2,2,2,2)
facets <- list(c(1,2), c(1,4), c(2,3))
( A <- hmat(varlvls, facets) )
# 2x2 independence example
# following convention, the first index indicates rows
varlvls <- c(2,2)
facets <- list(1,2)
( A <- hmat(varlvls, facets) )
printForMarkov <- function(A){
cat(paste(nrow(A), ncol(A)))
cat("\n")
cat(apply(unname(A), 1, paste, collapse = " "), sep = "\n")
cat("\n")
}
printForMarkov(A)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.