Learn R Programming

LCPA (version 1.0.0)

compare.model: Model Comparison Tool

Description

Compares two nested latent class/profile models using multiple fit indices, likelihood ratio tests, and classification metrics.

Usage

compare.model(object1, object2, n.Bootstrap = 0)

Value

An object of class compare.model containing:

npar

Named vector with number of free parameters for each model

entropy

Named vector with entropy values (classification accuracy measure) for each model

AvePP

List containing average posterior probabilities per latent class/profile

fit.index

List of get.fit.index objects for both models

BF

Bayes Factor for model comparison (based on SIC)

LRT.obj

Likelihood ratio test (LRT) results

LRT.VLMR.obj

Vuong-Lo-Mendell-Rubin (VLMR) adjusted LRT results

LRT.Bootstrap.obj

Bootstrap LRT results (if n.Bootstrap > 0)

call

The matched function call

arguments

List containing the original arguments passed to the function

Arguments

object1

An object of class LCA or LPA, representing the first latent class/profile model.

object2

An object of class LCA or LPA, representing the second latent class/profile model. Must be of the same type as object1.

n.Bootstrap

Integer specifying the number of bootstrap replications for the parametric bootstrap likelihood ratio test (BLRT). Default is 0 (no bootstrap test performed).

Details

This function performs comprehensive model comparison between two nested LCA/LPA models. Key features include:

  • Automatically orders models by parameter count (smaller model first)

  • Computes multiple fit indices via get.fit.index

  • Calculates classification quality metrics (entropy, average posterior probabilities)

  • Performs three types of likelihood ratio tests:

    • Standard LRT, see LRT.test

    • VLMR adjusted LRT, see LRT.test.VLMR

    • Parametric bootstrap LRT (computationally intensive but robust), see LRT.test.Bootstrap

  • Computes Bayes Factor using Sample-Size Adjusted BIC (SIC)

Important Requirements:

  • Both models must be of the same type (LCA or LPA)

  • Models must be nested (one model is a constrained version of the other)

  • n.Bootstrap > 0 requires significant computational resources

See Also

LCA, LPA, get.fit.index, extract, LRT.test, LRT.test.VLMR

Examples

Run this code
library(LCPA)
set.seed(123)

data.obj <- sim.LPA(N = 500, I = 5, L = 3, constraint = "V0")
response <- data.obj$response

# need Mplus
if (FALSE) {
# Compare 3-class vs 4-class LPA models
object1 <- LPA(response, L = 3, method = "Mplus", constraint = "V0")
object2 <- LPA(response, L = 4, method = "Mplus", constraint = "V0")

compare.model.obj <- compare.model(object1, object2)

print(compare.model.obj)
}

Run the code above in your browser using DataLab