fma
is used to perform Factor Mixture Analysis (with covariates) on a matrix of data by the Expectation Maximization algorithm.
fma(y, k, r, x.z = NULL, x.w = NULL, it = 15, eps = 1e-04, seed = 4, scaling = FALSE, init = NULL)
n
rows representing observations and p
columns representing variables.n
rows representing observations and q
columns representing the predictors. These covariates are assumed to linearly affect the factor means.n
rows representing observations and m
columns representing the predictors. These covariates are assumed to differently affect the a priori probability of group membership.eps
the fitting is stopped. The default is 0.0001.NULL
(default) the algorithm starts from random values.k x r x (q +1)
containing the vectors of regression
coefficients which are allowed to vary across the components. When no covariate is incorporated into the model,
i.e. x.z
is NULL, Beta
has dimension k x r
and it correponds to the estimated component means of the mixture.k x m
which contains the coefficients of the covariates affecting the group membership.k x r x r
which contains the estimated component covariance of the mixture.p
observed
variables y
are modelled in terms of the smaller set of r
factors, z
, and an additive
specific term u
: y=Hz+u
,
where u
is assumed
to be normally distributed with diagonal variance matrix Psi
. H
is the factor loading matrix.
The model is fitted by the EM algorithm.
The code implements also factor mixture model with covariates. Covariates may affect the observed variables into two manners:
they are assumed to linearly affect the factor means (x.z
) and \ or they can differently affect the a priori probability of group membership
(x.w
). The default is NULL which means that covariates are not incorporated in the model.
A. Montanari and C. Viroli (2011), Dimensionally reduced mixtures of regression models, Journal of Statistical Planning and Inference, 141, 1744-1752.
C. Viroli (2011), Using factor mixture analysis to model heterogeneity, cognitive structure and determinants of dementia: an application to the Aging, Demographics, and Memory Study, Statistics in Medicine, to appear.
data(crabs)
y=as.matrix(crabs[,4:8])
fit=fma(y,k=2,r=1,it=50,eps=0.0001,scaling=TRUE) # without covariates
misc(fit$index,crabs[,1]) # compute the misclassification error
sex=as.double(crabs[,2])-1
fit=fma(y,k=2,r=1,x.z=sex,x.w=sex,it=50,eps=0.0001,scaling=TRUE) # with covariates
Run the code above in your browser using DataLab