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

Hi there,

 

I'm interested in understanding the amount of variance from each variable in a multiple linear regression analysis. I am using PROC GLM because I have a dummy categorical variable. What function allows me to do this? Or alternatively would I be able to use PROC REG to do this?

 

Thank you for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

I guess you are looking for something like:

 

proc glm data=sashelp.class;
class sex;
model weight = sex|height / ss3;
ods output modelanova=ma overallanova=oa;
run; 

proc sql;
select 
    ma.Dependent,
    ma.source, 
    ma.SS / oa.SS as type3_PartialRsquare format=percentn7.1,
    ma.probF
from 
    ma, oa
where oa.source="Corrected Total";
quit;

 

                                                      type3_
                                                     Partial
               Dependent  Source                     Rsquare  Pr > F
               -----------------------------------------------------
               Weight     Sex                          0.2%   0.7360
               Weight     Height                      60.6%   <.0001
               Weight     Height*Sex                   0.3%   0.6657

 

 

use with caution.

PG

View solution in original post

9 REPLIES 9
PaigeMiller
Diamond | Level 26

@xshinbrot0 wrote:

Hi there,

 

I'm interested in understanding the amount of variance from each variable in a multiple linear regression analysis. I am using PROC GLM because I have a dummy categorical variable. What function allows me to do this? Or alternatively would I be able to use PROC REG to do this?

 

Thank you for your help!


"Variance from each variable" isn't worded in a way that makes sense to me.

 

There is a variance of the slope estimate for each variable.

 

There is a percent of total variability explained by each variable (although this isn't a unique quantity unless you have a perfectly orthogonal set of input variables).

 

Is either of these what you are interested in? (Both of these, by the way, can be computed for categorical variables)

 

Also, with regard to your title (which really ought to be explicitly stated somewhere in the text of your message), there are partial correlations that can be computed in SAS, but as far as I am aware, there are no partial R-squared.

--
Paige Miller
xshinbrot0
Calcite | Level 5

Apologies. I believe what I'm asking for is the coefficient of partial determination. When you conduct a multiple regression using forward, backward or stepwise, the output provides a partial R2 (along with a model R2), I'm interested in generating that from the PROC REG or PROC GLM statement with only the variables of interest.

 

Let me know if more clarification is needed.

PaigeMiller
Diamond | Level 26

Ah, I see. I'm sorry to state that I have such negative opinions about stepwise regression that I completely block it out of my mind, and so I can't even help here as I don't know (or understand) what the statistic is in the context of stepwise regression.

 

Adding: my brain is so used to the underlying concepts of Partial Least Squares regression that the idea of assigning some (partial) R2 to individual variables is something that I would advise against (except in the case of a perfectly orthogonal X matrix).

--
Paige Miller
xshinbrot0
Calcite | Level 5
I completely understand.

If I were interested in the variance of the slope estimate for each variable and the percent of total variability explained by each variable, where would I look in the output or is there a separate ODS statement I would need to add?
PaigeMiller
Diamond | Level 26

In PROC GLM, the variability of the slope estimate is, expessed as a standard error, in the "Standard Error" column, for example:

http://documentation.sas.com/?cdcId=statcdc&cdcVersion=14.2&docsetId=statug&docsetTarget=statug_glm_...

 

At the same link, the percent of total variability explained is shown under Mean Square (which is in variance units, not standard deviation units) but as I said, these values are not unique unless you have a perfectly orthogonal X-matrix, which you probably don't have.

 

 

 

 

--
Paige Miller
PGStats
Opal | Level 21

I guess you are looking for something like:

 

proc glm data=sashelp.class;
class sex;
model weight = sex|height / ss3;
ods output modelanova=ma overallanova=oa;
run; 

proc sql;
select 
    ma.Dependent,
    ma.source, 
    ma.SS / oa.SS as type3_PartialRsquare format=percentn7.1,
    ma.probF
from 
    ma, oa
where oa.source="Corrected Total";
quit;

 

                                                      type3_
                                                     Partial
               Dependent  Source                     Rsquare  Pr > F
               -----------------------------------------------------
               Weight     Sex                          0.2%   0.7360
               Weight     Height                      60.6%   <.0001
               Weight     Height*Sex                   0.3%   0.6657

 

 

use with caution.

PG
xshinbrot0
Calcite | Level 5
Thank you. What are the words of caution?
xshinbrot0
Calcite | Level 5

Hi there,

 

So I conducted the test as suggested, but it gives me the output with the partial R2 twice (see attached), why is that?

 

proc sql;
select 
    ma.Dependent,
    ma.source, 
    ma.SS / oa.SS as type3_PartialRsquare format=percentn7.1,
    ma.probF
from 
    ma, oa
where oa.source="Corrected Total";
quit;

  

PGStats
Opal | Level 21

You should show the code for the regression.

 

Caution: consider @PaigeMiller's answers above and search Google for   caution "r square"

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 9 replies
  • 5313 views
  • 0 likes
  • 3 in conversation