Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- How can I apply my nonlinear mixed-effects model to testdata?

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 03-23-2022 09:23 AM
(436 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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;**

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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:

- Introduction and main ideas: "The missing value trick for scoring a regression model"
- A second example: "How to score and graph a quantile regression model in SAS"

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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;**

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thank you very much Rick for your helps.

I predicted fixed and random effects.

**Available on demand!**

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

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.