inst/pkgdown/includes/custom-head.html

Skip to contents

Article in progress…

Latent Class Analysis

Sometimes, people belong to different groups (i.e., classes) that are due to nonobservable characteristics. This fact conditions their probability of selecting a particular response option when answering an item. Latent Class Analysis is a statistical model that estimates the probability that a person belongs to a particular class and the conditional probabilities of selecting a particular response option conditioning in the given class.

The likelihood

Suppose that a sample of people respond to JJ items and 𝐲\boldsymbol{y} is a vector that contains the scores to each item jj. Also, let KK denote the number of latent classes and xkx_k, the specific class kk. Then, the likelihood of this response pattern 𝐲\boldsymbol{y}, if it was observed nn times in the sample, can be written as

l=P(𝐲)n=(βˆ‘k=1KP(xk)P(𝐲|xk))n, \begin{aligned} l &= P(\boldsymbol{y})^n \\ &= \Bigg (\sum_{k=1}^K P(x_k)P(\boldsymbol{y}|x_k)\Bigg)^n, \end{aligned}

Assuming local independence, we can rewrite the conditional probabilities as

P(𝐲|xk)=∏j=1JP(yj|xk), P(\boldsymbol{y}|x_k) = \prod_{j=1}^J P(y_j|x_k),

where yjy_j denotes the score in item jj.

With this assumption, the likelihood can be rewritten as l=(βˆ‘k=1KP(xk)∏j=1JP(yj|xk))n,l = \Bigg(\sum_{k=1}^K P(x_k)\prod_{j=1}^J P(y_j|x_k)\Bigg)^n,

and the logarithm likelihood becomes ll=nlog(βˆ‘k=1KP(xk)∏j=1JP(yj|xk)).ll = n \log\Bigg(\sum_{k=1}^K P(x_k)\prod_{j=1}^J P(y_j|x_k)\Bigg).

First-order derivatives

The partial derivative of llll with respect to the probability of belonging to the class kk is βˆ‚llβˆ‚P(xg)=nβˆ‘k=1KP(xk)∏j=1JP(yj|xk)∏j=1JP(yj|xg). \frac{\partial ll}{\partial P(x_g)} = \frac{n}{\sum_{k=1}^K P(x_k)\prod_{j=1}^J P(y_j|x_k)} \prod_{j=1}^J P(y_j|x_g).

On the other hand, the partial derivative of llll with respect to the probability of scoring a particular yjy_j while belonging to the class kk is βˆ‚llβˆ‚P(ym|xg)=nβˆ‘k=1KP(xk)∏j=1JP(yj|xk)P(xg)∏jβ‰ mP(yj|xg). \frac{\partial ll}{\partial P(y_m|x_g)} = \frac{n}{\sum_{k=1}^K P(x_k)\prod_{j=1}^J P(y_j|x_k)} P(x_g)\prod_{j\neq m} P(y_j|x_g).

Second-order derivatives

The second partial derivative of llll with respect to the probability of belonging to the class kk is

βˆ‚2llβˆ‚P(xg)βˆ‚P(xh)=βˆ’n∏j=1JP(yj|xh)∏j=1JP(yj|xg)(βˆ‘k=1KP(xk)∏j=1JP(yj|xk))2 \frac{\partial^2 ll}{\partial P(x_g) \partial P(x_h)} = -\frac{n \prod_{j=1}^J P(y_j|x_h) \prod_{j=1}^J P(y_j|x_g)}{\Big(\sum_{k=1}^K P(x_k)\prod_{j=1}^J P(y_j|x_k)\Big)^2}

βˆ‚llβˆ‚P(ym|xg)P(ym|xg)=βˆ’nP(xg)∏jβ‰ mP(yj|xg)P(xg)∏jβ‰ mP(yj|xg)(βˆ‘k=1KP(xk)∏j=1JP(yj|xk))2. \frac{\partial ll}{\partial P(y_m|x_g) P(y_m|x_g)} = -\frac{n P(x_g)\prod_{j \neq m} P(y_j|x_g) P(x_g) \prod_{j\neq m} P(y_j|x_g)}{\Big(\sum_{k=1}^K P(x_k)\prod_{j=1}^J P(y_j|x_k)\Big)^2}.

