BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JOmy
Fluorite | Level 6

 

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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

5 REPLIES 5
ballardw
Super User

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.

Rick_SAS
SAS Super FREQ

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.)

JOmy
Fluorite | Level 6

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;

Rick_SAS
SAS Super FREQ

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."

JOmy
Fluorite | Level 6

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);

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 1484 views
  • 3 likes
  • 3 in conversation