Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- PROC MCMC Warning

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-06-2018 07:12 AM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to JOmy

04-06-2018 01:51 PM

All Replies

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to JOmy

04-06-2018 10:51 AM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to JOmy

04-06-2018 01:51 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

04-09-2018 02:18 AM

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;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to JOmy

04-09-2018 08:03 AM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

04-10-2018 02:51 AM

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