Learn R Programming

poLCA (version 1.0)

poLCA-internal: Internal functions for poLCA

Description

Internal poLCA functions

Usage

poLCA.updatePrior(b, x, R)
poLCA.postClass.C(prior, vp, y)
poLCA.probHat.C(rgivy, y, vp)
poLCA.ylik.C(vp, y)
poLCA.dLL2dBeta.C(rgivy, prior, x)
poLCA.vectorize(probs)
poLCA.unvectorize(vp)
poLCA.compress(y)
poLCA.se(y,x,probs,prior,rgivy)

Arguments

b
vector of multinomial logit coefficients on covariates.
R
number of classes assumed in fitting model.
prior
matrix of prior probabilities.
probs
a list of length equal to the number of outcome variables, containing estimated conditional item response probabilities for each question and class.
vp
vectorized format of probs for use in C code.
rgivy
matrix of posterior probabilities of observation being in class r given data y.
x
matrix of covariates.
y
a matrix or data frame of manifest variables.

Value

  • poLCA.updatePriorWhen estimating latent class regression models (with covariates), function uses multinomial logit link to update prior probabilities of class membership based upon estimated coefficients and values of the concomitant variables in EM algorithm. Returns matrix of prior probabilities, with one column per class being estimated, and each row representing one observation.
  • poLCA.postClass.CC call. Calculates posterior probabilities of class membership as prior times likelihood, in EM algorithm. Returns matrix of posterior probabilities of class memberships, with one column per class being estimated, and each row representing one observation, so that every row sums to 1.
  • poLCA.probHat.CC call. Calculates updated estimates of manifest variable class-conditional reponse probabilities, in EM algorithm. Returns list of length equal to number of manifest variables, with each item containing a matrix of conditional response probabilties.
  • poLCA.ylik.CC call. Calculates for each observation the probabilities of observing the full set of responses to all manifest variables, given conditional response probabilities probs, for each class. Probabilities are calculated assuming local independence, meaning that for each observation and each class, the item response probabilities are simply multiplied across the manifest variables. Returns a matrix with rows equal to number of observations and columns equal to number of classes specified by nclass in poLCA
  • poLCA.dLL2dBeta.CC call. Calculates gradient vector and Hessian matrix when estimating model with covariates, for updating multinomial logit coefficients b in EM algorithm.
  • poLCA.vectorizeConverts conditional response probabilties from list format probs to vector format vp for use in compiled C code.
  • poLCA.unvectorizeConverts conditional response probabilties from vector format vp to list format probs for use in R.
  • poLCA.compressCompress a matrix or data frame by removing redundant rows, so that each unique row appears only once. Also counts and returns the frequency of each row pattern. The resulting matrix is sorted in ascending order, by column, starting with the first column. Returns a list containing the "compressed" matrix datamat, in the same format (data frame or matrix) as what was inputted, along with the frequency count freq of each unique row in that matrix.
  • poLCA.seCalculates covariance matrix and standard error estimates for all parameters, based upon the empirical observed information matrix.

Details

Functions used in updating EM algorithm in main poLCA function, including calls to compiled C code to accelerate estimation. These functions are masked from the user and are only meant to be called internally from poLCA.

See Also

poLCA