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
#> 28 93 136 75 18
Smats <- matrix(runif(J*K,.1,.3),c(J,K))
Gmats <- matrix(runif(J*K,.1,.3),c(J,K))
# Simulate rRUM parameters
r_stars <- Gmats / (1-Smats)
pi_stars <- apply((1-Smats)^Q_matrix, 1, prod)
Y_sim <- sim_hmcdm(model="rRUM",Alphas,Q_matrix,Design_array,
r_stars=r_stars,pi_stars=pi_stars)
output_rRUM_indept = hmcdm(Y_sim,Q_matrix,"rRUM_indept",Design_array,
100,30,R = R)
#> 0
output_rRUM_indept
#>
#> Model: rRUM_indept
#>
#> Sample Size: 350
#> Number of Items:
#> Number of Time Points:
#>
#> Chain Length: 100, burn-in: 50
summary(output_rRUM_indept)
#>
#> Model: rRUM_indept
#>
#> Item Parameters:
#> r_stars1_EAP r_stars2_EAP r_stars3_EAP r_stars4_EAP pi_stars_EAP
#> 0.4773 0.52614 0.5253 0.6395 0.7350
#> 0.6053 0.35360 0.5723 0.5711 0.7642
#> 0.5889 0.67949 0.6601 0.3858 0.7011
#> 0.5993 0.69182 0.2371 0.5625 0.7485
#> 0.4741 0.04227 0.5137 0.5988 0.6526
#> ... 45 more items
#>
#> Transition Parameters:
#> taus_EAP
#> τ1 0.4225
#> τ2 0.4943
#> τ3 0.4618
#> τ4 0.3278
#>
#> Class Probabilities:
#> pis_EAP
#> 0000 0.09113
#> 0001 0.05084
#> 0010 0.03600
#> 0011 0.06357
#> 0100 0.06196
#> ... 11 more classes
#>
#> Deviance Information Criterion (DIC): 23687.93
#>
#> Posterior Predictive P-value (PPP):
#> M1: 0.4988
#> M2: 0.49
#> total scores: 0.6081
a <- summary(output_rRUM_indept)
head(a$r_stars_EAP)
#> [,1] [,2] [,3] [,4]
#> [1,] 0.4773087 0.52614404 0.5253129 0.6395075
#> [2,] 0.6053046 0.35359546 0.5723301 0.5710974
#> [3,] 0.5888621 0.67949331 0.6600833 0.3858473
#> [4,] 0.5993120 0.69181567 0.2371137 0.5625196
#> [5,] 0.4740937 0.04227164 0.5137391 0.5988094
#> [6,] 0.5273991 0.37205285 0.2451295 0.6669386
(cor_pistars <- cor(as.vector(pi_stars),as.vector(a$pi_stars_EAP)))
#> [1] 0.9538903
(cor_rstars <- cor(as.vector(r_stars*Q_matrix),as.vector(a$r_stars_EAP*Q_matrix)))
#> [1] 0.9330186
AAR_vec <- numeric(L)
for(t in 1:L){
AAR_vec[t] <- mean(Alphas[,,t]==a$Alphas_est[,,t])
}
AAR_vec
#> [1] 0.8292857 0.8964286 0.9250000 0.9421429 0.9564286
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.5028571 0.6457143 0.7485714 0.7971429 0.8342857
a$DIC
#> Transition Response_Time Response Joint Total
#> D_bar 2220.138 NA 18800.54 1856.781 22877.46
#> D(theta_bar) 2151.948 NA 18067.53 1847.506 22066.98
#> DIC 2288.328 NA 19533.55 1866.057 23687.93
head(a$PPP_total_scores)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.00 0.04 0.02 0.02 0.00
#> [2,] 0.08 0.80 0.36 0.90 0.62
#> [3,] 0.38 0.78 0.18 0.56 0.36
#> [4,] 0.44 0.42 0.80 0.98 0.24
#> [5,] 0.58 0.98 0.58 0.94 0.96
#> [6,] 0.46 0.98 0.62 0.78 1.00
head(a$PPP_item_means)
#> [1] 0.50 0.48 0.52 0.52 0.48 0.48
head(a$PPP_item_ORs)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
#> [1,] NA 0.18 0.36 0.12 0.16 0.52 0.92 0.92 0.88 0.44 0.76 0.80 0.98 0.40
#> [2,] NA NA 0.54 0.86 0.50 0.48 0.38 0.48 0.30 0.14 0.86 0.52 0.20 0.12
#> [3,] NA NA NA 0.90 0.50 0.10 0.24 0.60 0.22 0.62 0.20 0.36 0.74 0.96
#> [4,] NA NA NA NA 0.96 0.46 0.70 0.94 0.62 0.32 0.02 0.22 0.88 0.96
#> [5,] NA NA NA NA NA 0.72 0.28 0.40 0.36 0.28 0.38 0.72 0.40 0.06
#> [6,] NA NA NA NA NA NA 0.66 0.70 0.22 0.96 0.56 0.44 0.08 0.72
#> [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
#> [1,] 0.16 0.94 0.90 0.52 0.06 0.76 0.84 0.46 0.64 0.90 0.20 0.26
#> [2,] 0.92 0.38 0.36 0.94 0.36 0.44 0.76 0.40 0.52 0.40 0.36 0.58
#> [3,] 0.06 0.26 0.34 0.54 0.48 0.84 0.66 0.98 0.06 0.54 0.28 0.58
#> [4,] 0.14 0.30 0.36 0.76 0.52 0.84 0.10 0.52 0.82 0.42 0.30 0.28
#> [5,] 0.46 0.92 0.82 0.80 0.24 0.84 0.90 0.90 0.32 0.16 0.28 0.54
#> [6,] 0.00 0.66 0.16 0.24 0.72 0.82 0.14 0.26 0.16 0.76 0.08 0.46
#> [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37] [,38]
#> [1,] 0.20 0.56 0.72 0.02 0.58 0.72 0.26 0.50 0.68 0.22 0.12 0.80
#> [2,] 0.08 0.64 0.44 0.76 0.38 0.22 0.24 0.44 0.04 0.84 0.16 0.18
#> [3,] 0.36 0.92 0.94 0.76 0.70 0.74 0.46 0.86 0.68 0.08 0.84 0.44
#> [4,] 0.38 0.54 0.98 0.10 0.38 0.52 0.42 0.80 0.92 0.66 0.78 0.36
#> [5,] 0.42 0.94 0.40 0.88 0.36 0.60 0.34 0.28 0.86 0.74 0.90 0.52
#> [6,] 0.90 0.98 0.32 0.66 0.70 0.54 0.62 0.98 0.92 0.78 0.52 0.88
#> [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49] [,50]
#> [1,] 0.32 0.52 0.48 0.76 0.50 0.84 0.60 0.40 0.30 0.88 0.60 0.76
#> [2,] 0.08 0.26 0.22 0.08 0.38 0.14 0.98 0.00 0.40 0.24 0.66 0.44
#> [3,] 0.96 0.96 0.50 0.10 1.00 0.54 0.92 0.68 0.50 0.36 0.92 0.30
#> [4,] 0.54 0.22 0.52 0.20 0.24 0.58 0.88 0.24 0.88 0.40 0.96 0.34
#> [5,] 0.24 0.26 0.02 0.16 0.24 0.16 0.22 0.26 0.20 0.22 0.54 0.06
#> [6,] 0.22 0.08 0.70 0.94 0.80 0.88 0.08 0.50 0.58 0.88 0.42 0.48