Learn R Programming

LCPA (version 1.0.0)

get.Log.Lik.LTA: Calculate Log-Likelihood for Latent Transition Analysis

Description

Computes the observed-data log-likelihood for a Latent Transition Analysis (LTA) model using the three-step approach with measurement error correction. The likelihood integrates over all possible latent class paths while incorporating classification uncertainty via Classification Error Probability (CEP) matrices. This function is designed to work with parameters estimated from the LTA function.

Usage

get.Log.Lik.LTA(
  params,
  CEP,
  P.Z.Xns,
  Zs,
  covariates,
  covariates.timeCross = FALSE
)

Value

A single numeric value representing the total observed-data log-likelihood: $$ \begin{aligned} \log \mathcal{L}(\boldsymbol{\theta}) &= \sum_{n=1}^N \log \Biggl[ \sum_{\mathbf{z}_n \in \{1,\dots,L\}^T} \Bigl( \prod_{t=1}^T \text{CEP}_t(z_{nt}, \hat{z}_{nt}) \Bigr) \cdot \\ &\quad P(Z_{n1}=z_{n1} \mid \mathbf{X}_{n1}) \cdot \prod_{t=2}^T P(Z_{nt}=z_{nt} \mid Z_{n,t-1}=z_{n,t-1}, \mathbf{X}_{nt}) \Biggr] \end{aligned} $$

where \(\mathbf{z}_n = (z_{n1},\dots,z_{nT})\) is a latent class path, \(\hat{z}_{nt} = \texttt{Zs[[t]][n]}\) is the modal assignment, and \(\boldsymbol{\theta}\) denotes all model parameters (beta, gama).

Arguments

params

A named list containing model parameters:

  • beta: Matrix of size \(p_1 \times L\) with coefficients for the initial class membership multinomial logit model (time 1). The coefficient vector for reference class \(L\) is constrained to \(\boldsymbol{\beta}_L = \mathbf{0}\).

  • gama: Nested list of transition coefficients. For transition to time \(t\) (from time \(t-1\) to \(t\), where \(t = 2, \dots, T\)):

    gama[[t-1]][[from_class]][[to_class]]

    Coefficient vector of length \(p_t\) for transition from class from_class at time \(t-1\) to class to_class at time \(t\).

Coefficients for transitions to reference class \(L\) are constrained to zero vectors (\(\boldsymbol{\gamma}_{kl t} = \mathbf{0}\) when \(k = L\)).

CEP

A list of \(L \times L\) matrices (length = number of time points \(T\)). Element \((k,l)\) in CEP[[t]] estimates: $$P(\hat{Z}_{nt} = l \mid Z_{nt} = k)$$ where \(\hat{Z}_{nt}\) is the modal class assignment and \(Z_{nt}\) is the true latent class. Computed via non-parametric approximation in Step 2 of three-step LTA.

P.Z.Xns

A list of matrices (length = \(T\)). Each matrix has dimensions \(N \times L\), where element \((n,l)\) is: $$P(Z_{nt} = l \mid \mathbf{X}_{nt})$$ the posterior probability of individual \(n\) belonging to class \(l\) at time \(t\) from Step 1 latent class/profile analysis.

Zs

A list of integer vectors (length = \(T\)). Each vector has length \(N\), where Zs[[t]][n] is the modal (most likely) class assignment \(\hat{Z}_{nt}\) for individual \(n\) at time \(t\).

covariates

A list of design matrices (length = \(T\)). For time \(t\), matrix dimension is \(N \times p_t\). Must include an intercept column (all 1s) as the first column, i.e., \(\mathbf{X}_{nt} = (X_{nt0}, X_{nt1}, \dots, X_{ntM})^\top\) with \(X_{nt0} = 1\). Covariates may differ across time points and between initial status (\(t=1\)) and transitions (\(t \geq 2\)).

covariates.timeCross

Logical. If TRUE, forces identical transition coefficients across all time points (gama[[t]] is copied from gama[[1]] for \(t>1\)). Default is FALSE.

Details

The log-likelihood calculation follows these steps:

  1. Latent Path Enumeration: All \(L^T\) possible latent class trajectories \(\mathbf{z}_n\) are generated and cached.

  2. Initial Class Probabilities (time 1): For individual \(n\), compute using multinomial logit with covariates \(\mathbf{X}_{n1}\): $$P(Z_{n1} = l \mid \mathbf{X}_{n1}) = \frac{\exp(\boldsymbol{\beta}_l^\top \mathbf{X}_{n1})} {\sum_{k=1}^L \exp(\boldsymbol{\beta}_k^\top \mathbf{X}_{n1})}$$ where \(\boldsymbol{\beta}_L = \mathbf{0}\) (reference class constraint). Numerical stabilization is applied via subtraction of the maximum linear predictor.

  3. Transition Probabilities (times \(t \geq 2\)): For transition from class \(k\) at time \(t-1\) to class \(l\) at time \(t\): $$P(Z_{nt} = l \mid Z_{n,t-1} = k, \mathbf{X}_{nt}) = \frac{\exp(\boldsymbol{\gamma}_{kl t}^\top \mathbf{X}_{nt})} {\sum_{j=1}^L \exp(\boldsymbol{\gamma}_{kj t}^\top \mathbf{X}_{nt})}$$ where \(\boldsymbol{\gamma}_{kL t} = \mathbf{0}\) for all \(k\) (reference class constraint).

  4. Path-Specific Likelihood: For each path \(\mathbf{z}_n\) and individual \(n\):

    1. Compute path probability: \(P(Z_{n1}=z_{n1} \mid \mathbf{X}_{n1}) \times \prod_{t=2}^T P(Z_{nt}=z_{nt} \mid Z_{n,t-1}=z_{n,t-1}, \mathbf{X}_{nt})\)

    2. Apply CEP weights: \(\prod_{t=1}^T P(\hat{Z}_{nt} = \hat{z}_{nt} \mid Z_{nt} = z_{nt}) = \prod_{t=1}^T \text{CEP}_t(z_{nt}, \hat{z}_{nt})\)

    3. Multiply path probability by CEP weights

  5. Marginalization: Sum path-specific likelihoods over all \(L^T\) paths for each individual \(n\), then sum log-transformed marginal likelihoods across all individuals.

See Also

LTA for three-step LTA estimation, get.CEP for CEP matrix computation