tau <- numeric(K)
for(k in 1:K){
tau[k] <- runif(1,.2,.6)
}
R = matrix(0,K,K)
# Initial alphas
p_mastery <- c(.5,.5,.4,.4)
Alphas_0 <- matrix(0,N,K)
for(i in 1:N){
for(k in 1:K){
prereqs <- which(R[k,]==1)
if(length(prereqs)==0){
Alphas_0[i,k] <- rbinom(1,1,p_mastery[k])
}
if(length(prereqs)>0){
Alphas_0[i,k] <- prod(Alphas_0[i,prereqs])*rbinom(1,1,p_mastery)
}
}
}
Alphas <- sim_alphas(model="indept",taus=tau,N=N,L=L,R=R,alpha0=Alphas_0)
table(rowSums(Alphas[,,5]) - rowSums(Alphas[,,1])) # used to see how much transition has taken place
#>
#> 0 1 2 3 4
#> 25 87 134 85 19
Svec <- runif(K,.1,.3)
Gvec <- runif(K,.1,.3)
Y_sim <- sim_hmcdm(model="NIDA",Alphas,Q_matrix,Design_array,
Svec=Svec,Gvec=Gvec)
output_NIDA_indept = hmcdm(Y_sim, Q_matrix, "NIDA_indept", Design_array,
100, 30, R = R)
#> 0
output_NIDA_indept
#>
#> Model: NIDA_indept
#>
#> Sample Size: 350
#> Number of Items:
#> Number of Time Points:
#>
#> Chain Length: 100, burn-in: 50
summary(output_NIDA_indept)
#>
#> Model: NIDA_indept
#>
#> Item Parameters:
#> ss_EAP gs_EAP
#> 0.1179 0.1536
#> 0.1055 0.1847
#> 0.2685 0.2227
#> 0.1978 0.2309
#>
#> Transition Parameters:
#> taus_EAP
#> τ1 0.4406
#> τ2 0.4746
#> τ3 0.4706
#> τ4 0.4106
#>
#> Class Probabilities:
#> pis_EAP
#> 0000 0.060862
#> 0001 0.027853
#> 0010 0.057665
#> 0011 0.006243
#> 0100 0.121910
#> ... 11 more classes
#>
#> Deviance Information Criterion (DIC): 21311.64
#>
#> Posterior Predictive P-value (PPP):
#> M1: 0.4756
#> M2: 0.49
#> total scores: 0.6103
a <- summary(output_NIDA_indept)
head(a$ss_EAP)
#> [,1]
#> [1,] 0.1178531
#> [2,] 0.1055205
#> [3,] 0.2685189
#> [4,] 0.1977739
AAR_vec <- numeric(L)
for(t in 1:L){
AAR_vec[t] <- mean(Alphas[,,t]==a$Alphas_est[,,t])
}
AAR_vec
#> [1] 0.8678571 0.9085714 0.9407143 0.9621429 0.9742857
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.5742857 0.6857143 0.7828571 0.8600000 0.9057143
a$DIC
#> Transition Response_Time Response Joint Total
#> D_bar 2066.194 NA 16754.42 1846.428 20667.04
#> D(theta_bar) 2000.635 NA 16183.89 1837.928 20022.45
#> DIC 2131.753 NA 17324.96 1854.928 21311.64
head(a$PPP_total_scores)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.12 0.34 0.56 0.14 0.00
#> [2,] 0.64 0.54 0.08 0.26 0.18
#> [3,] 0.92 0.20 0.48 0.10 0.88
#> [4,] 0.18 0.78 0.34 0.60 1.00
#> [5,] 0.68 0.88 0.30 0.86 0.70
#> [6,] 0.32 0.10 0.06 1.00 0.08
head(a$PPP_item_means)
#> [1] 0.76 0.46 0.32 0.48 0.22 0.74
head(a$PPP_item_ORs)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
#> [1,] NA 0.62 0.38 0.24 0.60 0.06 0.30 0.78 0.28 0.12 0.54 0.24 0.80 0.72
#> [2,] NA NA 0.56 0.64 0.70 0.82 0.14 0.74 0.94 0.82 0.66 0.32 0.38 0.74
#> [3,] NA NA NA 0.44 0.78 0.48 0.00 0.18 0.96 0.42 0.58 0.36 0.20 0.34
#> [4,] NA NA NA NA 0.22 0.38 0.30 0.12 0.38 0.82 0.32 0.20 0.60 0.88
#> [5,] NA NA NA NA NA 0.54 0.02 0.92 0.82 0.44 0.24 0.08 0.86 0.68
#> [6,] NA NA NA NA NA NA 0.48 0.24 0.42 0.16 0.22 0.54 0.16 0.26
#> [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
#> [1,] 0.70 0.36 0.58 0.72 0.66 0.28 0.00 0.64 0.44 0.82 0.82 0.74
#> [2,] 0.46 0.16 0.38 0.44 0.62 0.20 0.28 0.42 0.16 0.28 0.12 0.14
#> [3,] 0.58 0.52 0.22 0.24 0.34 0.00 0.68 0.08 0.40 0.00 0.06 0.16
#> [4,] 0.30 0.36 0.58 0.42 0.40 0.94 0.86 0.54 0.38 0.78 0.82 0.42
#> [5,] 0.80 0.82 0.58 0.64 0.68 0.26 0.72 0.74 0.40 0.46 0.22 0.68
#> [6,] 0.80 0.14 0.38 0.20 0.20 0.54 0.46 0.74 0.00 0.28 0.00 0.60
#> [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37] [,38]
#> [1,] 0.60 0.94 0.26 0.88 0.74 0.92 0.16 0.34 0.54 0.92 0.68 0.86
#> [2,] 0.02 0.38 0.38 0.36 0.40 0.60 0.72 0.04 0.48 0.08 0.40 0.32
#> [3,] 0.06 0.26 0.60 0.06 0.40 0.72 1.00 0.26 0.20 0.92 0.10 0.54
#> [4,] 0.16 0.58 0.10 0.74 0.58 0.08 0.96 0.50 0.62 0.46 0.56 0.70
#> [5,] 0.14 0.58 0.76 0.40 0.38 0.66 0.30 0.24 0.08 0.88 0.62 0.48
#> [6,] 0.06 0.70 0.74 0.08 0.64 0.10 0.08 0.24 0.78 0.60 0.46 0.98
#> [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49] [,50]
#> [1,] 0.54 0.68 0.96 0.14 0.52 0.06 0.06 0.26 0.70 0.16 0.12 0.50
#> [2,] 0.66 0.18 0.48 0.90 0.26 0.62 0.96 0.32 1.00 0.16 0.46 0.56
#> [3,] 0.12 0.52 0.68 0.12 0.60 0.02 0.48 0.02 0.44 0.12 0.18 0.70
#> [4,] 0.60 0.20 0.68 0.46 0.56 0.50 0.10 0.52 0.40 0.52 0.96 0.78
#> [5,] 0.42 0.34 0.98 0.64 0.08 0.10 0.38 0.06 0.44 0.16 0.22 0.84
#> [6,] 0.50 0.06 0.26 0.22 0.18 0.38 0.46 0.76 0.42 0.44 0.98 0.78