βˆ‚llβˆ‚P(ym|xg)P(yn|xg)=nβˆ‘k=1KP(xk)∏j=1JP(yj|xk)P(xg)∏jβ‰ m,nP(yj|xg)βˆ’nP(xg)∏jβ‰ nP(yj|xg)P(xg)∏jβ‰ mP(yj|xg)(βˆ‘k=1KP(xk)∏j=1JP(yj|xk))2. \frac{\partial ll}{\partial P(y_m|x_g) P(y_n|x_g)} = \frac{n \sum_{k=1}^K P(x_k)\prod_{j=1}^J P(y_j|x_k) P(x_g) \prod_{j\neq m,n} P(y_j|x_g) - n P(x_g)\prod_{j \neq n} P(y_j|x_g) P(x_g) \prod_{j\neq m} P(y_j|x_g)}{\Big(\sum_{k=1}^K P(x_k)\prod_{j=1}^J P(y_j|x_k)\Big)^2}.

The second partial derivative of llll with respect to the probability of scoring a particular ymy_m or yny_n while belonging to the class gg or hh is βˆ‚llβˆ‚P(ym|xg)P(yn|xh)=βˆ’nP(xh)∏jβ‰ nP(yj|xh)P(xg)∏jβ‰ mP(yj|xg)(βˆ‘k=1KP(xk)∏j=1JP(yj|xk))2. \frac{\partial ll}{\partial P(y_m|x_g) P(y_n|x_h)} = -\frac{n P(x_h) \prod_{j\neq n} P(y_j|x_h) P(x_g) \prod_{j\neq m} P(y_j|x_g)}{\Big(\sum_{k=1}^K P(x_k)\prod_{j=1}^J P(y_j|x_k)\Big)^2}.

The second partial derivative of llll between the probability of belonging to the class gg and the probability of scoring a particular ymy_m while belonging to the class hh is

βˆ‚llβˆ‚P(xg)βˆ‚P(ym|xg)=n∏jβ‰ mP(yj|xg)βˆ‘k=1KP(xk)∏j=1JP(yj|xk)βˆ’n∏j=1JP(yj|xg)P(xg)∏jβ‰ mP(yj|xg)(βˆ‘k=1KP(xk)∏j=1JP(yj|xk))2. \frac{\partial ll}{\partial P(x_g) \partial P(y_m|x_g)} = \frac{n \prod_{j\neq m} P(y_j|x_g) \sum_{k=1}^K P(x_k)\prod_{j=1}^J P(y_j|x_k) - n \prod_{j=1}^J P(y_j|x_g) P(x_g) \prod_{j\neq m} P(y_j|x_g)}{\Big(\sum_{k=1}^K P(x_k)\prod_{j=1}^J P(y_j|x_k)\Big)^2}.

βˆ‚llβˆ‚P(xh)βˆ‚P(ym|xg)=βˆ’n∏j=1JP(yj|xh)P(xg)∏jβ‰ mP(yj|xg)(βˆ‘k=1KP(xk)∏j=1JP(yj|xk))2. \frac{\partial ll}{\partial P(x_h) \partial P(y_m|x_g)} = -\frac{n \prod_{j=1}^J P(y_j|x_h) P(x_g) \prod_{j\neq m} P(y_j|x_g)}{\Big(\sum_{k=1}^K P(x_k)\prod_{j=1}^J P(y_j|x_k)\Big)^2}.

Model for the conditional probabilities

Bernoulli

When yjy_j is a bernoulli random variable, the conditional probability becomes P(yj|xk)=ΞΈjyj(1βˆ’ΞΈj)1βˆ’yj, P(y_j|x_k) = \theta_j^{y_j} (1-\theta_j)^{1-y_j}, where ΞΈj\theta_j is the probability of endorsing item jj (i.e., yj=1y_j=1).

Its partial derivative with respect to ΞΈj\theta_j is βˆ‚P(yj|xk)ΞΈj=12yjβˆ’1. \frac{\partial P(y_j|x_k)}{\theta_j} = \frac{1}{2y_j - 1}.

Multinomial

βˆ‚P(ym|xg)βˆ‚ΞΈmk|g=nlP(xg)∏jβ‰ mP(yj|xg). \frac{\partial P(y_m|x_g)}{\partial \theta_{m_k|g}} = \frac{n}{l} P(x_g)\prod_{j\neq m} P(y_j|x_g).

Gaussian

softmax

Evaluating the likelihood

trick to prevent undeflow