| loglin.model {hmmm} | R Documentation |
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 |
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.
Value
An object of the class hmmmmod defining a log-linear model that can be estimated by ‘hmmm.mlfit’.
Note
If int and formula are not supplied a saturated log-linear model is defined. For log-linear models where the parameters
depend on covariates first define a saturated log-linear model and then use the function ‘create.XMAT’.
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
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)
mod<-hmmm.mlfit(y,model,maxit=3000)
print(mod,printflag=TRUE)