11
$\begingroup$

I've been trying to learn about effect size in relation to linear regression and am wondering how to implement it in R. Sure, I have p-values and they indicate how "predictive" the explanatory variable is. However, for each variable in a linear model, I was wondering how to compute a standardized score for how much it impacts the response variable.

Some sample data if you can present a R solution.

x1 = rnorm(10)
x2 = rnorm(10)
y1 = rnorm(10)

mod = lm(y1 ~ x1 + x2)
summary(mod)
$\endgroup$
4
  • $\begingroup$ You should be more specific in your context. There's a lot of different effect size statistics, and which one you find useful will depend on your context. For one, if you are dealing with latent variables, standardized statistics such as standardized beta, r-squared, and semi-partial correlation will be useful. If you are dealing with manifest variables, unstandardized beta will be useful. Just an example. $\endgroup$
    – Hotaka
    Commented Oct 3, 2013 at 16:59
  • $\begingroup$ Do you mean you want standardized parameter estimates? library(QuantPsyc) lm.beta(mod) $\endgroup$ Commented Oct 3, 2013 at 18:30
  • $\begingroup$ No. From a model, I can determine what predictors are "important" and how their relate to the response variable. However, I want to know more about the effect. So if variable x and y are important predictors, the effect would inform how x or y influenced the response variable. Wanted to run abnalysis where I could say that variable x had a 15% effect on y while variable z had a 2% effect in y. $\endgroup$
    – AMathew
    Commented Oct 3, 2013 at 19:23
  • 3
    $\begingroup$ Take a look at this paper Relative Importance for Linear Regression. There are a number of different methods that achieve what you are looking for. $\endgroup$
    – mss
    Commented May 21, 2015 at 14:25

2 Answers 2

6
$\begingroup$

I think what you want is the semi-partial correlation squared. This gives you the proportion of variance in y accounted for by x1 having controlled for x2. Note that this isn't necessarily the same as the proportion of variance in y accounted for by x1. That is the regular correlation squared. They will differ if the variables x1 and x2 are not perfectly uncorrelated. In addition, the multiple $R^2$ will be equal to the sum of $r_{yx_2}^2$ (i.e., the zero-order correlation squared for one of your variables), plus $r_{yx_1|x_2}$ (i.e., the semi-partial correlation squared controlling for the first variable), plus $r_{yx_1|x_2x_3}$, etc.

The formula for the semi-partial correlation is:
$$ r_{yx_1|x_2} = \frac{r_{yx_1} - r_{yx_2}r_{x_1x_2}}{\sqrt{(1-r_{x_1x_2}^2)}} $$

Here is a simple R demonstration:

semi.r = function(y, x, given){  # this function will compute the semi-partial r
  ryx  = cor(y, x)
  ryg  = cor(y, given)
  rxg  = cor(x, given)
  num  = ryx - (ryg*rxg)
  dnm  = sqrt( (1-rxg^2) )
  sp.r = num/dnm
  return(sp.r)
}
set.seed(9503)                   # this makes the example exactly reproducible
x1 = rnorm(10)                   # these variables are uncorrelated in the population
x2 = rnorm(10)                   # but not perfectly uncorrelated in this sample:
cor(x1, x2)                      # [1]  0.1265472
y  = 4 + .5*x1 - .3*x2 + rnorm(10, mean=0, sd=1)
model = lm(y~x1+x2)
summary(model)
# ...
# Coefficients:
#             Estimate Std. Error t value Pr(>|t|)    
# (Intercept)   4.1363     0.4127  10.022 2.11e-05 ***
# x1            0.1754     0.3800   0.461    0.658    
# x2           -0.6181     0.3604  -1.715    0.130    
# ...
sp.x1 = semi.r(y=y, x=x1, given=x2);  sp.x1  # [1]  0.1459061
sp.x1^2                                      # [1]  0.02128858
c.x2 = cor(x2, y);  c.x2                     # [1] -0.5280958
c.x2^2                                       # [1]  0.2788852
c.x2^2 + sp.x1^2                             # [1]  0.3001738
summary(model)$r.squared                     # [1]  0.3001738
$\endgroup$
2
$\begingroup$

I've been researching the same question and am surprised to not see a clear universally accepted answer (that I've found so far).

However a few methods I've seen are as follows:

  1. Report partial-Eta squared (η2p). Can be calculated by the eta_squared() function in the effectsize package in R.

    eta_squared(car::Anova(m, type = 3))

Full description found here: https://www.researchgate.net/post/Which-effect-size-estimate-should-I-use-for-a-linear-regression-with-a-continuous-dep-variable-dichotomous-indep-variable-and-covariates

  1. Alternatively you could calculate Cohen's F^2

The formula of which is

Cohen's f2 = (R^2included - R^2excluded) / (1 - R^2included)

For nested models R^2 included is the model with your effect of interest and R^2 excluded is your reduced model. f2 of 0.02-> small, 0.15-> Medium, 0.35 -> large effect sizes I got this info from: https://www.researchgate.net/post/Which-effect-size-estimate-should-I-use-for-a-linear-regression-with-a-continuous-dep-variable-dichotomous-indep-variable-and-covariates

  1. There's also a package for R called yhat that computes a variety of effect sizes with their effect.size() function. https://rdrr.io/cran/yhat/man/effect.size.html However I don't know how to interpret the effects it produces yet.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.