performance icon indicating copy to clipboard operation
performance copied to clipboard

add r2 for lavaan

Open mattansb opened this issue 4 years ago • 6 comments

m <- lavaan::sem("mpg ~ cyl
                   hp ~ am", 
                 data = mtcars)

lavaan::lavInspect(m, "rsquare")
#>   mpg    hp 
#> 0.686 0.033

performance::r2(m)
#> 'r2()' does not support models of class 'lavaan'.
#> [1] NA

Created on 2021-02-17 by the reprex package (v1.0.0)

mattansb avatar Feb 17 '21 13:02 mattansb

should we return like a list with the R2 for each response?

DominiqueMakowski avatar Feb 17 '21 14:02 DominiqueMakowski

🤷‍♂️ I guess it has so be somewhat consistent with other r2s...?

mattansb avatar Feb 17 '21 14:02 mattansb

out of curiosity, is there a way to aggregate them to have a "unique" model-general R2 (the explained variance of the dataset made of all the responses)?

DominiqueMakowski avatar Feb 17 '21 14:02 DominiqueMakowski

Not that I know of...

mattansb avatar Feb 17 '21 14:02 mattansb

https://link.springer.com/article/10.3758/s13428-020-01532-y

DominiqueMakowski avatar Mar 31 '21 23:03 DominiqueMakowski

In SEM we generally report individual response variable R2 by convention. FYI, this could easily be done for piecewiseSEM as well to cover all of your bases - there is a function within the package, or just lapply your way across each model piece.

jebyrnes avatar Jun 01 '21 02:06 jebyrnes