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

Hi all,

 

Consider the following basic example, where "Add" is used to add two variables to an existing regression equation:

 

proc reg;
model Y=x1 x2;
run;
 
add x3 x4;
print;
run;

 

The print command after the "add" shows the new model and its R square.  However, it does not show the change (or delta) in R square from the first to the second model (as with full/nested models).  It also does not provide a signficance test (specifically, an F test) to determine if the new variables provide a significant change in R2.  How can I get SAS to provide the change in R square and the accompanying significance test from the first to the second model?

 

EDIT:  Added request for significant test of change in R2.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

You should get the proper tests with the test statement in proc reg:

 

proc reg data=pt8 edf outest=r2 plots=none;
   	Covariates: model jobSat= I IM A AM;
   	Linear: model jobSat= R RM I IM A AM;
	LinTest: test R=0, RM=0;
	Quadratic: model jobSat= R RM RM2 R2 RInt I IM A AM;
	QuadTest: test RM2=0, R2=0, RInt=0;
run;
quit;
PG

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

If you give labels to your models :

 

proc reg data=sashelp.class edf outest=r2 plots=none;
partial: model weight = height;
full: model weight = height age;
run;
quit;

data _null_;
set r2(where=(_model_="partial"));
R2_partial = _RSQ_;
set r2(where=(_model_="full"));
R2_full = _RSQ_;
R2_diff = R2_full - R2_partial;
put (R2_:) (percentn6.1);
run;
PG
jpwiega
Fluorite | Level 6

Thanks @PGStats

 

I'm almost there, but two issues remain:

  1. Most importantly, I want to determine if there is a significant change in R2 from one model to the next--my fault for not specifying this earlier--I'll update the initial post momentarily.  As such, I need not only the change in R2 from one model to the next, but an F statistic and p-value to determine whether the change after adding variables is significant.
  2. The output is presently in the log and not labeled.  Is there a way to get formatted output?

Of note, here is the actual syntax I'm using, please build from it if possible.  I'm adding to sets of variables to the initial equation.  So there are 3 models and two comparisons for change in R-square:

 

proc reg data=pt8 edf outest=r2 plots=none;
   	Covariates: model jobSat= I IM A AM;
   	Linear: model jobSat= R RM I IM A AM;
	Quadratic: model jobSat= R RM RM2 R2 RInt I IM A AM;
run;
quit;

data _null_;
	set r2(where=(_model_="Covariates"));
		R2_Covariates = _RSQ_;
	set r2(where=(_model_="Linear"));
		R2_Linear = _RSQ_;
	set r2(where=(_model_="Quadratic"));
		R2_Quadratic = _RSQ_;
	R2_diff1 = R2_Linear - R2_Covariates;
	R2_diff2 = R2_Quadratic - R2_Linear;
	put (R2_:) (percentn6.1);
run;

 

Many thanks!

PGStats
Opal | Level 21

You should get the proper tests with the test statement in proc reg:

 

proc reg data=pt8 edf outest=r2 plots=none;
   	Covariates: model jobSat= I IM A AM;
   	Linear: model jobSat= R RM I IM A AM;
	LinTest: test R=0, RM=0;
	Quadratic: model jobSat= R RM RM2 R2 RInt I IM A AM;
	QuadTest: test RM2=0, R2=0, RInt=0;
run;
quit;
PG

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!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2621 views
  • 0 likes
  • 2 in conversation