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
#> 68 62 83 99 38
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.1557 0.1143
#> 0.2245 0.1741
#> 0.2263 0.1156
#> 0.1533 0.2161
#> 0.1638 0.1624
#> ... 45 more items
#>
#> Transition Parameters:
#> lambdas_EAP
#> λ0 -2.0626
#> λ1 0.1431
#> λ2 0.2529
#>
#> Class Probabilities:
#> pis_EAP
#> 0000 0.0859
#> 0001 0.1950
#> 0010 0.1360
#> 0011 0.2987
#> 0100 0.1423
#> ... 11 more classes
#>
#> Deviance Information Criterion (DIC): 154707
#>
#> Posterior Predictive P-value (PPP):
#> M1: 0.5164
#> M2: 0.49
#> total scores: 0.6248
a <- summary(output_HMDCM_RT_joint)
a
#>
#> Model: DINA_HO_RT_joint
#>
#> Item Parameters:
#> ss_EAP gs_EAP
#> 0.1557 0.1143
#> 0.2245 0.1741
#> 0.2263 0.1156
#> 0.1533 0.2161
#> 0.1638 0.1624
#> ... 45 more items
#>
#> Transition Parameters:
#> lambdas_EAP
#> λ0 -2.0626
#> λ1 0.1431
#> λ2 0.2529
#>
#> Class Probabilities:
#> pis_EAP
#> 0000 0.0859
#> 0001 0.1950
#> 0010 0.1360
#> 0011 0.2987
#> 0100 0.1423
#> ... 11 more classes
#>
#> Deviance Information Criterion (DIC): 154707
#>
#> Posterior Predictive P-value (PPP):
#> M1: 0.5172
#> M2: 0.49
#> total scores: 0.6257
a$ss_EAP
#> [,1]
#> [1,] 0.1557205
#> [2,] 0.2244812
#> [3,] 0.2262660
#> [4,] 0.1532767
#> [5,] 0.1638374
#> [6,] 0.1507844
#> [7,] 0.1952788
#> [8,] 0.1364254
#> [9,] 0.1975456
#> [10,] 0.1644454
#> [11,] 0.1298776
#> [12,] 0.2212982
#> [13,] 0.2286232
#> [14,] 0.1627503
#> [15,] 0.1541261
#> [16,] 0.2147110
#> [17,] 0.2043280
#> [18,] 0.1620837
#> [19,] 0.2023271
#> [20,] 0.1051622
#> [21,] 0.1243876
#> [22,] 0.1804976
#> [23,] 0.2746697
#> [24,] 0.1359099
#> [25,] 0.2426224
#> [26,] 0.1727554
#> [27,] 0.2772798
#> [28,] 0.2448241
#> [29,] 0.2045482
#> [30,] 0.1153920
#> [31,] 0.2095491
#> [32,] 0.2167588
#> [33,] 0.1888326
#> [34,] 0.2458929
#> [35,] 0.2068952
#> [36,] 0.1455357
#> [37,] 0.2163113
#> [38,] 0.1978453
#> [39,] 0.2248851
#> [40,] 0.1874084
#> [41,] 0.1766877
#> [42,] 0.1930233
#> [43,] 0.1351152
#> [44,] 0.1264922
#> [45,] 0.2971824
#> [46,] 0.1334946
#> [47,] 0.1585078
#> [48,] 0.1526695
#> [49,] 0.2295854
#> [50,] 0.2177479
head(a$ss_EAP)
#> [,1]
#> [1,] 0.1557205
#> [2,] 0.2244812
#> [3,] 0.2262660
#> [4,] 0.1532767
#> [5,] 0.1638374
#> [6,] 0.1507844(cor_thetas <- cor(thetas_true,a$thetas_EAP))
#> [,1]
#> [1,] 0.8165708
(cor_taus <- cor(taus_true,a$response_times_coefficients$taus_EAP))
#> [,1]
#> [1,] 0.9868757
(cor_ss <- cor(as.vector(itempars_true[,1]),a$ss_EAP))
#> [,1]
#> [1,] 0.5570496
(cor_gs <- cor(as.vector(itempars_true[,2]),a$gs_EAP))
#> [,1]
#> [1,] 0.526791
AAR_vec <- numeric(L)
for(t in 1:L){
AAR_vec[t] <- mean(Alphas[,,t]==a$Alphas_est[,,t])
}
AAR_vec
#> [1] 0.8842857 0.8978571 0.9171429 0.9328571 0.9335714
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.6142857 0.6685714 0.7257143 0.7714286 0.7885714a$DIC
#> Transition Response_Time Response Joint Total
#> D_bar 1644.209 132763.2 15429.68 3737.795 153574.9
#> D(theta_bar) 1430.446 132328.9 15053.73 3629.588 152442.7
#> DIC 1857.971 133197.4 15805.63 3846.002 154707.0
head(a$PPP_total_scores)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.96 0.36 0.54 0.92 0.58
#> [2,] 0.34 0.88 0.52 0.10 0.96
#> [3,] 1.00 0.84 0.70 0.80 0.54
#> [4,] 0.86 0.40 0.30 0.70 0.88
#> [5,] 0.88 0.82 1.00 0.90 0.84
#> [6,] 0.54 0.90 0.34 0.08 0.80
head(a$PPP_total_RTs)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.78 0.56 0.32 0.52 0.52
#> [2,] 0.38 0.18 0.18 0.96 0.86
#> [3,] 0.54 0.10 0.38 0.66 0.68
#> [4,] 0.58 0.54 0.46 0.56 0.40
#> [5,] 0.86 0.30 0.12 0.32 0.88
#> [6,] 0.40 0.76 0.70 0.56 0.50
head(a$PPP_item_means)
#> [1] 0.56 0.56 0.62 0.44 0.46 0.46
head(a$PPP_item_mean_RTs)
#> [1] 0.40 0.58 0.54 0.32 0.58 0.56
head(a$PPP_item_ORs)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
#> [1,] NA 0.46 0.94 0.96 0.86 0.98 0.58 0.50 0.90 0.48 0.22 0.84 0.82 0.92
#> [2,] NA NA 0.52 0.96 0.68 0.82 0.70 0.52 0.14 0.46 0.76 0.82 0.46 0.66
#> [3,] NA NA NA 0.94 0.98 0.90 1.00 0.76 0.90 0.96 0.08 0.80 0.94 0.88
#> [4,] NA NA NA NA 1.00 0.84 0.90 0.82 0.90 0.86 0.68 0.96 1.00 0.94
#> [5,] NA NA NA NA NA 0.90 0.74 0.56 0.92 0.62 0.74 0.94 0.86 0.80
#> [6,] NA NA NA NA NA NA 0.78 0.88 0.32 0.46 0.74 0.98 0.00 0.82
#> [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
#> [1,] 0.66 0.54 0.88 0.52 0.86 0.82 0.76 1.00 0.42 1.00 0.24 0.56
#> [2,] 0.58 0.94 0.52 0.78 0.94 0.28 0.58 0.22 0.82 0.62 0.32 0.60
#> [3,] 0.66 0.32 0.90 0.88 0.70 0.80 0.56 0.86 0.42 0.36 0.78 0.88
#> [4,] 0.98 0.52 0.94 0.92 0.86 0.98 0.72 0.94 0.94 0.72 1.00 0.66
#> [5,] 0.98 0.50 1.00 0.90 0.92 0.90 0.86 0.96 0.98 1.00 0.56 0.92
#> [6,] 0.80 0.90 0.92 0.92 0.94 0.78 0.30 0.60 0.72 0.44 0.28 0.14
#> [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37] [,38]
#> [1,] 0.92 0.10 0.84 0.70 0.42 0.40 0.32 0.68 0.56 0.22 0.64 0.46
#> [2,] 0.10 0.02 0.52 0.34 0.82 0.64 0.52 0.82 0.74 0.16 0.40 0.76
#> [3,] 1.00 0.50 0.64 0.88 0.96 0.96 0.68 0.92 0.56 0.20 0.54 0.72
#> [4,] 0.84 0.94 0.82 0.98 1.00 1.00 0.92 0.64 0.98 0.98 0.50 1.00
#> [5,] 0.74 0.22 0.70 1.00 0.86 0.56 0.54 0.64 0.36 1.00 0.76 0.90
#> [6,] 0.42 0.06 0.48 0.20 0.28 0.12 0.34 0.26 0.06 0.44 0.06 0.92
#> [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49] [,50]
#> [1,] 0.88 0.56 0.96 0.72 0.88 0.54 0.96 0.86 0.32 0.68 0.82 0.86
#> [2,] 0.84 0.66 0.94 0.72 0.60 0.64 0.96 0.60 0.68 0.86 0.90 0.78
#> [3,] 0.90 0.80 0.76 0.76 0.92 0.58 0.64 1.00 0.38 0.92 0.90 0.98
#> [4,] 0.78 0.98 0.84 0.78 0.94 0.96 0.94 1.00 0.86 0.90 0.92 0.68
#> [5,] 0.54 0.66 0.96 0.86 0.86 0.62 0.58 0.90 0.66 0.76 0.30 0.94
#> [6,] 0.36 0.02 0.44 0.48 0.44 0.92 0.88 0.88 0.38 0.92 0.76 0.64