BookmarkSubscribeRSS Feed
Polina_UH
Obsidian | Level 7

Dear experts,

 

I am trying to apply SAS code

 

proc mcmc data=crp nbi=50000 nmc=100000 outpost=OutData
init = random monitor=(lw1 lw2 lw3 beta0 delta w);
parms lw1 lw2 lw3 ;
array w[3];
w[1] = exp(lw1)/(exp(lw1)+ exp(lw2)+ exp(lw3));
w[2] = exp(lw2)/(exp(lw1)+ exp(lw2)+ exp(lw3));
w[3] = exp(lw3)/(exp(lw1)+ exp(lw2)+ exp(lw3));
parms beta0 delta ;
prior beta0 ~ cauchy(0,2.5);
prior delta ~ cauchy(0,2.5);
prior lw1 ~ beta(1,1);
prior lw2 ~ beta(1,1);
prior lw3 ~ beta(1,1);
p = beta0+ delta*(w[1]*cesd12+w[2]*cesd22+w[3]*cesd32);
model any_disorder ~ binomial(1,p);
run;

recommended is this paper https://pubmed.ncbi.nlm.nih.gov/29912384/  

 to examine how a time-varying exposure cesd affects health outcome any_disorder later in life. The code seems to be working when my exposure is binary, but when I am trying to use continuous exposure, I get this error ERROR: The BINOMIAL distribution of any_disorder (Obs = 1553) has an invalid probability -1.12646636. Use an appropriate parameter value instead. Could you you help me to modify the code such that it would work with continuous exposure variables?

 

Many thanks in advance!

 

ERROR: The BINOMIAL distribution of any_disorder (Obs = 1553) has an invalid probability
-1.12646636. Use an appropriate parameter value instead.

 

2 REPLIES 2
Polina_UH
Obsidian | Level 7
I am sorry, I forgot to mention that I have modified the original part of the code
p = logistic(beta0+ delta*(w[1]*cesd12_binary+w[2]*cesd22_binary+w[3]*cesd32_binary));

to p = beta0+ delta*(w[1]*cesd12+w[2]*cesd22+w[3]*cesd32); to accommodate continuous nature of the variables
ballardw
Super User

Your problem is not continuous values but the specific value. Binomial parameter for P in general has a range of 0 to 1. A negative value makes no sense at all.

You need to provide a value between 0 and 1 for P. That may require a pass through a data step to set an appropriate value for P. What that should be I have no clue.

 

Perhaps you need to look at what creates P very closely and see why it is 1) negative and 2) outside of the intended range of use values (0 to 1). Perhaps some data outlier?

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 684 views
  • 1 like
  • 2 in conversation