ETAs <- ETAmat(K, J, Q_matrix)
class_0 <- sample(1:2^K, N, replace = L)
Alphas_0 <- matrix(0,N,K)
mu_thetatau = c(0,0)
Sig_thetatau = rbind(c(1.8^2,.4*.5*1.8),c(.4*.5*1.8,.25))
Z = matrix(rnorm(N*2),N,2)
thetatau_true = Z%*%chol(Sig_thetatau)
thetas_true = thetatau_true[,1]
taus_true = thetatau_true[,2]
G_version = 3
phi_true = 0.8
for(i in 1:N){
Alphas_0[i,] <- inv_bijectionvector(K,(class_0[i]-1))
}
lambdas_true <- c(-2, .4, .055) # empirical from Wang 2017
Alphas <- sim_alphas(model="HO_joint",
lambdas=lambdas_true,
thetas=thetas_true,
Q_matrix=Q_matrix,
Design_array=Design_array)
table(rowSums(Alphas[,,5]) - rowSums(Alphas[,,1])) # used to see how much transition has taken place
#>
#> 0 1 2 3 4
#> 64 55 83 114 34
itempars_true <- matrix(runif(J*2,.1,.2), ncol=2)
RT_itempars_true <- matrix(NA, nrow=J, ncol=2)
RT_itempars_true[,2] <- rnorm(J,3.45,.5)
RT_itempars_true[,1] <- runif(J,1.5,2)
Y_sim <- sim_hmcdm(model="DINA",Alphas,Q_matrix,Design_array,
itempars=itempars_true)
L_sim <- sim_RT(Alphas,Q_matrix,Design_array,
RT_itempars_true,taus_true,phi_true,G_version)
output_HMDCM_RT_joint = hmcdm(Y_sim,Q_matrix,"DINA_HO_RT_joint",Design_array,100,30,
Latency_array = L_sim, G_version = G_version,
theta_propose = 2,deltas_propose = c(.45,.25,.06))
#> 0
output_HMDCM_RT_joint
#>
#> Model: DINA_HO_RT_joint
#>
#> Sample Size: 350
#> Number of Items:
#> Number of Time Points:
#>
#> Chain Length: 100, burn-in: 50
summary(output_HMDCM_RT_joint)
#>
#> Model: DINA_HO_RT_joint
#>
#> Item Parameters:
#> ss_EAP gs_EAP
#> 0.22532 0.2052
#> 0.21637 0.1363
#> 0.28094 0.1371
#> 0.21710 0.1168
#> 0.09446 0.2245
#> ... 45 more items
#>
#> Transition Parameters:
#> lambdas_EAP
#> λ0 -3.1008
#> λ1 0.0947
#> λ2 0.2752
#>
#> Class Probabilities:
#> pis_EAP
#> 0000 0.1316
#> 0001 0.2110
#> 0010 0.1564
#> 0011 0.2303
#> 0100 0.1277
#> ... 11 more classes
#>
#> Deviance Information Criterion (DIC): 158202.4
#>
#> Posterior Predictive P-value (PPP):
#> M1: 0.5076
#> M2: 0.49
#> total scores: 0.6235
a <- summary(output_HMDCM_RT_joint)
a
#>
#> Model: DINA_HO_RT_joint
#>
#> Item Parameters:
#> ss_EAP gs_EAP
#> 0.22532 0.2052
#> 0.21637 0.1363
#> 0.28094 0.1371
#> 0.21710 0.1168
#> 0.09446 0.2245
#> ... 45 more items
#>
#> Transition Parameters:
#> lambdas_EAP
#> λ0 -3.1008
#> λ1 0.0947
#> λ2 0.2752
#>
#> Class Probabilities:
#> pis_EAP
#> 0000 0.1316
#> 0001 0.2110
#> 0010 0.1564
#> 0011 0.2303
#> 0100 0.1277
#> ... 11 more classes
#>
#> Deviance Information Criterion (DIC): 158202.4
#>
#> Posterior Predictive P-value (PPP):
#> M1: 0.5108
#> M2: 0.49
#> total scores: 0.623
a$ss_EAP
#> [,1]
#> [1,] 0.22532151
#> [2,] 0.21637219
#> [3,] 0.28093710
#> [4,] 0.21710260
#> [5,] 0.09446081
#> [6,] 0.09450295
#> [7,] 0.15848813
#> [8,] 0.15109879
#> [9,] 0.19932304
#> [10,] 0.13248230
#> [11,] 0.14290901
#> [12,] 0.18587316
#> [13,] 0.15098260
#> [14,] 0.17363300
#> [15,] 0.15046872
#> [16,] 0.16897644
#> [17,] 0.17511254
#> [18,] 0.20521302
#> [19,] 0.10588287
#> [20,] 0.10875672
#> [21,] 0.21934760
#> [22,] 0.18824273
#> [23,] 0.13966137
#> [24,] 0.25493274
#> [25,] 0.16736327
#> [26,] 0.21540074
#> [27,] 0.18807268
#> [28,] 0.14223415
#> [29,] 0.14443937
#> [30,] 0.19691753
#> [31,] 0.15981576
#> [32,] 0.20097515
#> [33,] 0.17020442
#> [34,] 0.22851427
#> [35,] 0.14086579
#> [36,] 0.10862603
#> [37,] 0.24408210
#> [38,] 0.23114127
#> [39,] 0.15210578
#> [40,] 0.10940601
#> [41,] 0.18706496
#> [42,] 0.17652787
#> [43,] 0.14491090
#> [44,] 0.15709135
#> [45,] 0.16179697
#> [46,] 0.13527903
#> [47,] 0.14532566
#> [48,] 0.19799098
#> [49,] 0.22146977
#> [50,] 0.20726222
head(a$ss_EAP)
#> [,1]
#> [1,] 0.22532151
#> [2,] 0.21637219
#> [3,] 0.28093710
#> [4,] 0.21710260
#> [5,] 0.09446081
#> [6,] 0.09450295
(cor_thetas <- cor(thetas_true,a$thetas_EAP))
#> [,1]
#> [1,] 0.8036101
(cor_taus <- cor(taus_true,a$response_times_coefficients$taus_EAP))
#> [,1]
#> [1,] 0.984953
(cor_ss <- cor(as.vector(itempars_true[,1]),a$ss_EAP))
#> [,1]
#> [1,] 0.5691691
(cor_gs <- cor(as.vector(itempars_true[,2]),a$gs_EAP))
#> [,1]
#> [1,] 0.5874792
AAR_vec <- numeric(L)
for(t in 1:L){
AAR_vec[t] <- mean(Alphas[,,t]==a$Alphas_est[,,t])
}
AAR_vec
#> [1] 0.9100000 0.9185714 0.9378571 0.9428571 0.9500000
PAR_vec <- numeric(L)
for(t in 1:L){
PAR_vec[t] <- mean(rowSums((Alphas[,,t]-a$Alphas_est[,,t])^2)==0)
}
PAR_vec
#> [1] 0.6857143 0.6971429 0.7857143 0.8085714 0.8400000
a$DIC
#> Transition Response_Time Response Joint Total
#> D_bar 1914.792 136395.3 15164.48 3631.777 157106.4
#> D(theta_bar) 1645.803 135961.0 14901.81 3501.764 156010.4
#> DIC 2183.781 136829.6 15427.15 3761.790 158202.4
head(a$PPP_total_scores)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.42 0.76 0.20 0.60 0.62
#> [2,] 0.90 0.46 0.86 0.84 0.88
#> [3,] 0.94 0.06 0.92 0.48 0.86
#> [4,] 0.72 0.44 0.58 0.50 0.76
#> [5,] 0.86 0.70 0.18 0.72 0.16
#> [6,] 0.94 0.44 0.32 0.88 0.32
head(a$PPP_total_RTs)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.42 0.14 0.84 0.12 0.30
#> [2,] 0.62 0.64 0.68 0.34 0.16
#> [3,] 0.14 0.58 0.66 0.70 0.34
#> [4,] 0.16 0.20 0.72 0.70 0.26
#> [5,] 0.94 0.16 0.76 0.26 0.92
#> [6,] 0.90 0.26 0.64 0.00 0.26
head(a$PPP_item_means)
#> [1] 0.40 0.48 0.56 0.48 0.46 0.68
head(a$PPP_item_mean_RTs)
#> [1] 0.58 0.42 0.24 0.30 0.42 0.38
head(a$PPP_item_ORs)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
#> [1,] NA 0.86 0.96 0.76 0.88 0.74 0.28 0.58 0.70 0.74 0.98 0.74 0.32 0.98
#> [2,] NA NA 1.00 0.72 0.58 0.80 0.54 0.04 0.40 0.84 0.98 0.78 0.50 1.00
#> [3,] NA NA NA 0.44 0.82 0.56 0.94 0.46 0.98 0.90 0.44 0.80 0.64 0.98
#> [4,] NA NA NA NA 0.94 0.72 0.98 0.86 0.86 0.94 0.88 0.54 0.82 0.24
#> [5,] NA NA NA NA NA 0.52 0.54 0.58 0.34 0.14 0.96 0.60 0.22 0.36
#> [6,] NA NA NA NA NA NA 0.72 0.60 0.74 0.94 0.50 0.42 0.60 0.82
#> [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
#> [1,] 0.88 0.64 0.90 0.84 0.84 0.86 0.58 0.44 0.46 0.84 0.34 0.18
#> [2,] 0.70 0.94 0.62 0.84 0.98 0.88 0.34 0.26 0.30 0.38 0.70 0.72
#> [3,] 0.64 0.16 0.52 0.48 0.90 0.76 0.94 0.58 0.18 0.88 0.48 0.78
#> [4,] 0.90 0.62 1.00 0.72 0.92 0.88 0.56 0.26 0.68 0.66 0.42 0.50
#> [5,] 0.14 0.20 0.54 0.84 0.86 0.48 0.50 0.46 0.46 0.40 0.78 0.16
#> [6,] 0.28 0.28 0.64 0.28 0.64 0.66 0.06 0.92 0.52 0.58 0.42 0.00
#> [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37] [,38]
#> [1,] 0.00 0.24 0.22 0.36 0.02 0.66 0.74 0.80 0.86 0.40 0.50 0.84
#> [2,] 0.72 0.34 0.46 1.00 0.02 0.08 0.66 0.68 0.28 0.20 0.42 0.24
#> [3,] 0.32 0.68 0.92 0.70 0.66 0.20 0.16 0.50 0.68 0.56 0.58 0.86
#> [4,] 0.44 0.06 0.96 0.16 0.70 0.64 0.12 0.30 0.78 0.62 0.92 0.56
#> [5,] 0.64 0.20 0.24 0.22 0.76 0.40 0.96 0.56 0.82 0.00 0.46 0.40
#> [6,] 0.54 0.18 0.32 0.58 0.00 0.26 0.48 0.58 0.16 0.08 0.64 0.28
#> [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49] [,50]
#> [1,] 0.26 0.48 0.92 0.94 0.66 0.92 0.94 0.58 0.80 1.00 1.00 0.12
#> [2,] 0.34 0.28 0.34 0.98 0.20 0.28 0.42 0.08 0.62 0.58 0.38 0.04
#> [3,] 0.44 0.80 0.46 0.20 0.72 0.94 0.52 0.70 0.84 0.68 1.00 0.04
#> [4,] 0.56 0.68 0.02 1.00 0.70 0.78 0.54 0.36 0.68 0.92 0.80 0.92
#> [5,] 0.60 0.70 0.22 0.96 0.10 0.40 0.74 0.20 0.74 0.46 0.90 0.14
#> [6,] 0.06 0.76 0.68 0.98 0.42 0.36 0.60 0.02 0.48 0.46 0.56 0.28