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.
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.
[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.]
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.
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.
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.
Ready to level-up your skills? Choose your own adventure.