12-04-2015 10:16 PM
Currently, I encountered one problem from Proc NLMIXED procedure. Any advice will be appreciated.
After I build random effect model by Proc NLMIXED, the event% from prediction is always lower than actual value. Here, I will use the example from "Fixed effects regression methods fro longitudinal data" (by Paul D. Allison) to describe my problem.
After run the code below, I got predicted Phat for both fixed and random effects and saved in data P2 and P respectively. Then I calculated the yearly event rate and compare them with actual value.
eta=b0 + byr1*(year=1)+ byr2*(year=2) + byr3*(year=3) +byr4*(year=4) + bmother*mother +bspouse*spouse +bschool*inschool + bhours*hours + alpha;
RANDOM alpha ~ NORMAL(0,s2) SUBJECT=id out=abc;
PARMS b0=-.29 byr1=-.06 byr2=.16 byr3=.09 byr4=.09 bmother=.99 bspouse=-1.26 bschool=.24 bhours=-.03 s2=1 ;
predict P out=p;
predict 1/(1+ EXP(-(b0 + byr1*(year=1)+ byr2*(year=2) + byr3*(year=3) +
byr4*(year= 4) + bmother*mother + bspouse*spouse +
bschool*inschool + bhours*hours))) out=p2;
From both data and charts(attached picture), the predicted rates were lower than actual value with parallel shift.
Since this is the first time I use Proc NLMIXED, I wonder if there is anything wrong in my process to predict yhat.Meanwhile, could I also setup the mean of alpha as random term instead of constant of 0.
Thanks a lot in advance.
12-11-2015 08:35 AM
It is hard to tell what is going on without the data. Also, you are apparently doing post-model-fit processing to get the numbers you are showing, and I can't tell what you are doing there. With more information, we might be able to help.
12-12-2015 10:28 PM
Thank you so much for your reply. The data and code can be download from link below:
The data manipulation code is:
year=1 TO 5;
id year black age pov mother spouse inschool hours;
Currently, I just guess if the nonlinear transformation between probability and odds by logit function is the main reason of my question. Because all observations under single id will be assigned identical random-intercept, but it will resulted in different impact on probability.
Thanks again and have a great weekend.
12-30-2015 01:52 PM
I believe you have identified a large part of the reason with "Meanwhile, could I also setup the mean of alpha as random term instead of constant of 0."
I guess my next question is why NLMIXED, rather than GLIMMIX. Wouldn't the following fit the same model?
proc glimmix data=teenyrs5 method=laplace;
class mother spouse inschool hours year id;
model pov= mother spouse inschool hours year/dist=binary solution;
random year/subject=id type=ar(1) g gcorr v vcorr; /* If you have sufficient data, you might want to try type=chol for an unstructured correlation matrix*/
For predicted values, you can add an lsmeans statement. To estimate the fixed effects at various years, you will need to add interaction terms to the model statement (which may be the source of your difference in NLMIXED).