Movatterモバイル変換


[0]ホーム

URL:


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_FOHMmodel

TP<-TPmat(K)Omega_true<-rOmega(TP)class_0<-sample(1:2^K, N,replace = L)Alphas_0<-matrix(0,N,K)for(iin1: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 posteriordistribution

output_FOHM=hmcdm(Y_sim,Q_matrix,"DINA_FOHM",Design_array,100,30)#> 0output_FOHM#>#> Model: DINA_FOHM#>#> Sample Size: 350#> Number of Items:#> Number of Time Points:#>#> Chain Length: 100, burn-in: 50summary(output_FOHM)#>#> Model: DINA_FOHM#>#> Item Parameters:#>  ss_EAP gs_EAP#>  0.2268 0.1448#>  0.1936 0.1967#>  0.1645 0.2347#>  0.1487 0.2092#>  0.1489 0.1085#>    ... 45 more items#>#> Transition Parameters:#>  [1] 0.02241 0.03004 0.03006 0.02264 0.02932 0.02900 0.05417 0.06629 0.12017#> [10] 0.17819 0.15945 0.02662 0.06635 0.10660 0.02111 0.03757#>    ... 15 more rows#>#> Class Probabilities:#>      pis_EAP#> 0000  0.1670#> 0001  0.2611#> 0010  0.1588#> 0011  0.2025#> 0100  0.1458#>    ... 11 more classes#>#> Deviance Information Criterion (DIC): 18365.61#>#> Posterior Predictive P-value (PPP):#> M1: 0.5084#> M2:  0.49#> total scores:  0.6293a<-summary(output_FOHM)head(a$ss_EAP)#>           [,1]#> [1,] 0.2268467#> [2,] 0.1936234#> [3,] 0.1644741#> [4,] 0.1487108#> [5,] 0.1488766#> [6,] 0.1347755

(3) Check for parameter estimation accuracy

AAR_vec<-numeric(L)for(tin1:L){  AAR_vec[t]<-mean(Alphas[,,t]==a$Alphas_est[,,t])}AAR_vec#> [1] 0.9450000 0.9450000 0.9685714 0.9850000 0.9878571PAR_vec<-numeric(L)for(tin1:L){  PAR_vec[t]<-mean(rowSums((Alphas[,,t]-a$Alphas_est[,,t])^2)==0)}PAR_vec#> [1] 0.7971429 0.8228571 0.8885714 0.9485714 0.9514286

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

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

[8]ページ先頭

©2009-2025 Movatter.jp