简体   繁体   中英

is there any way to calculate f-squared (as an effect size) for a predictor within an lm() multiple linear regression model?

For example, see the following reproducible example from the effectsize package:

library(effectsize)
model1 <- lm(mpg ~ cyl + disp + hp, data = mtcars)
model2 <- lm(mpg ~ cyl, data = mtcars)
cohens_f_squared(model1, model2 = model2)

The output indicates the Cohen's f2 is .18 and the change in r2 is .04. I would think f-squared would be .04167 (.04/1 - .04).

Let me know where I'm missing something - thank you!

@BenBolker This is the correct formula for computing f-square (see reference below):

f2 = (R2_modelA - R2_modelB)/(1 - R2_modelA)

In the example you posted, the modelA R2 is 0.7262 and modelB R2 is 0.7679. When you plug this into the f-square formula, you get (0.7679-0.7262)/(1-0.7679) = 0.18, which is the same value computed by the cohens_f_squared() function.

Cheers!

REFERENCE:

Selya, AS, Rose, JS, Dierker, LC, Hedeker, D., & Mermelstein, RJ (2012). A Practical Guide to Calculating Cohen's f(2), a Measure of Local Effect Size, from PROC MIXED. Frontiers in psychology, 3, 111. https://doi.org/10.3389/fpsyg.2012.00111

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3328081/#:~:text=f%202%20%3D%20R%202%201%20%2D%20R%202%20 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM