Programming the statistical procedures from SAS

R-Squared(Predicted)? How can you get these values in SAS 9.4

Accepted Solution Solved
Reply
Contributor
Posts: 45
Accepted Solution

R-Squared(Predicted)? How can you get these values in SAS 9.4

Hello,

I was wondering if you can get the R-Squared(predicted) values for models in SAS 9.4 for regression?

Thank you,

Jeff S. O.


Accepted Solutions
Solution
‎07-10-2016 02:13 PM
Respected Advisor
Posts: 4,606

Re: R-Squared(Predicted)? How can you get these values in SAS 9.4

Here is a way to get the predicted r-squared with proc reg:

 

proc reg data=sashelp.class outest=outest plots=none;
model weight = height / rsquare press sse adjrsq;
run;
quit;

data outestPlus;
set outest;
_PRSQ_ = 1 - _PRESS_ * (1 - _RSQ_)/_SSE_;
label _PRSQ_ = "Predicted r-squared";
run;

proc print data=outestPlus label; 
var _RSQ_ _ADJRSQ_ _PRSQ_;
run;
PG

View solution in original post


All Replies
Grand Advisor
Posts: 16,841

Re: R-Squared(Predicted)? How can you get these values in SAS 9.4

What proc are you using? I'm fairly sure their output by default in proc REG. 

Contributor
Posts: 45

Re: R-Squared(Predicted)? How can you get these values in SAS 9.4

I'm willing to use any of the regression procedures for this.  R-Squared(predicted) is not to be confused with R-Squared(adj) or normal R-Squared.  R-Squared(predicted) is based on the PRESS statistic.  I am trying to get R-Squared(predicted) values for each model as you could for the Cp values.

Thank you,

Jeff S. O.

Grand Advisor
Posts: 9,444

Re: R-Squared(Predicted)? How can you get these values in SAS 9.4

Then check PROC GLMSELECT which contains all the good fit statistic : AIC , BIC , PRESS , R-square , Cp ..........


Solution
‎07-10-2016 02:13 PM
Respected Advisor
Posts: 4,606

Re: R-Squared(Predicted)? How can you get these values in SAS 9.4

Here is a way to get the predicted r-squared with proc reg:

 

proc reg data=sashelp.class outest=outest plots=none;
model weight = height / rsquare press sse adjrsq;
run;
quit;

data outestPlus;
set outest;
_PRSQ_ = 1 - _PRESS_ * (1 - _RSQ_)/_SSE_;
label _PRSQ_ = "Predicted r-squared";
run;

proc print data=outestPlus label; 
var _RSQ_ _ADJRSQ_ _PRSQ_;
run;
PG
Contributor
Posts: 45

Re: R-Squared(Predicted)? How can you get these values in SAS 9.4

Thank you,

I do have another question however, which I may need to start a new thread for.  From what I see so far, Proc PHREG is the only procedure that will do the Best Subset Selection process for determining what predictors to include in a model.  The question I have is, can you get other values such as Cp or the different R-Squared values along with the Chi-square score that is presented with each model?

Thank you,
Jeff S. O.

Respected Advisor
Posts: 4,606

Re: R-Squared(Predicted)? How can you get these values in SAS 9.4

[ Edited ]

Simple answer: No. Best subset model selection is limited to certain criteria that are "easy" to compute. Unless there is some mathematical shortcut, there are too many candidate subsets for the best subsets approach to be practical.  PHREG is for fitting survival models. Proc reg does best subset selection when METHOD = RSQUARE, ADJRSQ, or CP. PRESS and thus predicted r-squared is expensive to calculate, so I wouldn't expect best subset model selection based on that criterion.

 

For modern approaches to variable selection with large (long and wide) datasets, look at proc glmselect.

PG
Contributor
Posts: 45

Re: R-Squared(Predicted)? How can you get these values in SAS 9.4

A desired example is output from MiniTab.  I do have MiniTab, but it is my last resort for various reasons.  Here is the MiniTab output:

 

Response is BP

                                                                                  W         S
                                                                                   e       P t
                                                                                   i        u r
                                                                              A g B D l  e
                                            Mallows                      g h S u s  s
Vars    R-Sq      R-Sq(adj)            Cp              S      e t A  r e  s
1          90.3      89.7              312.8       1.7405      X
1          75.0      73.6              829.1       2.7903      X
2          99.1      99.0              15.1       0.53269      X X
2          92.0      91.0              256.6       1.6246      X X
3          99.5       99.4             6.4         0.43705      X X X
3          99.2       99.1            14.1        0.52012      X X X
4          99.5       99.4              6.4        0.42591      X X X X
4          99.5       99.4            7.1          0.43500      X X X X
5          99.6       99.4           7.0           0.42142      X X X X X
5          99.5       99.4            7.7          0.43078      X X X X X
6          99.6       99.4            7.0          0.40723      X X X X X X

 

 

Thank you,

Jeff S. O.

 

Grand Advisor
Posts: 9,444

Re: R-Squared(Predicted)? How can you get these values in SAS 9.4

It sounds that you are doing FORMARD selection method.

Why could have two obs for each variable ?

 

 

 


proc glmselect data=sashelp.baseball plot=CriterionPanel;
class league division;
model logSalary = nAtBat nHits nHome nRuns nRBI nBB
yrMajor crAtBat crHits crHome crRuns crRbi
crBB league division nOuts nAssts nError
/ selection=forward(select=SL) stats=all;
run;

x.png

☑ This topic is SOLVED.

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

Discussion stats
  • 8 replies
  • 1954 views
  • 4 likes
  • 4 in conversation