Description Usage Arguments Details Value Note References Examples
Fits latent class models with covariate effects on underlying and measured variables. The measured variables are dichotomous or polytomous, all with the same number of categories.
1 2 3 |
formula1 |
The formula where the dependent variables are the manifest variables, grouped by |
formula2 |
The formula where the dependent variables are the manifest variables, grouped by |
data |
a dataframe containing all variables appearing in |
nclass |
the number of latent classes assumed in the model. |
maxiter |
the maximum number of iterations through which the estimation algorithm will cycle. |
tol |
A tolerance value for judging when convergence has been reached. When the one-iteration change in the estimated log-likelihood is less than |
beta.start |
a vector of parameters β_{jp} to be used as the starting values for the estimation algorithm. There is one parameter for each pair latent class-covariate (the index of the covariate moving faster), except the last class, considered as the reference, for which β_{Jp}=0 \forall p. The default is |
alpha.start |
an M \times L(K-1) matrix of parameters α_{mlk} to be used as the starting values for the estimation algorithm. Rows correspond to manifest variable m. Within each row, columns correspond to covariates l and categories of manifest variables k (except the last category, for which α_{mlK_m}=0), the index of the latter moving faster. The default is |
gamma.start |
an M \times J(K-1) matrix of parameters γ_{mjk} to be used as the starting values for the estimation algorithm. Rows correspond to manifest variable m. Within each row, columns correspond to latent classes j and categories of manifest variables k (except the last category, for which γ_{mjK_m}=0), the index of the latter moving faster. The default is |
beta.auto |
logical, indicating whether |
alpha.auto |
logical, indicating whether |
gamma.auto |
logical, indicating whether |
nrep |
number of times the model is estimated, using different values of |
verbose |
logical, indicating wheter |
calc.se |
logical, indicating whether |
We denote individuals by i (i=1,…,N), manifest variables (items) by Y_m (m=1,…,M), levels of the manifest variables by k (k=1,…,K ), the latent variable by S (S=j and j=1,…,J). There are two sets of covariates: those related with the latent class probabilities, \mathbf{x_i}=(1,x_{i1},…,x_{iP})^T, and those which can have a direct effect on the manifest variables, \mathbf{z_i}=(\mathbf{z_{i1}},…,\mathbf{z_{iM}}) with \mathbf{z_{im}}=(1,z_{im1},…,z_{imL})^T, m=1,…,M. The parameters of the model are the latent class probabilities π_j(\mathbf{x}'_i\boldsymbol{β})=P(S_i=j;\mathbf{x}_i) and the conditional probabilities p_{mkj}(\boldsymbol{γ}_{mj}+\boldsymbol{z}'_{im}\boldsymbol{α}_m)=P(Y_{im}=k|S_i=j;\boldsymbol{z}_{im}).
The model is
P(\mathbf{Y_i}=\mathbf{y}|\mathbf{x}_i, \mathbf{z}_i)=P(Y_{i1}=y_{1},…,Y_{iM}=y_M|\mathbf{x}_i, \mathbf{z}_i)
=∑_{j=1}^{J} ≤ft\{π_j(\mathbf{x}'_i\boldsymbol{β}) ∏_{m=1}^{M} p_{mkj}^{y_{imk}}(\boldsymbol{γ}_{mj}+\boldsymbol{z}'_{im}\boldsymbol{α}_m)\right\}
with
\log≤ft(\frac{π_j(\mathbf{x}'_i\boldsymbol{β})}{π_J(\mathbf{x}'_i\boldsymbol{β})}\right)= \mathbf{x}'_i\boldsymbol{β}_j \qquad i=1,…,N ;\quad j=1,…,(J-1)
and
\log≤ft(\frac{p_{mkj}(\boldsymbol{γ}_{mj}+\mathbf{z}'_{im}\boldsymbol{α}_m)}{p_{mKj}(\boldsymbol{γ}_{mj}+\boldsymbol{z}'_{im}\boldsymbol{α}_m)}\right)=γ_{mkj}+\mathbf{z}'_{im}\boldsymbol{α}_{mk}
The output of function covLCA()
is a list containing the following elements:
llik |
The log-likelihood value of the estimated model. |
attempts |
A vector containing the maximum loglikelihood values found in each of the |
beta.start |
A vector containing the initial values for parameters β when such values were provided by the user (in |
alpha.start |
A vector containing the initial values for parameters α when such values were provided by the user (in |
gamma.start |
A vector containing the initial values for parameters γ when such values were provided by the user (in |
beta.auto |
Logical, indicating whether the user asked for “reasonable” initial estimates of parameters β to be automatically computed (with the argument |
alpha.auto |
Logical, indicating whether the user asked for “reasonable” initial estimates of parameters α to be automatically computed (with the argument |
gamma.auto |
Logical, indicating whether the user asked for “reasonable” initial estimates of parameters γ to be automatically computed (with the argument |
beta.initAuto |
A vector containing the initial values for parameters β when “reasonable” values are automatically computed (when |
alpha.initAuto |
A vector containing the initial values for parameters α when “reasonable” values are automatically computed (when |
gamma.initAuto |
A vector containing the initial values for parameters γ when “reasonable” values are automatically computed (when |
probs |
An N\times M\times K\times J array containing the estimated conditional probabilities \hat{p}_{imkj}=\hat{p}_{mkj}(\boldsymbol{γ}_{mj}+\mathbf{z}'_{im}\boldsymbol{α}_m), where the first to fourth dimensions correspond to individuals, manifest variables, categories of manifest variables and latent classes, respectively. |
prior |
An N \times J matrix containing the estimated latent class probabilities \hat{π}_{ij}=\hat{π}_j(\mathbf{x}'_i\boldsymbol{β}), where rows correspond to individuals and columns, to latent classes. |
posterior |
An N \times J matrix containing the estimated posterior latent class probabilities h_{ij}(\hat{φ}), where rows correspond to individuals and columns to latent classes. |
predclass |
A vector of length N of predicted class memberships, by modal assignment. |
P |
The respective size of each latent class, equal to the mean of the priors. |
numiter |
The number of iterations required by the estimation algorithm to achieve convergence. |
coeffBeta |
An P\times J matrix of estimated β_{pj}, where rows correspond to covariates and columns, to latent classes. |
param.se |
A vector containing the standard error of each estimated parameter, in the following order: β_{jp}, γ_{mjk}, α_{mlk} where the last index always moves faster. |
param.V |
The covariance matrix of the coefficient estimates (in the same order as in |
coeffGamma |
An M \times J(K-1) matrix of estimated parameters γ_{mjk}. Each row corresponds to manifest variable m. Within each row, columns correspond to latent classes j and categories of manifest variables k (except the last category, for which γ_{mjK_m}=0), the index of the latter moving faster. |
coeffAlpha |
An M \times L(K-1) matrix of estimated parameters α_{mlk}. Each row corresponds to manifest variable m. Within each row, columns correspond to covariates l and categories of manifest variables k (except the last category, for which α_{mlK_m}=0), the index of the latter moving faster. |
meanProbs |
An M \times K \times J array of estimated conditional probabilities evaluated at the sample mean of the covariates. The first to third dimensions correspond to manifest variables, categories of manifest variables and latent classes, respectively. |
eflag |
Logical, error flag. |
npar |
The number of estimated parameters. |
aic |
Value of the AIC criterion for the estimated model. |
bic |
Value of the BIC criterion for the estimated model. |
Nobs |
Number of fully observed cases. |
x |
A dataframe containing the covariates for the latent class probabilities. |
z |
A dataframe containing the covariates for the conditional probabilities. |
y |
A dataframe containing the manifest variables. |
identifiability |
A list containing the eigenvalues and the inverse condition number of the matrices involved in conditions (iii') and (iv') of Theorem 1 (Local Identifiability) in Huang and Bandeen-Roche (2004). |
maxiter |
The maximum number of iterations of the estimation algorithm. |
resid.df |
The number of residual degrees of freedom, equal to the lesser of N and MK, minus |
time |
Computation time of model estimation. |
This function is an extension of the source code of the R package poLCA
(Linzer and Lewis, 2011) to the methodology proposed by Huang and Bandeen-Roche (2004).
Bertrand, A., Hafner, C.M. (2011) On heterogeneous latent class models with applications to the analysis of rating scores. Louvain-la-Neuve: Universite catholique de Louvain, Institute of Statistics, Biostatistics and Actuarial Sciences. Discussion paper 2011/28. Available at: http://uclouvain.be/cps/ucl/doc/stat/documents/ISBADP2011-28_On_heterogeneous_latent_class_models...pdf
Huang, G.-H., Bandeen-Roche K. (2004) Building an identifiable latent class model with covariate effects on underlying and measured variables. Psychometrika, 69(1), 5–32.
Linzer, D.A., Lewis J. (2011) poLCA: Polytomous Variable Latent Class Analysis. R package version 1.3.1.
Linzer, D.A., Lewis J. (2011) poLCA: an R Package for Polytomous Variable Latent Class Analysis. Journal of Statistical Software, 42(10), 1–29. http://www.jstatsoft.org/v42/i10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | ## 2 models for a subset of dataset election in package poLCA
library("poLCA")
data("election",package="poLCA")
election$GENDER <- factor(election$GENDER)
elec <- election[,c(1:3,7:12,16:17)]
elec <- na.omit(elec)
elec <- elec[1:200,]
## Model 1: 3 classes, 1 covariate for modelling latent class membership
fm1 <- cbind(MORALG,CARESG,KNOWG,MORALB,CARESB,
KNOWB)~PARTY
poLCA1 <- poLCA(formula=fm1,data=elec,nclass=3,nrep=10)
## Model 2: 3 classes, 1 covariate in the model for latent class membership,
## 1 covariate in the model for the manifest variables probabilities
fm2 <- cbind(MORALG,CARESG,KNOWG,MORALB,CARESB,
KNOWB)~1+PARTY
fm3 <- cbind(MORALG,CARESG,KNOWG,MORALB,CARESB,
KNOWB)~1+GENDER
covLCA1 <- covLCA(formula1=fm2,formula2=fm3,data=elec,nclass=3,
beta.auto=TRUE,gamma.auto=TRUE,alpha.auto=TRUE,maxit=10000)
## Not run: ## 2 models for dataset election in package poLCA
library("poLCA")
data("election",package="poLCA")
election$GENDER <- factor(election$GENDER)
elec <- election[,c(1:12,16:17)]
elec <- na.omit(elec)
## Model 1: 3 classes, 1 covariate for modelling latent class membership
fm1 <- cbind(MORALG,CARESG,KNOWG,LEADG,DISHONG,INTELG,MORALB,CARESB,
KNOWB,LEADB,DISHONB,INTELB)~PARTY
poLCA1 <- poLCA(formula=fm1,data=elec,nclass=3,nrep=10)
## Model 2: 3 classes, 1 covariate in the model for latent class membership,
## 1 covariate in the model for the manifest variables probabilities
fm2 <- cbind(MORALG,CARESG,KNOWG,LEADG,DISHONG,INTELG,MORALB,CARESB,
KNOWB,LEADB,DISHONB,INTELB)~1+PARTY
fm3 <- cbind(MORALG,CARESG,KNOWG,LEADG,DISHONG,INTELG,MORALB,CARESB,
KNOWB,LEADB,DISHONB,INTELB)~1+GENDER
covLCA1 <- covLCA(formula1=fm2,formula2=fm3,data=elec,nclass=3,
beta.auto=TRUE,gamma.auto=TRUE,alpha.auto=TRUE,maxit=10000)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.