knitr::opts_chunk$set(echo = TRUE)
Note: the estimation process can be time consuming depending on the computing power. You can same some time by reducing the length of the chains.
1) Load the package, obtain the data, check the true loading pattern (qlam) and no. of factors/traits.
library(LAWBL) dat <- sim24ccfa21$dat head(dat) J <- ncol(dat) # no. of items qlam <- sim24ccfa21$qlam qlam K <- ncol(qlam) # no. of factors
2) PCIRM with primary loadings and three traits specified. Longer chain is suggested for stabler performance (burn=iter=5,000 by default).
ipf <- 8 Q<-matrix(-1,J,K-1); # -1 for unspecified items Q[1:8,1]<-Q[9:16,2]<-Q[17:24,3]<-1 Q m0<-pcirm(dat = dat,Q= Q,LD = TRUE,cati = -1,burn = 5000,iter = 5000) summary(m0) summary(m0, what = 'qlambda') summary(m0, what = 'offpsx') #summarize significant LD terms summary(m0,what='int') summary(m0,what='eigen') #plotting factorial eigenvalue plot_lawbl(m0) # trace plot_lawbl(m0, what='density') #density plot_lawbl(m0, what='EPSR') #EPSR
3) PCIRM-LI with four traits and two cross-loadings specified based on results from previous step. Longer chain is suggested for stabler performance.
Q<-cbind(Q,-1); Q[c(15:16),K] <- 1 m1<-pcirm(dat = dat,Q= Q,LD = FALSE, cati = -1,burn = 5000,iter = 5000) summary(m1) summary(m1, what = 'qlambda') #close to qlam
4) PCIRM with four traits and four cross-loadings specified based on results from previous step. Longer chain is suggested for stabler performance.
tmp<-summary(m1, what="qlambda") Q<-matrix(-1,J,K) Q[tmp!=0]<-1 Q m2<-pcirm(dat = dat,Q= Q,LD = TRUE,cati = -1,burn = 5000,iter = 5000) summary(m2) summary(m2, what = 'qlambda') summary(m2, what = 'offpsx') #summarize significant LD terms summary(m2,what='int') summary(m2,what='eigen') #plotting factorial eigenvalue plot_lawbl(m2) # trace plot_lawbl(m2, what='density') #density plot_lawbl(m2, what='EPSR') #EPSR
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.