loglin-dim: Return the dimension of a log-linear model

loglin-dimR Documentation

Return the dimension of a log-linear model

Description

Return the dimension of a log-linear model given by the generating class 'glist'. If the model is decomposable and adjusted dimension can be found.

Usage

dim_loglin(glist, tableinfo)

dim_loglin_decomp(glist, tableinfo, adjust = TRUE)

Arguments

glist

Generating class (a list) for a log-linear model. See 'details' below.

tableinfo

Specification of the levels of the variables. See 'details' below.

adjust

Should model dimension be adjusted for sparsity of data (only available for decomposable models)

Details

glist can be either a list of vectors with variable names or a list of vectors of variable indices.

tableinfo can be one of three different things.

  1. A contingency table (a table).

  2. A list with the names of the variables and their levels (such as one would get if calling dimnames on a table).

  3. A vector with the levels. If glist is a list of vectors with variable names, then the entries of the vector tableinfo must be named.

If the model is decomposable it dim_loglin_decomp is to be preferred over dim_loglin as the former is much faster.

Setting adjust=TRUE will force dim_loglin_decomp to calculated a dimension which is adjusted for sparsity of data. For this to work, tableinfo MUST be a table.

Value

A numeric.

Author(s)

Søren Højsgaard, sorenh@math.aau.dk

See Also

dmod, glm, loglm

Examples

## glist contains variable names and tableinfo is a named vector:
dim_loglin(list(c("a", "b"), c("b", "c")), c(a=4, b=7, c=6))

## glist contains variable names and tableinfo is not named:
dim_loglin(list(c(1, 2), c(2, 3)), c(4, 7, 6))

## For decomposable models:
dim_loglin_decomp(list(c("a", "b"), c("b", "c")), c(a=4, b=7, c=6),adjust=FALSE)


gRim documentation built on Oct. 2, 2023, 9:06 a.m.