hmat | R Documentation |
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.
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.
genmodel()
# 2x2 independence example
# following convention, the first index indicates rows
varlvls <- c(2,2)
facets <- list(1,2)
( A <- hmat(varlvls, facets) )
# alternatively:
hmat(c(2, 2), 1:2)
# facets = list() returns the matrix that computes the sample size of the table
( A <- hmat(varlvls, list()) )
# 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) )
cat(format_latte(A))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.