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

Hi,

I developed a nonlinear mixed-effects model using nlmixed procedure. But, I do not know how to apply this model to test data (unseen data in modeling). I tried OUTmodel and INmodel options, but I failed to run the model. Could you help me please?

 

data capboy;
input boy dbh N G hmak dmak plot;
datalines;
10.1 35 725 23.50 11.2 35 1
10.6 21 725 23.50 11.2 35 1

... more lines

;

data testdata;
input boy dbh N G hmak dmak plot;
datalines;
19 28 450 24.25 20 53 5
16.3 32 450 24.25 20 53 5

... more lines

;

proc nlmixed data=capboy ;
parms b1=54.021 b2=-12.521 b3=5.445 b4=1.911 b5=0.0699 s2u=0 s2e=1;
mdl=1.3 + (((b1 + b2*(dbh/hmak)))/(1 + (((b3 + b4*dmak/hmak))*exp( - (b5+u)*dbh))));
model boy ~ normal(mdl,s2e) OUTmodel=deneme;
random u ~ normal(0,s2u) subject=plot out=rp;
predict mdl out=tahmin;
run;

proc nlmixed INmodel=deneme;
score data=testdata fitstat;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

The PREDICT statement predicts any expression. Currently, you are predicting mdl, which does not include any random effects.  Add a new PREDICT statement such as 

predict mdl+u  out=tahminRand;

Or, for more complicated expressions, define a temporary variable in the program that incorporates the random effects. For example:

Pred = mdl + u;
predict Pred out=tahminRand;

 

View solution in original post

4 REPLIES 4
Rick_SAS
SAS Super FREQ

The NLMIXED procedure does not support a SCORE statement, nor a STORE statement that would create a model that PROC PLM could score. Therefore, you have to use the "missing value trick" to score data sets. For a discussion of the missing value trick and a complete example, see the following articles:

Neither of the examples use PROC NLMIXED, but I can see from the code you've posted that you have experience with PROC NLMIXED syntax, so I think you'll be able to adapt the ideas to your problem.

ferhatbolat
Calcite | Level 5

Thank you Rick,

I used "the missing value trick" and predicted the missing values. However, this method gave the predictions of fixed-effects. I need the predictions of random-effects.

 

data score;
boy=.;
do plot=143 to 178;
output;
run;
data Combined;
set capboy
Score(in=ScoreData);
run;
proc nlmixed data=Combined;
parms b1=54.021 b2=-12.521 b3=5.445 b4=1.911 b5=0.0699 s2u=0.3 s2e=0.5;
mdl=1.3 + ((((b1+u) + b2*(dbh/hmak)))/(1 + (((b3 + b4*dmak/hmak))*exp( - b5*dbh))));
model boy ~ normal(mdl,s2e);
random u ~ normal(0,s2u) subject=plot out=rp;
predict mdl out=tahmin;
run;
proc print data=tahmin(Where= (plot=143));
run;

Rick_SAS
SAS Super FREQ

The PREDICT statement predicts any expression. Currently, you are predicting mdl, which does not include any random effects.  Add a new PREDICT statement such as 

predict mdl+u  out=tahminRand;

Or, for more complicated expressions, define a temporary variable in the program that incorporates the random effects. For example:

Pred = mdl + u;
predict Pred out=tahminRand;

 

ferhatbolat
Calcite | Level 5

Thank you very much Rick for your helps.

I predicted fixed and random effects.

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 469 views
  • 3 likes
  • 2 in conversation