MarginalModelFit {cmm}R Documentation

MarginalModelFit

Description

Fits marginal model

Usage

MarginalModelFit(dat, model, MaxSteps=1000, MaxStepSize=1, MaxError=1e-20, StartingPoint="Automatic",
    MaxInnerSteps=2, ShowProgress=TRUE, CoefficientDimensions="Automatic",
    Labels="Automatic",ShowCoefficients=TRUE,ShowParameters=FALSE, ParameterCoding="Effect",
    ShowCorrelations=FALSE, Method="ML", Title="" )

Arguments

dat vector of frequencies or data frame
model list specified eg as list(bt,coeff,at)
MaxSteps integer: maximum number of steps of the algorithm
MaxStepSize number greater than 0 and at most 1: step size
MaxError numeric: maximum error term
StartingPoint vector of starting frequencies corresponding to all cells in the manifest table
MaxInnerSteps nonnegative integer: only used for latent variable models, indicates number of steps in M step of EM algorithms
ShowProgress boolean or integer: FALSE for no progress information, TRUE or 1 for information at every step, an integer k for information at every k-th step
CoefficientDimensions numeric vector of dimensions of the table in which the coefficient vector is to be arranged
Labels list of characters or numbers indicating labels for dimensions of table in which the coefficient vector is to be arranged
ShowCoefficients boolean, indicating whether or not the coefficients are to be displayed
ShowParameters boolean, indicating whether or not the parameters (computed from the coefficients) are to be displayed
ParameterCoding Coding to be used for parameters, choice of "Effect", "Dummy" and "Polynomial"
ShowCorrelations boolean, indicating whether or not to show the correlation matrix for the estimated coefficients
Method character, choice of "ML" for maximum likelihood or "GSK" for the GSK method
Title title of computation to appear at top of screen output

Details

The data can be a data frame or vector of frequencies. MarginalModelFit converts a data frame dat using c(t(ftable(dat))).

The model can be specified in various ways, eg, as list(bt,coeff,at) where bt may be obtained using ConstraintMatrix, coeff using SpecifyCoefficient and at using MarginalMatrix. Alternatively, list(coeff,at) or list(coeff,at) can be used. Furthermore, coeff can be a function, eg, a loglinear marginal model can be specified using list(bt,"log",at).

An extended model specification is list(margmodel,x) where margmodel has one of the above forms, and x is a design matrix, which can be obtained using DesignMatrix. In addition to the marginal model margmodel, this specifies a loglinear model based on design matrix x. Fitting is often more efficient by specifying a loglinear model for the joint distribution in this way rather than using constraints.

In the output, coefficients are given. These are that part of model without the bt matrix, eg if the model is list(bt,coeff,at) then the coefficients are list(coeff,at). If other coefficients are needed, ModelStatistics can be used.

Latent variable models can be specified: if the size of the table for which model is specified is a multiple of the the size of the observed frequencies specified in dat, it is assumed this is due to the presence of latent variables. With respect to vectorization, the latent variables are assumed to change their value fastest, ie, their values change fastest.

Convergence may not be achieved with MaxStepSize=1 and a lower value may need to be used, not too low or convergence is slow.

Value

NA. Only output to the screen is provided

Author(s)

W. P. Bergsma w.p.bergsma@lse.ac.uk

References

Bergsma, W. P. (1997). Marginal models for categorical data. Tilburg, The Netherlands: Tilburg University Press. http://stats.lse.ac.uk/bergsma/pdf/bergsma_phdthesis.pdf

See Also

SampleStatistics, ModelStatistics

Examples

# see also the built-in data sets

data(NKPS)

# Compute Goodman and Kruskal's gamma for
# Child's attitude toward sex role's (NKPS[,3], three categories) and
# parent's attitude toward sex role's (NKPS[,4], three categories).

coeff = SpecifyCoefficient("GoodmanKruskalGamma",c(3,3))
MarginalModelFit(NKPS[,c(3,4)], coeff )


[Package cmm version 0.1 Index]