我正在准备 LCA(LCR)分析,并尝试学习如何使用估算数据进行分析。我之前曾使用鼠标进行回归分析,然后这个过程非常简单。
我正在准备 LCA(LCR)分析,并尝试学习如何使用估算数据进行分析。
我以前用过鼠标进行回归分析,当时的程序相当简单。然而,这个程序似乎不适用于 GLCA。有什么建议吗?
# Step 1: Simulate a Sample Dataset
set.seed(123)
n <- 200
# Simulating a dataset with missing data in covariates
data <- data.frame(
var1 = sample(1:5, n, replace = TRUE), # LCA variable 1
var2 = sample(1:4, n, replace = TRUE), # LCA variable 2
var3 = sample(1:3, n, replace = TRUE), # LCA variable 3
covariate1 = rnorm(n), # Continuous covariate with missing data
covariate2 = sample(1:5, n, replace = TRUE) # Categorical covariate with missing data
)
# Introduce missing data in covariates
data$covariate1[sample(1:n, 30)] <- NA # 15% missing data
data$covariate2[sample(1:n, 20)] <- NA # 10% missing data
imputed_data <- mice(data, m = 5, method = "pmm", seed = 500) #Imputed data
lca_model <- with(imputed_data, glca(nclass = 3, item(var1, var2, var3) ~ covariate1, covariate2, n.init = 1)) #LCA-modelling
summary(lca_model) #This returns the error "Error: No tidy method for objects of class glca"
summary(pool(lca_model)) #This returns the error "Error: No tidy method for objects of class glca
#In addition: Warning message:
# In get.dfcom(object, dfcom) : Infinite sample size assumed.