# pcirm-examples

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.

## Dichotomous Data with Local Dependence and Minor Trait:

library(LAWBL)
dat <- sim24ccfa21$dat head(dat) R> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] R> [1,] 2 1 2 2 2 2 2 2 1 2 2 2 2 2 R> [2,] 2 2 2 2 1 2 2 2 1 1 1 1 1 1 R> [3,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 R> [4,] 2 1 2 1 1 1 1 1 1 1 1 1 1 1 R> [5,] 2 2 2 2 2 2 2 2 2 2 2 1 2 2 R> [6,] 1 1 1 1 2 2 1 1 2 1 2 1 1 1 R> [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] R> [1,] 1 1 1 1 1 1 1 1 1 1 R> [2,] 2 2 1 1 1 2 2 1 2 2 R> [3,] 1 1 2 2 1 1 1 1 1 2 R> [4,] 1 1 1 1 2 1 1 1 2 2 R> [5,] 2 2 2 2 2 1 2 2 2 2 R> [6,] 2 2 1 1 1 1 1 1 1 1 J <- ncol(dat) # no. of items qlam <- sim24ccfa21$qlam
qlam
R>       [,1] [,2] [,3] [,4]
R>  [1,]  0.7  0.0  0.0 0.00
R>  [2,]  0.7  0.0  0.0 0.00
R>  [3,]  0.7  0.0  0.0 0.00
R>  [4,]  0.7  0.0  0.0 0.00
R>  [5,]  0.7  0.0  0.0 0.00
R>  [6,]  0.7  0.0  0.0 0.00
R>  [7,]  0.7  0.0  0.0 0.00
R>  [8,]  0.7  0.0  0.0 0.00
R>  [9,]  0.0  0.7  0.0 0.00
R> [10,]  0.0  0.7  0.0 0.00
R> [11,]  0.0  0.7  0.0 0.00
R> [12,]  0.0  0.7  0.0 0.00
R> [13,]  0.0  0.7  0.0 0.00
R> [14,]  0.0  0.7  0.0 0.00
R> [15,]  0.0  0.7  0.0 0.55
R> [16,]  0.0  0.7  0.0 0.55
R> [17,]  0.0  0.0  0.7 0.00
R> [18,]  0.0  0.0  0.7 0.00
R> [19,]  0.0  0.0  0.7 0.00
R> [20,]  0.0  0.0  0.7 0.00
R> [21,]  0.0  0.0  0.7 0.00
R> [22,]  0.0  0.0  0.7 0.00
R> [23,]  0.0  0.0  0.7 0.55
R> [24,]  0.0  0.0  0.7 0.55
K <- ncol(qlam) # no. of factors
1. 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 = 2000,iter = 2000,verbose = TRUE)
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_eigen(m0) # trace
plot_eigen(m0, what='density') #density
plot_eigen(m0, what='APSR') #adj, PSRF
1. 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 = 4000,iter = 4000,verbose = TRUE)
summary(m1)
summary(m1, what = 'qlambda') #close to qlam
1. 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 = 4000,iter = 4000,verbose = TRUE)
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_eigen(m2) # trace
plot_eigen(m2, what='density') #density
plot_eigen(m2, what='APSR') #adj, PSRF