This is the script I am working on:
library(poLCA)
f <- cbind(bq70, bq72_1, bq72_2, bq72_3, bq72_4, bq72_5,
bq72_6, bq72_7, bq73a_1, bq73a_2, bq73a_3, bq73a_4) ~
zq88 + zq89 + dm_zq101_2 + dm_zq101_3 + dm_zq101_4 +
dm_zq101_5 + dm_zq101_6 + dm_zq101_7 + dm_zq101_8 + dm_zq101_9
for(i in 2:14){
max_II <- -1000000
min_bic <- 100000
for(j in 1:1024){
res <- poLCA(f, BESDATA, nclass=i, maxiter=1000,
tol=1e-5, na.rm=FALSE, probs.start=NULL,
nrep=1, verbose=TRUE, calc.se=TRUE)
if(res$bic < min_bic){
min_bic <- res$bic
LCA_best_model<-res
}
}
}
I would like to perform a latent class analysis, and also with a regression. However, the above code takes my pc a very long time to complete (intel core i5 4690k, 16gb ram).
Is it typical for poLCA to take this long?
Also, is there a line of code that I can use that will stop the loops for each class once global maximum likelihood has been reached?
N = around 2000.
I use R studio by the way, in case it matters!