1

Does anyone know how to extract the cohen's f2 effect size value from a model computed with the lm() function in R?

I would like to report effect sizes for individual predictors while accounting for other covariates in a multiple regression model, in order to not limit myself to p values in my reporting. There is information out there for using SAS, but not for the lm() function in R

jpsmith
  • 11,023
  • 5
  • 15
  • 36
  • Are you looking for [this SO post](https://stackoverflow.com/questions/71213139/is-there-any-way-to-calculate-f-squared-as-an-effect-size-for-a-predictor-with)? – Rui Barradas May 13 '22 at 12:37

1 Answers1

2

Here is a function to compute Cohen's f2.

cohen_f2 <- function(fit, fit2){
  R2 <- summary(fit)$r.squared
  if(missing(fit2)) {
    R2/(1 - R2)
  } else {
    R2B <- summary(fit2)$r.squared
    (R2B - R2)/(1 - R2B)
  }
}

data(LifeCycleSavings, package = "datasets")

fm0 <- lm(sr ~ pop15 + pop75 + dpi, data = LifeCycleSavings)
fm1 <- lm(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings)

# summary(fm0)
# summary(fm1)

cohen_f2(fm0)
#> [1] 0.3780803
cohen_f2(fm1)
#> [1] 0.5116161
cohen_f2(fm0, fm1)
#> [1] 0.09689991

Created on 2022-05-13 by the reprex package (v2.0.1)

Rui Barradas
  • 70,273
  • 8
  • 34
  • 66
  • How do you interpret the result? For example, I'm getting a value of 1.278. Is that a low, medium, or high effect size? – Outsider Jan 21 '23 at 00:51
  • 1
    @ArkaGhosh See [this CV post](https://stats.stackexchange.com/questions/266003/interpretation-of-cohens-f2-for-effect-size-in-multiple-regression). – Rui Barradas Jan 21 '23 at 16:36