class_0 <- sample(1:2^K, N, replace = L)
Alphas_0 <- matrix(0,N,K)
for(i in 1:N){
Alphas_0[i,] <- inv_bijectionvector(K,(class_0[i]-1))
}
thetas_true = rnorm(N,0,1)
tausd_true=0.5
taus_true = rnorm(N,0,tausd_true)
G_version = 3
phi_true = 0.8
lambdas_true <- c(-2, 1.6, .4, .055) # empirical from Wang 2017
Alphas <- sim_alphas(model="HO_sep",
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
#> 55 53 76 128 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_sep = hmcdm(Y_sim,Q_matrix,"DINA_HO_RT_sep",Design_array,
100, 30,
Latency_array = L_sim, G_version = G_version,
theta_propose = 2,deltas_propose = c(.45,.35,.25,.06))
#> 0
output_HMDCM_RT_sep
#>
#> Model: DINA_HO_RT_sep
#>
#> Sample Size: 350
#> Number of Items:
#> Number of Time Points:
#>
#> Chain Length: 100, burn-in: 50
summary(output_HMDCM_RT_sep)
#>
#> Model: DINA_HO_RT_sep
#>
#> Item Parameters:
#> ss_EAP gs_EAP
#> 0.1293 0.10014
#> 0.1517 0.08696
#> 0.1517 0.08739
#> 0.1509 0.13448
#> 0.1117 0.21191
#> ... 45 more items
#>
#> Transition Parameters:
#> lambdas_EAP
#> λ0 -1.64544
#> λ1 1.44791
#> λ2 0.20665
#> λ3 0.06816
#>
#> Class Probabilities:
#> pis_EAP
#> 0000 0.2104
#> 0001 0.1515
#> 0010 0.2122
#> 0011 0.1759
#> 0100 0.1877
#> ... 11 more classes
#>
#> Deviance Information Criterion (DIC): 154179.4
#>
#> Posterior Predictive P-value (PPP):
#> M1: 0.5284
#> M2: 0.49
#> total scores: 0.63
a <- summary(output_HMDCM_RT_sep)
head(a$ss_EAP)
#> [,1]
#> [1,] 0.1293485
#> [2,] 0.1516944
#> [3,] 0.1517333
#> [4,] 0.1508772
#> [5,] 0.1116532
#> [6,] 0.1619892(cor_thetas <- cor(thetas_true,a$thetas_EAP))
#> [,1]
#> [1,] 0.7868931
(cor_taus <- cor(taus_true,a$response_times_coefficients$taus_EAP))
#> [,1]
#> [1,] 0.9888166
(cor_ss <- cor(as.vector(itempars_true[,1]),a$ss_EAP))
#> [,1]
#> [1,] 0.5887397
(cor_gs <- cor(as.vector(itempars_true[,2]),a$gs_EAP))
#> [,1]
#> [1,] 0.7653382
AAR_vec <- numeric(L)
for(t in 1:L){
AAR_vec[t] <- mean(Alphas[,,t]==a$Alphas_est[,,t])
}
AAR_vec
#> [1] 0.9478571 0.9421429 0.9514286 0.9678571 0.9714286
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.8228571 0.7914286 0.8200000 0.8771429 0.8942857a$DIC
#> Transition Response_Time Response Joint Total
#> D_bar 2533.065 133266.1 14644.06 2992.048 153435.3
#> D(theta_bar) 2292.028 132832.2 14614.72 2952.148 152691.1
#> DIC 2774.102 133700.0 14673.41 3031.948 154179.4
head(a$PPP_total_scores)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.76 0.78 0.52 0.68 0.34
#> [2,] 0.20 0.60 0.80 0.12 0.76
#> [3,] 0.24 0.42 0.90 0.76 0.90
#> [4,] 0.50 0.76 1.00 1.00 0.22
#> [5,] 0.32 0.52 0.82 0.18 0.82
#> [6,] 0.48 0.64 0.18 0.92 0.42
head(a$PPP_item_means)
#> [1] 0.48 0.46 0.62 0.52 0.62 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.60 0.38 0.34 0.32 0.32 0.58 0.32 0.70 0.74 0.28 0.40 0.90
#> [2,] NA NA 0.82 0.52 0.32 0.74 0.56 0.66 0.88 0.60 0.28 0.08 0.78 0.34
#> [3,] NA NA NA 0.10 0.58 0.72 0.82 0.86 0.34 0.92 0.28 0.54 0.38 0.82
#> [4,] NA NA NA NA 0.46 0.52 0.30 0.94 0.82 0.64 0.84 0.26 0.30 0.54
#> [5,] NA NA NA NA NA 0.80 0.34 0.82 0.42 0.86 0.52 0.22 0.24 0.32
#> [6,] NA NA NA NA NA NA 0.50 0.78 0.70 0.60 0.72 0.26 0.66 0.56
#> [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
#> [1,] 0.12 0.50 0.08 0.22 1.00 0.16 0.86 0.32 0.86 0.26 0.14 0.42
#> [2,] 0.52 0.70 0.64 0.68 0.92 0.70 0.94 0.24 0.86 0.34 0.88 0.54
#> [3,] 0.36 0.64 0.78 0.04 0.62 0.54 0.94 0.74 0.78 0.78 0.42 0.86
#> [4,] 0.58 0.98 0.04 0.94 0.68 0.22 0.28 0.14 0.50 0.48 0.16 0.38
#> [5,] 0.14 0.26 0.46 0.26 0.72 0.58 0.24 0.06 0.82 0.16 0.82 0.02
#> [6,] 0.86 0.80 0.22 0.76 1.00 0.72 0.94 0.50 0.90 0.64 0.44 0.90
#> [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37] [,38]
#> [1,] 0.12 0.44 0.36 0.92 0.30 0.78 0.68 0.58 0.94 0.42 0.62 0.34
#> [2,] 0.72 0.72 0.10 0.34 0.26 0.48 0.84 0.10 0.94 0.82 1.00 0.46
#> [3,] 0.68 0.84 0.66 1.00 0.68 0.64 0.24 0.38 0.96 0.70 0.92 0.64
#> [4,] 0.24 0.20 0.00 0.42 0.12 0.20 0.30 0.42 0.90 0.44 1.00 0.20
#> [5,] 0.40 0.90 0.06 0.50 0.12 0.54 0.92 0.38 0.90 0.88 0.74 0.68
#> [6,] 0.94 0.84 0.38 0.82 0.90 0.84 0.90 0.70 0.86 0.72 1.00 0.56
#> [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49] [,50]
#> [1,] 0.70 0.04 0.52 0.52 0.74 1.00 0.16 0.88 0.46 0.88 1.00 0.76
#> [2,] 0.44 0.90 0.72 0.60 0.68 1.00 0.40 0.78 0.50 0.84 0.76 0.66
#> [3,] 0.38 0.42 0.88 0.58 0.70 0.96 0.26 0.94 0.70 0.44 0.96 0.66
#> [4,] 0.08 0.28 0.20 0.54 0.88 0.40 0.00 0.30 0.90 0.02 0.04 0.72
#> [5,] 0.68 0.18 0.34 0.00 0.48 0.20 0.30 0.70 0.06 0.34 0.64 0.24
#> [6,] 0.68 0.96 0.94 0.52 0.70 0.96 0.92 0.38 0.88 0.42 0.38 0.70
library(bayesplot)
#> This is bayesplot version 1.15.0
#> - Online documentation and vignettes at mc-stan.org/bayesplot
#> - bayesplot theme set to bayesplot::theme_default()
#> * Does _not_ affect other ggplot2 plots
#> * See ?bayesplot_theme_set for details on theme setting
pp_check(output_HMDCM_RT_sep, type="total_latency")