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
#> 70 51 75 121 33
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.1300 0.1258
#> 0.1136 0.1292
#> 0.1635 0.1215
#> 0.1568 0.1777
#> 0.1263 0.1914
#> ... 45 more items
#>
#> Transition Parameters:
#> lambdas_EAP
#> λ0 -1.65090
#> λ1 0.20662
#> λ2 0.08132
#>
#> Class Probabilities:
#> pis_EAP
#> 0000 0.2148
#> 0001 0.1856
#> 0010 0.1697
#> 0011 0.1974
#> 0100 0.1708
#> ... 11 more classes
#>
#> Deviance Information Criterion (DIC): 152228.6
#>
#> Posterior Predictive P-value (PPP):
#> M1: 0.5064
#> M2: 0.49
#> total scores: 0.6226
a <- summary(output_HMDCM_RT_joint)
a
#>
#> Model: DINA_HO_RT_joint
#>
#> Item Parameters:
#> ss_EAP gs_EAP
#> 0.1300 0.1258
#> 0.1136 0.1292
#> 0.1635 0.1215
#> 0.1568 0.1777
#> 0.1263 0.1914
#> ... 45 more items
#>
#> Transition Parameters:
#> lambdas_EAP
#> λ0 -1.65090
#> λ1 0.20662
#> λ2 0.08132
#>
#> Class Probabilities:
#> pis_EAP
#> 0000 0.2148
#> 0001 0.1856
#> 0010 0.1697
#> 0011 0.1974
#> 0100 0.1708
#> ... 11 more classes
#>
#> Deviance Information Criterion (DIC): 152228.6
#>
#> Posterior Predictive P-value (PPP):
#> M1: 0.5188
#> M2: 0.49
#> total scores: 0.6247
a$ss_EAP
#> [,1]
#> [1,] 0.12999633
#> [2,] 0.11360049
#> [3,] 0.16348123
#> [4,] 0.15683769
#> [5,] 0.12625522
#> [6,] 0.19755273
#> [7,] 0.12119278
#> [8,] 0.19518701
#> [9,] 0.18230846
#> [10,] 0.14043451
#> [11,] 0.09472822
#> [12,] 0.13562448
#> [13,] 0.12552354
#> [14,] 0.20268698
#> [15,] 0.13647910
#> [16,] 0.16507338
#> [17,] 0.11665838
#> [18,] 0.17168741
#> [19,] 0.22589366
#> [20,] 0.23840032
#> [21,] 0.13206921
#> [22,] 0.19269680
#> [23,] 0.20376446
#> [24,] 0.22422448
#> [25,] 0.19176068
#> [26,] 0.18315390
#> [27,] 0.17404486
#> [28,] 0.09818167
#> [29,] 0.14364529
#> [30,] 0.13079080
#> [31,] 0.13909495
#> [32,] 0.19240481
#> [33,] 0.12058378
#> [34,] 0.14056519
#> [35,] 0.21799864
#> [36,] 0.12087723
#> [37,] 0.12033629
#> [38,] 0.18958418
#> [39,] 0.12398808
#> [40,] 0.20718206
#> [41,] 0.08836154
#> [42,] 0.19828595
#> [43,] 0.16687008
#> [44,] 0.20949203
#> [45,] 0.19933541
#> [46,] 0.16242713
#> [47,] 0.15988273
#> [48,] 0.19879919
#> [49,] 0.11813948
#> [50,] 0.13712726
head(a$ss_EAP)
#> [,1]
#> [1,] 0.1299963
#> [2,] 0.1136005
#> [3,] 0.1634812
#> [4,] 0.1568377
#> [5,] 0.1262552
#> [6,] 0.1975527(cor_thetas <- cor(thetas_true,a$thetas_EAP))
#> [,1]
#> [1,] 0.8531207
(cor_taus <- cor(taus_true,a$response_times_coefficients$taus_EAP))
#> [,1]
#> [1,] 0.9876732
(cor_ss <- cor(as.vector(itempars_true[,1]),a$ss_EAP))
#> [,1]
#> [1,] 0.6474638
(cor_gs <- cor(as.vector(itempars_true[,2]),a$gs_EAP))
#> [,1]
#> [1,] 0.683952
AAR_vec <- numeric(L)
for(t in 1:L){
AAR_vec[t] <- mean(Alphas[,,t]==a$Alphas_est[,,t])
}
AAR_vec
#> [1] 0.9457143 0.9421429 0.9650000 0.9664286 0.9664286
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.8171429 0.7857143 0.8657143 0.8800000 0.8914286a$DIC
#> Transition Response_Time Response Joint Total
#> D_bar 2242.770 131145.3 14793.21 3163.920 151345.2
#> D(theta_bar) 1958.254 130715.8 14759.70 3028.184 150461.9
#> DIC 2527.286 131574.9 14826.72 3299.657 152228.6
head(a$PPP_total_scores)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.42 0.88 0.28 0.94 0.44
#> [2,] 0.92 0.50 0.76 0.30 0.02
#> [3,] 0.66 0.74 0.76 0.48 1.00
#> [4,] 0.20 0.24 0.62 0.44 0.78
#> [5,] 0.96 0.24 0.28 0.70 0.90
#> [6,] 0.42 0.98 1.00 0.42 0.82
head(a$PPP_total_RTs)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1.00 1.00 0.26 0.68 0.04
#> [2,] 0.24 0.30 0.38 0.84 0.64
#> [3,] 0.50 0.34 0.46 0.46 0.64
#> [4,] 0.94 0.42 0.26 0.96 0.02
#> [5,] 0.14 0.34 0.24 0.70 0.36
#> [6,] 0.42 0.48 0.34 0.42 0.20
head(a$PPP_item_means)
#> [1] 0.56 0.48 0.46 0.62 0.62 0.44
head(a$PPP_item_mean_RTs)
#> [1] 0.20 0.40 0.66 0.64 0.64 0.34
head(a$PPP_item_ORs)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
#> [1,] NA 0.4 0.20 0.92 0.42 0.66 0.32 0.36 0.64 0.40 0.78 0.04 0.72 0.70
#> [2,] NA NA 0.36 0.94 0.10 0.68 0.26 0.80 0.52 0.56 0.52 0.66 0.58 0.18
#> [3,] NA NA NA 0.62 0.24 0.70 0.10 0.38 0.72 0.88 0.30 0.94 0.56 0.46
#> [4,] NA NA NA NA 0.18 0.54 0.72 0.64 0.88 0.50 0.88 1.00 0.54 0.84
#> [5,] NA NA NA NA NA 0.46 0.58 0.24 0.08 0.64 0.64 0.04 0.24 0.50
#> [6,] NA NA NA NA NA NA 0.32 0.56 0.88 0.48 0.16 0.10 0.92 0.20
#> [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
#> [1,] 0.66 0.74 0.82 0.84 0.20 0.88 0.44 0.34 0.04 0.36 0.52 0.58
#> [2,] 0.12 0.78 0.42 0.94 0.08 0.30 0.62 0.28 0.50 0.58 0.70 0.78
#> [3,] 0.30 0.78 0.90 0.66 0.48 0.84 0.68 0.28 0.84 0.38 0.56 0.74
#> [4,] 0.70 0.88 0.94 0.68 0.74 0.92 0.84 1.00 0.92 0.84 0.48 0.76
#> [5,] 0.48 0.98 0.84 0.20 0.92 0.44 0.94 0.82 0.12 0.68 0.56 0.94
#> [6,] 0.28 0.78 0.12 0.10 0.14 0.52 0.68 0.98 0.64 0.94 0.86 0.84
#> [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37] [,38]
#> [1,] 0.32 0.08 0.80 0.50 0.92 0.80 0.98 0.44 0.38 0.20 0.82 0.94
#> [2,] 0.62 0.48 0.44 0.64 0.50 0.94 0.86 0.18 0.92 0.48 0.82 0.68
#> [3,] 0.60 0.16 0.14 0.20 0.58 0.44 0.30 0.56 0.64 0.12 0.72 0.62
#> [4,] 0.48 0.02 0.98 0.38 1.00 0.08 0.22 0.48 0.44 0.42 0.84 0.68
#> [5,] 0.62 0.08 0.06 0.68 0.20 0.28 0.92 0.62 0.80 0.22 0.96 0.66
#> [6,] 0.78 0.48 0.32 0.58 0.30 0.82 0.66 0.86 0.96 0.42 0.80 0.50
#> [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49] [,50]
#> [1,] 0.74 0.00 0.66 0.44 0.24 0.82 0.18 0.10 1.00 0.30 0.12 0.16
#> [2,] 0.18 0.54 0.06 0.32 0.42 0.38 0.04 0.76 0.60 0.48 0.46 0.78
#> [3,] 0.48 0.38 0.14 0.42 0.88 0.34 0.78 0.68 0.66 0.32 0.58 0.64
#> [4,] 0.82 0.00 0.90 0.74 0.94 0.96 0.68 0.30 0.94 0.46 0.54 0.56
#> [5,] 0.98 0.04 0.70 0.04 0.56 0.52 0.06 0.18 0.84 0.44 0.22 0.20
#> [6,] 1.00 0.46 0.40 0.20 0.94 0.18 0.40 0.46 0.84 0.72 0.10 0.72