Programming the statistical procedures from SAS

Use regression parameters to predict values in another dataset

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 111
Accepted Solution

Use regression parameters to predict values in another dataset

Hello,

I computed multinomial logit regression parameters using proc logistic:

 

proc sort data=edu.educationClean;by EU15 sex;run;
proc logistic data=edu.educationClean;
class cohort2(ref='2') Langue(ref='0') cntr_regr(ref=first) genstat3(ref='0') eduM3(ref='2') religion(ref='0') /param=ref;
model edu3(ref='2')= cntr_regr cohort2 cntr_regr*cohort2 Langue genstat3 religion eduM3  /link=glogit rsquare;
weight pond / norm;
by EU15 sex;
where model=1;
run;

 

I would like to use parameters to predict values of edu3 in another dataset  (donnees.popbase2) which has the same shape, but a different population. Is it possible?


Accepted Solutions
Solution
‎03-03-2017 07:05 AM
SAS Super FREQ
Posts: 3,556

Re: Use regression parameters to predict values in another dataset

Yes. This is called "scoring," and you can read about how to do it in the article "Techniques for scoring a regression model in SAS."

 

For your situation, I suggest using the STORE statement and the PLM procedure. To your PROC LOGISTIC code, add the SCORE statement, then use the SCORE statement in PROC PLM.  There is an example in the article.

View solution in original post


All Replies
Solution
‎03-03-2017 07:05 AM
SAS Super FREQ
Posts: 3,556

Re: Use regression parameters to predict values in another dataset

Yes. This is called "scoring," and you can read about how to do it in the article "Techniques for scoring a regression model in SAS."

 

For your situation, I suggest using the STORE statement and the PLM procedure. To your PROC LOGISTIC code, add the SCORE statement, then use the SCORE statement in PROC PLM.  There is an example in the article.

Frequent Contributor
Posts: 111

Re: Use regression parameters to predict values in another dataset

Thank you. I tried this:

 

proc sort data=edu.educationClean;by EU15 sex;run;
proc logistic data=edu.educationClean;
class cohort2(ref='2') cntr_regr(ref=first) genstat3(ref='0') eduM3(ref='2') religion(ref='0') /param=ref;
model edu3(ref='2')= cntr_regr cohort2 cntr_regr*cohort2 genstat3 religion eduM3  /link=glogit rsquare;
weight pond / norm;
where model=1;
by EU15 sex;
store work.regout;
run;

 

proc plm restore=work.regout;
   score data=edu.missing_countr;

   by EU15 sex;
run;

 

There is an error message saying "At least one variable used in the model is not present or has incompatible type in the EDU.MISSING_COUNTR score data set"

I noted that the dataset regout doesn't appear in the work folder. What I did wrong?

 

SAS Super FREQ
Posts: 3,556

Re: Use regression parameters to predict values in another dataset

REGOUT is not a data set. It is an item store.

 

The error message is reminding you that the data set that you are attempting to score must have every  variable that is in the model. You can use

 

PROC CONTENTS SHORT data=edu.missing_countr; run;

 

to see which variables are in the scoring data and (more importantly) which are not.

Frequent Contributor
Posts: 111

Re: Use regression parameters to predict values in another dataset

Right... the label of the weight variable was not the same.

Now I have values in the predicted value column, but I am not totally sure what they mean. I was expecting having probabilities for the 3 modalities of the dependent variable, but I have values such as

 

Ordinal Response Predicted value
0 -1.79479
1 -1.18285
2 0
Frequent Contributor
Posts: 111

Re: Use regression parameters to predict values in another dataset

[ Edited ]

Nevermind, I had to add out=testout predicted/ilink;

Now it works. Thank you.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 201 views
  • 0 likes
  • 2 in conversation