The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

DINA_FOHM

library(hmcdm)

Load the spatial rotation data

N = length(Test_versions)
J = nrow(Q_matrix)
K = ncol(Q_matrix)
L = nrow(Test_order)
Jt = J/L

(1) Simulate responses and response times based on the DINA_FOHM model

TP <- TPmat(K)
Omega_true <- rOmega(TP)
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))
}
Alphas <- sim_alphas(model="FOHM", Omega = Omega_true, N=N, L=L)
itempars_true <- matrix(runif(J*2,.1,.2), ncol=2)

Y_sim <- sim_hmcdm(model="DINA",Alphas,Q_matrix,Design_array,
                   itempars=itempars_true)

(2) Run the MCMC to sample parameters from the posterior distribution

output_FOHM = hmcdm(Y_sim,Q_matrix,"DINA_FOHM",Design_array,100,30)
#> 0
output_FOHM
#> 
#> Model: DINA_FOHM 
#> 
#> Sample Size: 350
#> Number of Items: 
#> Number of Time Points: 
#> 
#> Chain Length: 100, burn-in: 50
summary(output_FOHM)
#> 
#> Model: DINA_FOHM 
#> 
#> Item Parameters:
#>  ss_EAP gs_EAP
#>  0.1608 0.1285
#>  0.1918 0.2048
#>  0.1378 0.2567
#>  0.2098 0.2158
#>  0.1816 0.1293
#>    ... 45 more items
#> 
#> Transition Parameters:
#>  [1] 0.02909 0.04587 0.03618 0.04830 0.15715 0.03313 0.05721 0.02544 0.03755
#> [10] 0.06410 0.06371 0.03695 0.04014 0.05010 0.25844 0.01663
#>    ... 15 more rows
#> 
#> Class Probabilities:
#>      pis_EAP
#> 0000  0.1944
#> 0001  0.1329
#> 0010  0.2160
#> 0011  0.2464
#> 0100  0.1279
#>    ... 11 more classes
#> 
#> Deviance Information Criterion (DIC): 18901.53 
#> 
#> Posterior Predictive P-value (PPP):
#> M1: 0.5036
#> M2:  0.49
#> total scores:  0.6264
a <- summary(output_FOHM)
head(a$ss_EAP)
#>           [,1]
#> [1,] 0.1608014
#> [2,] 0.1918233
#> [3,] 0.1378178
#> [4,] 0.2097728
#> [5,] 0.1816050
#> [6,] 0.2081184

(3) Check for parameter estimation accuracy

AAR_vec <- numeric(L)
for(t in 1:L){
  AAR_vec[t] <- mean(Alphas[,,t]==a$Alphas_est[,,t])
}
AAR_vec
#> [1] 0.9250000 0.9371429 0.9728571 0.9878571 0.9921429

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.7342857 0.7800000 0.8971429 0.9514286 0.9685714

(4) Evaluate the fit of the model to the observed response

a$DIC
#>              Transition Response_Time Response    Joint    Total
#> D_bar          2089.519            NA 14968.72 1259.491 18317.73
#> D(theta_bar)   2041.764            NA 14487.14 1205.031 17733.93
#> DIC            2137.274            NA 15450.31 1313.952 18901.53
head(a$PPP_total_scores)
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.26 0.72 0.26 0.70 0.92
#> [2,] 0.92 0.98 0.86 0.04 0.94
#> [3,] 0.56 0.86 0.08 1.00 0.28
#> [4,] 0.82 0.60 0.92 0.60 0.76
#> [5,] 0.54 0.48 0.38 0.54 0.70
#> [6,] 0.62 0.04 0.72 0.62 0.94
head(a$PPP_item_means)
#> [1] 0.52 0.40 0.50 0.44 0.40 0.52
head(a$PPP_item_ORs)
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
#> [1,]   NA 0.24 0.74 0.82 0.48 0.66 0.76 0.78 0.74  0.82  0.50  0.66  0.26  0.34
#> [2,]   NA   NA 0.26 0.42 0.44 0.50 0.62 0.30 0.24  0.32  1.00  0.24  0.22  0.96
#> [3,]   NA   NA   NA 0.98 0.46 0.84 0.24 0.36 0.30  0.64  0.96  0.58  0.56  0.66
#> [4,]   NA   NA   NA   NA 0.68 0.44 0.54 0.96 0.66  0.70  1.00  0.20  0.94  0.94
#> [5,]   NA   NA   NA   NA   NA 0.78 0.58 0.12 0.60  0.62  0.54  0.80  0.24  0.86
#> [6,]   NA   NA   NA   NA   NA   NA 0.30 0.84 0.34  0.34  0.92  0.80  0.40  1.00
#>      [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
#> [1,]  0.56  0.10  0.62  0.98  0.50  0.48  0.58  0.24  0.48  0.64  0.62  0.84
#> [2,]  0.94  0.54  0.60  0.44  0.94  0.86  0.80  0.02  0.50  0.78  0.58  0.80
#> [3,]  0.68  0.78  0.50  0.64  0.72  0.96  0.26  0.14  0.88  0.60  0.90  0.12
#> [4,]  0.64  0.86  0.12  0.68  0.18  1.00  0.62  0.04  0.78  0.54  0.74  0.12
#> [5,]  0.60  0.44  0.20  0.66  0.82  0.70  0.16  0.10  0.40  0.62  0.34  0.10
#> [6,]  0.78  0.50  0.48  0.72  0.68  0.96  0.78  0.08  0.12  1.00  0.16  0.54
#>      [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37] [,38]
#> [1,]  0.76  0.14  0.56  0.58  0.54  0.16  0.38  0.54  0.76  0.80  0.52  0.64
#> [2,]  0.26  0.60  0.38  0.32  0.78  0.00  0.00  0.36  0.80  0.58  0.06  0.24
#> [3,]  0.02  0.40  0.28  1.00  0.70  0.16  0.24  0.64  0.58  0.42  0.18  0.34
#> [4,]  0.86  0.22  0.48  0.72  0.68  0.20  0.12  0.04  0.70  0.22  0.16  0.06
#> [5,]  0.34  0.82  0.90  0.68  0.80  0.08  0.38  0.52  0.90  0.58  0.94  0.62
#> [6,]  0.00  0.62  0.96  0.16  0.62  0.04  0.06  0.08  0.98  0.40  0.10  0.46
#>      [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49] [,50]
#> [1,]  1.00  0.32  0.32  0.68  0.82  0.86  0.74  0.64  0.72  1.00  0.90  0.94
#> [2,]  0.50  0.22  0.62  0.60  0.38  0.38  0.20  0.12  0.64  0.70  0.84  0.62
#> [3,]  0.62  0.56  0.54  0.46  0.54  0.60  0.90  0.22  0.66  0.58  0.80  0.36
#> [4,]  0.98  0.32  0.56  0.58  0.22  0.28  1.00  0.56  0.74  0.34  0.64  0.28
#> [5,]  0.72  0.22  0.04  0.46  0.42  0.08  0.24  0.56  0.82  0.28  0.66  0.32
#> [6,]  0.68  0.34  0.20  0.62  0.80  0.66  0.50  0.62  0.54  0.24  0.74  0.24

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.