performance
performance copied to clipboard
Performance not compatible with fixest objects
I'm a big fan of this package, but it doesn't work natively with fixest objects (i.e., feols). Would this be possible to add?
What issue are you exactly encountering? Do you have a small reproducible example?
Sure, here you go:
model.lm <- lm(disp ~ am, data = mtcars) #using lm
model.feols <- fixest::feols(disp ~ am, data = mtcars) #using feols from fixest
performance::check_model(model.lm) #works
performance::check_model(model.feols) #fails
mod <- fixest::feols(disp ~ am, data = mtcars)
performance::check_model(mod)
#> Homogeneity of variance could not be computed. Cannot extract residual variance from objects of class 'fixest'.
#> Error in UseMethod("cooks.distance"): no applicable method for 'cooks.distance' applied to an object of class "fixest"
Created on 2022-06-07 by the reprex package (v2.0.1.9000)
Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#> setting value
#> version R version 4.1.3 (2022-03-10)
#> os Windows 10 x64 (build 22000)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate English_United Kingdom.1252
#> ctype English_United Kingdom.1252
#> tz Europe/Berlin
#> date 2022-06-07
#> pandoc 2.18 @ C:/PROGRA~1/Pandoc/ (via rmarkdown)
#>
#> - Packages -------------------------------------------------------------------
#> package * version date (UTC) lib source
#> bayestestR 0.12.1.1 2022-06-07 [1] Github (easystats/bayestestR@b58580c)
#> cli 3.3.0 2022-04-25 [1] CRAN (R 4.1.3)
#> crayon 1.5.1 2022-03-26 [1] CRAN (R 4.1.3)
#> datawizard 0.4.1.2 2022-06-07 [1] Github (easystats/datawizard@7e28b74)
#> digest 0.6.29 2021-12-01 [1] CRAN (R 4.1.2)
#> dreamerr 1.2.3 2020-12-05 [1] CRAN (R 4.1.1)
#> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.0)
#> evaluate 0.15 2022-02-18 [1] CRAN (R 4.1.2)
#> fansi 1.0.3 2022-03-24 [1] CRAN (R 4.1.3)
#> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.1)
#> fixest 0.10.4 2022-03-31 [1] CRAN (R 4.1.3)
#> Formula 1.2-4 2020-10-16 [1] CRAN (R 4.1.0)
#> fs 1.5.2 2021-12-08 [1] CRAN (R 4.1.2)
#> glue 1.6.2 2022-02-24 [1] CRAN (R 4.1.2)
#> highr 0.9 2021-04-16 [1] CRAN (R 4.1.1)
#> htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.1)
#> insight 0.17.1.7 2022-06-07 [1] Github (easystats/insight@85b8d27)
#> knitr 1.39 2022-04-26 [1] CRAN (R 4.1.3)
#> lattice 0.20-45 2021-09-22 [2] CRAN (R 4.1.3)
#> lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.1)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.1.3)
#> nlme 3.1-155 2022-01-16 [2] CRAN (R 4.1.3)
#> numDeriv 2016.8-1.1 2019-06-06 [1] CRAN (R 4.1.0)
#> performance 0.9.0.6 2022-06-07 [1] Github (easystats/performance@b6a221c)
#> pillar 1.7.0 2022-02-01 [1] CRAN (R 4.1.2)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.1)
#> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.1.1)
#> R.cache 0.15.0 2021-04-30 [1] CRAN (R 4.1.1)
#> R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.1.0)
#> R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.1.0)
#> R.utils 2.11.0 2021-09-26 [1] CRAN (R 4.1.1)
#> Rcpp 1.0.8.3 2022-03-17 [1] CRAN (R 4.1.3)
#> reprex 2.0.1.9000 2021-12-28 [1] Github (tidyverse/reprex@b96611f)
#> rlang 1.0.2 2022-03-04 [1] CRAN (R 4.1.2)
#> rmarkdown 2.14 2022-04-25 [1] CRAN (R 4.1.3)
#> rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.1.1)
#> sandwich 3.0-1 2021-05-18 [1] CRAN (R 4.1.1)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.2)
#> stringi 1.7.6 2021-11-29 [1] CRAN (R 4.1.2)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.1.2)
#> styler 1.7.0.9001 2022-06-07 [1] Github (r-lib/styler@cffab1e)
#> tibble 3.1.7 2022-05-03 [1] CRAN (R 4.1.3)
#> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.1.1)
#> vctrs 0.4.1 2022-04-13 [1] CRAN (R 4.1.3)
#> withr 2.5.0 2022-03-03 [1] CRAN (R 4.1.2)
#> xfun 0.31 2022-05-10 [1] CRAN (R 4.1.3)
#> yaml 2.3.5 2022-02-21 [1] CRAN (R 4.1.2)
#> zoo 1.8-10 2022-04-15 [1] CRAN (R 4.1.3)
#>
#> [1] C:/Users/IndrajeetPatil/Documents/R/win-library/4.1
#> [2] C:/Program Files/R/R-4.1.3/library
#>
#> ------------------------------------------------------------------------------
should work now, but there are not many checks that are available.
Which ones of the standard aren't available? We could write our own cooks d function eg
Here is the result from check_model()
:
@rempsyc Do you know whether check_outliers()
works on fixest models, now that you've done a large overhaul?
I am not familiar with fixest
models unfortunately, so I don't know if it should work (i.e,. if the current code—cook method—should be allowed to be applied to this type of model).
That said, I tested it and it currently runs, but no method is actually used. It should probably throw an error instead.
library(performance)
packageVersion("performance")
#> [1] '0.9.2.2'
model.feols <- fixest::feols(disp ~ am, data = mtcars)
check_outliers(model.feols)
#> Converting missing values (`NA`) into regular values currently not
#> possible for variables of class `NULL`.
#> OK: No outliers detected.
#> - Based on the following method and threshold: ().
#> - For variable: (Whole model)
Created on 2022-09-02 by the reprex package (v2.0.1)
I am doing further tests to see where it fails.
Seems fixest
is not compatible with cook:
model.feols <- fixest::feols(disp ~ am, data = mtcars)
stats::cooks.distance(model.feols)
#> Error in UseMethod("cooks.distance"): no applicable method for 'cooks.distance' applied to an object of class "fixest"
Created on 2022-09-02 by the reprex package (v2.0.1)
fixest
doesn't look like a bayesian method, but just, in case, I also tried pareto
method:
loo::pareto_k_values(loo::loo(model.feols))
#> Error in loo::loo(model.feols): object 'model.feols' not found
Created on 2022-09-02 by the reprex package (v2.0.1)
By the way, it's good that we have the methods listed in the print method now, because in the previous version, it seems like it would run and declare no outliers, while actually no method would be applied (and I've seen this happen in my initial testing). Now it's easier to diagnose if something goes wrong.