Learn R Programming

hmmm (version 1.0-4)

loglin.model: define a log-linear model

Description

Function to specify a hierarchical log-linear model. This is a particular case of a hmm model.

Usage

loglin.model(lev, int = NULL, strata = 1, dismarg = 0, type = "b", 
D = TRUE, c.gen = TRUE, printflag = FALSE, names = NULL, formula = NULL)

Arguments

lev

Vector of number of categories of variables

int

Generating class of the log-linear model (must be a list) or list of all the interactions included

strata

Number of strata

dismarg

List of interactions constrained by inequalities - see `hmmm.model'

type

"b" for baseline logits, "l" for local logits

D

Input argument for inequalities - see `hmmm.model'

c.gen

If FALSE the input int must be the list of the minimal interaction sets to be excluded

printflag

If TRUE information on the included and excluded interactions are given

names

A character vector whose elements are the names of the variables

formula

A formula describing a log-linear model

Value

An object of the class hmmmmod defining a log-linear model that can be estimated by `hmmm.mlfit'.

Details

This function simplifies `hmmm.model' in the case of log-linear models. If formula is employed, c.gen and int must not be declared while names must be specified.

References

Agresti A (2012) Categorical data Analysis, (3ed), Wiley, New York.

Bergsma W, Croon M, Hagenaars JA (2009) Marginal Models for Dependent, Clustered, and Longitudinal Categorical Data. Springer.

See Also

hmmm.model, hmmm.mlfit, create.XMAT

Examples

Run this code
# NOT RUN {
data(madsen)
y<-getnames(madsen)
names<-c("Infl","Sat","Co","Ho")

f<-~Co*Ho+Sat*Co+Infl*Co+Sat*Ho+Infl*Sat
model<-loglin.model(lev=c(3,3,2,4),formula=f,names=names)

# alternatively 
# model<-loglin.model(lev=c(3,3,2,4),
# int=list(c(3,4),c(2,3),c(1,3),c(2,4),c(1,2)),names=names)

mod<-hmmm.mlfit(y,model,maxit=3000)
print(mod,printflag=TRUE)
# }

Run the code above in your browser using DataLab