BookmarkSubscribeRSS Feed
chichingmui
Calcite | Level 5

I'm experimenting with proc mcmc in SAS EG to build  ERS and MRS for MNRM(multidimensional nominal response model).

I've referenced the following paper:Using SAS PROC MCMC for Item Response Theory Models Using SAS PROC MCMC for Item Response Theory Models - PMC (nih.gov)

 

My code is below:
 
proc mcmc data=est1 outpost =est_eem_mnrm_postgr seed = 23 nbi=5000
nmc=20000 diagnostics=all plots = all nthreads=-1 DIC;
array theta[3];
array c[10,5] c1_1-c1_5
c2_1-c2_5
c3_1-c3_5
c4_1-c4_5
c5_1-c5_5
c6_1-c6_5
c7_1-c7_5
c8_1-c8_5
c9_1-c9_5
c10_1-c10_5;
array i[990];
array z[5];
array p[5];
parms c1_2-c1_5 0;
parms c2_2-c2_5 0;
parms c3_2-c3_5 0;
parms c4_2-c4_5 0;
parms c5_2-c5_5 0;
parms c6_2-c6_5 0;
parms c7_2-c7_5 0;
parms c8_2-c8_5 0;
parms c9_2-c9_5 0;
parms c10_2-c10_5 0;
 
 
c1_1 = -(c1_2+c1_3+c1_4+c1_5);
c2_1 = -(c2_2+c2_3+c2_4+c2_5);
c3_1 = -(c3_2+c3_3+c3_4+c3_5);
c4_1 = -(c4_2+c4_3+c4_4+c4_5);
c5_1 = -(c5_2+c5_3+c5_4+c5_5);
c6_1 = -(c6_2+c6_3+c6_4+c6_5);
c7_1 = -(c7_2+c7_3+c7_4+c7_5);
c8_1 = -(c8_2+c8_3+c8_4+c8_5);
c9_1 = -(c9_2+c9_3+c9_4+c9_5);
c10_1 = -(c10_2+c10_3+c10_4+c10_5);
 
prior c1_2-c1_5 c2_2-c2_5 c3_2-c3_5 c4_2-c4_5 c5_2-c5_5
c6_2-c6_5 c7_2-c7_5 c8_2-c8_5 c9_2-c9_5 c10_2-c10_5
~normal(0, var=25);
random theta1~normal(0,var=1) subject=_obs_;
random theta2~normal(0,var=1) subject=_obs_;
random theta3~normal(0,var=1) subject=_obs_;
llike=0;
do m = 1 to 990;
    i[m] = m;
do j = 1 to 10;
z[1] =exp((-2)*theta[1]+(1)*theta[2]+(-0.25)*theta[3]+c[j,1]);
z[2] =exp((-1)*theta[1]+(-0.67)*theta[2]+(-0.25)*theta[3]+c[j,2]);
z[3] =exp((0)*theta[1]+(-0.67)*theta[2]+(1)*theta[3]+c[j,3]);
z[4] =exp((1)*theta[1]+(-0.67)*theta[2]+(-0.25)*theta[3]+c[j,4]);
            z[5] =exp((2)*theta[1]+(1)*theta[2]+(-0.25)*theta[3]+c[j,5]);
do k = 1 to 5;
p[k] = z[k]/(z1+z2+z3+z4+z5);
end;
llike = llike+log(p[i[j]]);
end;
model general(llike);
run;
 
Running the above code yields:
ERROR: The log-likelihood value is invalid.
 
How can I slove this problem?
Many thanks!
chichingmui
2 REPLIES 2
sbxkoenk
SAS Super FREQ

Hello,

 

It might have something to do with missing values.

Try using INITIAL= option in MODEL statement of PROC MCMC.

 

SAS/STAT 15.3 User's Guide
The MCMC Procedure
MODEL Statement
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_mcmc_syntax09.htm

 

Also possible (didn't check your code very well).
Prior distribution for sigma (variance) is specified as normal.
In this case, it might be possible to have negative variance, which results in problem for calculating log-likelihood.
Modify into other prior distribution, which has range above zero.

 

BR, Koen

Rick_SAS
SAS Super FREQ

It's always a good idea to show the error in the log.

I don't see the variables z1-z5 in the program, although they could be in the input data set. Should the equation for p[k] be

p[k] = z[k]/(z[1]+z[2]+z[3]+z[4]+z[5]);

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 649 views
  • 0 likes
  • 3 in conversation