getLatentKappa {nlpsem}R Documentation

Compute Latent Kappa Coefficient for Agreement between Two Latent Label Sets

Description

This function calculates the latent kappa, a measure of agreement between two sets of latent categorical labels. It also computes the confidence interval and provides a qualitative interpretation of the agreement level.

Usage

getLatentKappa(label1, label2, conf.level = 0.95)

Arguments

label1

A factor vector representing the first set of latent categorical labels.

label2

A factor vector representing the second set of latent categorical labels.

conf.level

A numeric value representing the confidence level for the confidence interval of the kappa statistic. The default value is 0.95.

Value

An object of class KappaOutput with the following slots:

The content of these slots can be printed using the printTable() method for S4 objects.

References

Examples

mxOption(model = NULL, key = "Default optimizer", "CSOLNP", reset = FALSE)
data("RMS_dat")
RMS_dat0 <- RMS_dat
# Re-baseline the data so that the estimated initial status is for the starting point of the study
baseT <- RMS_dat0$T1
RMS_dat0$T1 <- RMS_dat0$T1 - baseT
RMS_dat0$T2 <- RMS_dat0$T2 - baseT
RMS_dat0$T3 <- RMS_dat0$T3 - baseT
RMS_dat0$T4 <- RMS_dat0$T4 - baseT
RMS_dat0$T5 <- RMS_dat0$T5 - baseT
RMS_dat0$T6 <- RMS_dat0$T6 - baseT
RMS_dat0$T7 <- RMS_dat0$T7 - baseT
RMS_dat0$T8 <- RMS_dat0$T8 - baseT
RMS_dat0$T9 <- RMS_dat0$T9 - baseT
RMS_dat0$ex1 <- scale(RMS_dat0$Approach_to_Learning)
RMS_dat0$ex2 <- scale(RMS_dat0$Attention_focus)
RMS_dat0$gx1 <- scale(RMS_dat0$INCOME)
RMS_dat0$gx2 <- scale(RMS_dat0$EDU)

## Fit a growth mixture model with no TICs
set.seed(20191029)
MIX_BLS_LGCM_r <-  getMIX(
  dat = RMS_dat0, prop_starts = c(0.33, 0.34, 0.33), sub_Model = "LGCM",
  cluster_TIC = NULL, y_var = "M", t_var = "T", records = 1:9,
  curveFun = "BLS", intrinsic = FALSE, res_scale = list(0.3, 0.3, 0.3),
  growth_TIC = NULL, tries = 10
)
## Membership of each individual from growth mixture model with no TICs
label1 <- getPosterior(
  model = MIX_BLS_LGCM_r@mxOutput, nClass = 3, label = FALSE, cluster_TIC = NULL
)
set.seed(20191029)
## Fit a growth mixture model with growth TICs and cluster TICs
MIX_BLS_LGCM.TIC_r <-  getMIX(
  dat = RMS_dat0, prop_starts = c(0.33, 0.34, 0.33), sub_Model = "LGCM",
  cluster_TIC = c("gx1", "gx2"), y_var = "M", t_var = "T", records = 1:9,
  curveFun = "BLS", intrinsic = FALSE, res_scale = list(0.3, 0.3, 0.3),
  growth_TIC = c("ex1", "ex2"), tries = 10
)
## Membership of each individual from growth mixture model with growth TICs and cluster TICs
label2 <- getPosterior(
  model = MIX_BLS_LGCM.TIC_r@mxOutput, nClass = 3, label = FALSE,
  cluster_TIC = c("gx1", "gx2")
)
## Calcualte the agreement between two sets of membership labels
getLatentKappa(label1 = label1@membership, label2 = label2@membership)



[Package nlpsem version 0.3 Index]