BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
loris1
Calcite | Level 5

Tried using the following code and obtained the error message below. Would greatly appreciate any insight into how to correct code/what I am doing wrong.  variables BMI and age are continuous, gender is binary.

Code:

proc mcmc data=pdata outpost=pdata seed=1234 nmc=20000;
ods select PostSumInt;
parms beta0 0 beta1 0 beta2 0 beta3 0 s2 1;
prior s2 ~ igamma(0.01, s=0.01);
prior beta: ~ general(0);
w = beta0 + beta1*bmi + beta2*age + beta3*gender;
random delta ~ normal(w, var=100) subject=childid;
pi = logistic(delta);
model sick ~ binomial(p=pi);
run;

 


ERROR: A hyperparameter of the random effect delta changed value in observation 2. The
hyperparameter is a function of the data set variable bmi, which must remain constant
within subjects.


1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

The error message is telling you that the BMI for one of the subjects changed during the course of the repeated observations. It says that in a random effects model, the variables in the random effects are assumed to be constant within each subject. 

 

> Would greatly appreciate any insight into how to correct code/what I am doing wrong.

 

If you expect BMI to vary within subjects, you might need to change your model and incorporate BMI as a fixed effect. Or, I suppose you could use the average BMI for each subject during the study if the BMI is changes very little.

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

[I have just reported susanmoly2's reply as inappropriate content as it contains an unrelated advertising link, embedded in what sounds like AI-generated gibberish.]

Rick_SAS
SAS Super FREQ

The error message is telling you that the BMI for one of the subjects changed during the course of the repeated observations. It says that in a random effects model, the variables in the random effects are assumed to be constant within each subject. 

 

> Would greatly appreciate any insight into how to correct code/what I am doing wrong.

 

If you expect BMI to vary within subjects, you might need to change your model and incorporate BMI as a fixed effect. Or, I suppose you could use the average BMI for each subject during the study if the BMI is changes very little.

sas-innovate-wordmark-2025-midnight.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. Sign up by March 14 for just $795.


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
  • 850 views
  • 1 like
  • 3 in conversation