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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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