Programming the statistical procedures from SAS

PROC MCMC Warning

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

PROC MCMC Warning

 

PROC MCMC is giving  "WARNING: Use the RAND function with caution. The function should not be used in constructing the likelihood function or modifying model-related symbols in the program. This typically would lead to incorrect posterior inferences."

 

Is it a general warning or is something wrong which we have to check ?

Any guidance on this will be greatly appreciated.

 

Thanks in advance

 

 


Accepted Solutions
Solution
‎04-12-2018 05:12 AM
SAS Super FREQ
Posts: 4,245

Re: PROC MCMC Warning

If you are using the RAND statement as part of the construction of the likelihood function, then that is not acceptable. The likelihood function must be a function of the parameters, given the data. As Ballardw said, post your code and we might be able to offer more concrete suggestions. (For example, if you are trying to incorporate random effects, we can tell you to use the RANDOM statement, not the RAND function.)

View solution in original post


All Replies
Super User
Posts: 13,583

Re: PROC MCMC Warning

It never hurts to post the code in question. It will avoid getting suggestions / comments involving options you already used or didn't use and may provide additional information.

 

 

I might suggest running the proc with the same input data (possibly a small set) repeatedly and see if you get the same results each time. If not you have an example of why it may not be a good idea.

Solution
‎04-12-2018 05:12 AM
SAS Super FREQ
Posts: 4,245

Re: PROC MCMC Warning

If you are using the RAND statement as part of the construction of the likelihood function, then that is not acceptable. The likelihood function must be a function of the parameters, given the data. As Ballardw said, post your code and we might be able to offer more concrete suggestions. (For example, if you are trying to incorporate random effects, we can tell you to use the RANDOM statement, not the RAND function.)

New Contributor
Posts: 3

Re: PROC MCMC Warning

Thanks for the support offered

 

Please find the code,

 

ods graphics on;
proc mcmc data=input nmc=&nmc nbi=&nbi monitor=(_parms_ resn_pred_act resn_pred_ctrl resn_eos_act resn_eos_ctrl diff) diagnostics=(mcse autocorr ess)
               statistics=(summary intervals) stats(alpha=0.20) outpost=pred;
/*** Set up the constants for the beta distributions (a and b) ***/
    begincnst;
        a_act=1;
     b_act=1;
     a_ctrl=1;
     b_ctrl=1;
    endcnst;

/*** Priors: distributions and initial values ***/
    prior theta_act ~ beta(a_act,b_act);
    prior theta_ctrl ~ beta(a_ctrl,b_ctrl);
    parms theta_act 0.5 theta_ctrl 0.5;

/*** Likelihood ***/
    model resn_ia_act ~ binomial(n_ia_act,theta_act);
    model resn_ia_ctrl ~ binomial(n_ia_ctrl,theta_ctrl);

/*** Predicted number of responders in the remaining sample (n - n_ia)***/
    resn_pred_act = rand("binomial", theta_act, n_po_act); /*_p0: post interim*/
    resn_pred_ctrl = rand("binomial", theta_ctrl, n_po_ctrl);

/*** Number of responders at the end of the study = ia + pred ***/
    resn_eos_act = resn_ia_act + resn_pred_act;
    resn_eos_ctrl = resn_ia_ctrl + resn_pred_ctrl;

/*** Determine the probability that the difference is greater than 30% ***/
    diff = theta_act - theta_ctrl;
    ods output PostSummaries=posterior1 PostIntervals=posterior2;
run;
ods graphics off;

SAS Super FREQ
Posts: 4,245

Re: PROC MCMC Warning

Your use of the RAND function is incorrect. The "Predicted number of responders" cannot be random. I assume you either want to use the PDF function or the CDF function. To understand the difference between random values, densities, probabilities, and quantiles, see "Four essential functions for statistical programmers."

New Contributor
Posts: 3

Re: PROC MCMC Warning

Thanks for the support

 

Now with this code modification its working without any warning !!!


  random resn_pred_act ~binary(theta_act) subject= n_po_act monitor=(resn_pred_act);
  random  resn_pred_ctrl~binary(theta_ctrl) subject=n_po_ctrl monitor=(resn_pred_ctrl);

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 167 views
  • 3 likes
  • 3 in conversation