hmmm.model.X: hmm model with covariates effect on parameters

Description Usage Arguments Details Value References See Also Examples

Description

Function to define a hmm model whose parameters depend on covariates.

Usage

1
2
hmmm.model.X(marg, lev, names, Formula = NULL, strata = 1, 
fnames = NULL, cocacontr = NULL, ncocacontr = NULL, replace=TRUE)

Arguments

marg

A list of the marginal sets and their marginal interactions as described in Bartolucci et al. (2007). See details of hmmm.model

lev

Number of categories of the response variables

names

A character vector whose elements are the names of the response variables

Formula

List of model-formulas; one formula for every marginal interaction

strata

Number of categories of the covariates that describe the strata

fnames

Names of the covariates that describe the strata

cocacontr

A list of zero-one matrices to build "r" logits created by the function ‘recursive’

ncocacontr

Number of contrasts for every covariate, if NULL the maximum number is used

replace

If TRUE a new model object with design matrix X is produced, if FALSE the list of design matrices associated to each element specified in Formula is returned

Details

The arguments names and fnames report the names of responses and covariates according to the order in which the variables are declared, see details of function ‘hmmm.model’.

When the marginal interactions of a hmm model are defined in terms of a linear predictor of covariates Cln(Mm)=Xbeta, the list of model formulas defines additive effects of covariates on the interactions. In a case with two response variables declared by names<-c("A","B") and two covariates, named C and D by fnames=c("C","D"), the additive effect of the covariates on marginal logits of A and B and log odds ratios (A.B) of the two responses is specified by the following Formula: Formula<-list(A=~A*(C+D), B=~B*(C+D), A.B=~A.B*(C+D)). Use "zero" to constrain to zero all the interactions of a given type. The saturated model is the default if Formula is not specified.

Value

An object of the class hmmmmod; it describes a marginal model with effects of covariates on the interactions. This model can be estimated by ‘hmmm.mlfit’.

References

Colombi R, Giordano S, Cazzaro M (2014) hmmm: An R Package for hierarchical multinomial marginal models. Journal of Statistical Software, 59(11), 1-25, URL http://www.jstatsoft.org/v59/i11/.

Glonek GFV, McCullagh P (1995) Multivariate logistic models for contingency tables. Journal of the Royal Statistical Society, B, 57, 533-546.

Marchetti GM, Lupparelli M (2011) Chain graph models of multivariate regression type for categorical data. Bernoulli, 17, 827-844.

See Also

hmmm.model, create.XMAT, summary.hmmmmod, print.hmmmmod, marg.list, recursive, hmmm.mlfit

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data(accident)
y<-getnames(accident,st=9,sep=";")
# responses: 1 = Type, 2 = Time; covariates: 3 = Age, 4 = Hour

marginals<-marg.list(c("b-marg","marg-g","b-g"))
al<-list(
Type=~Type*(Age+Hour),
Time=~Time*(Age+Hour),
Type.Time=~Type.Time*(Age+Hour)
)
# model with additive effect of the covariates on logits and log-o.r. of the responses
model<-hmmm.model.X(marg=marginals,lev=c(3,4),names=c("Type","Time"),
Formula=al,strata=c(3,2),fnames=c("Age","Hour"))
mod<-hmmm.mlfit(y,model,y.eps=0.1)

hmmm documentation built on May 2, 2019, 12:27 p.m.