2
2
# performance <img src =' man/figures/logo.png ' align =" right " height =" 139 " />
3
3
4
4
[ ![ DOI] ( https://joss.theoj.org/papers/10.21105/joss.03139/status.svg )] ( https://doi.org/10.21105/joss.03139 )
5
- [ ![ downloads] ( http ://cranlogs.r-pkg.org/badges/performance)] ( https://cran.r-project.org/package=performance )
5
+ [ ![ downloads] ( https ://cranlogs.r-pkg.org/badges/performance)] ( https://cran.r-project.org/package=performance )
6
6
[ ![ total] ( https://cranlogs.r-pkg.org/badges/grand-total/performance )] ( https://cranlogs.r-pkg.org/ )
7
7
8
8
*** Test if your model is a good model!***
@@ -23,18 +23,17 @@ zero-inflation, convergence or singularity.
23
23
24
24
## Installation
25
25
26
- [ ![ CRAN] ( http ://www.r-pkg.org/badges/version/performance)] ( https://cran.r-project.org/package=performance )
26
+ [ ![ CRAN] ( https ://www.r-pkg.org/badges/version/performance)] ( https://cran.r-project.org/package=performance )
27
27
[ ![ performance status
28
28
badge] ( https://easystats.r-universe.dev/badges/performance )] ( https://easystats.r-universe.dev )
29
- [ ![ R
30
- check] ( https://github.com/easystats/performance/workflows/R-CMD-check/badge.svg?branch=main )] ( https://github.com/easystats/performance/actions )
29
+ [ ![ codecov] ( https://codecov.io/gh/easystats/performance/branch/main/graph/badge.svg )] ( https://app.codecov.io/gh/easystats/performance )
31
30
32
31
The * performance* package is available on CRAN, while its latest
33
32
development version is available on R-universe (from * rOpenSci* ).
34
33
35
- | Type | Source | Command |
36
- | ------------- | ------------ | --------------------------------------------------------------------------- ----|
37
- | Release | CRAN | ` install.packages("performance") ` |
34
+ | Type | Source | Command |
35
+ | ----| ----| ----|
36
+ | Release | CRAN | ` install.packages("performance") ` |
38
37
| Development | R-universe | ` install.packages("performance", repos = "https://easystats.r-universe.dev") ` |
39
38
40
39
Once you have downloaded the package, you can then load it using:
@@ -57,13 +56,13 @@ To cite performance in publications use:
57
56
``` r
58
57
citation(" performance" )
59
58
# > To cite package 'performance' in publications use:
60
- # >
59
+ # >
61
60
# > Lüdecke et al., (2021). performance: An R Package for Assessment, Comparison and
62
61
# > Testing of Statistical Models. Journal of Open Source Software, 6(60), 3139.
63
62
# > https://doi.org/10.21105/joss.03139
64
- # >
63
+ # >
65
64
# > A BibTeX entry for LaTeX users is
66
- # >
65
+ # >
67
66
# > @Article{,
68
67
# > title = {{performance}: An {R} Package for Assessment, Comparison and Testing of Statistical Models},
69
68
# > author = {Daniel Lüdecke and Mattan S. Ben-Shachar and Indrajeet Patil and Philip Waggoner and Dominique Makowski},
@@ -78,6 +77,10 @@ citation("performance")
78
77
79
78
## Documentation
80
79
80
+ [ ![ Documentation] ( https://img.shields.io/badge/documentation-performance-orange.svg?colorB=E91E63 )] ( https://easystats.github.io/performance/ )
81
+ [ ![ Blog] ( https://img.shields.io/badge/blog-easystats-orange.svg?colorB=FF9800 )] ( https://easystats.github.io/blog/posts/ )
82
+ [ ![ Features] ( https://img.shields.io/badge/features-performance-orange.svg?colorB=2196F3 )] ( https://easystats.github.io/performance/reference/index.html )
83
+
81
84
There is a nice introduction into the package on
82
85
[ youtube] ( https://www.youtube.com/watch?v=EPIxQ5i5oxs ) .
83
86
@@ -145,15 +148,15 @@ model <- stan_glmer(
145
148
146
149
r2(model )
147
150
# > # Bayesian R2 with Compatibility Interval
148
- # >
151
+ # >
149
152
# > Conditional R2: 0.954 (95% CI [0.951, 0.957])
150
153
# > Marginal R2: 0.414 (95% CI [0.204, 0.644])
151
154
152
155
library(lme4 )
153
156
model <- lmer(Reaction ~ Days + (1 + Days | Subject ), data = sleepstudy )
154
157
r2(model )
155
158
# > # R2 for Mixed Models
156
- # >
159
+ # >
157
160
# > Conditional R2: 0.799
158
161
# > Marginal R2: 0.279
159
162
```
@@ -172,7 +175,7 @@ library(lme4)
172
175
model <- lmer(Reaction ~ Days + (1 + Days | Subject ), data = sleepstudy )
173
176
icc(model )
174
177
# > # Intraclass Correlation Coefficient
175
- # >
178
+ # >
176
179
# > Adjusted ICC: 0.722
177
180
# > Unadjusted ICC: 0.521
178
181
```
@@ -188,9 +191,9 @@ model <- brm(mpg ~ wt + (1 | cyl) + (1 + wt | gear), data = mtcars)
188
191
``` r
189
192
icc(model )
190
193
# > # Intraclass Correlation Coefficient
191
- # >
192
- # > Adjusted ICC: 0.941
193
- # > Unadjusted ICC: 0.779
194
+ # >
195
+ # > Adjusted ICC: 0.930
196
+ # > Unadjusted ICC: 0.771
194
197
```
195
198
196
199
### Model diagnostics
@@ -209,7 +212,7 @@ data(Salamanders)
209
212
model <- glm(count ~ spp + mined , family = poisson , data = Salamanders )
210
213
check_overdispersion(model )
211
214
# > # Overdispersion test
212
- # >
215
+ # >
213
216
# > dispersion ratio = 2.946
214
217
# > Pearson's Chi-Squared = 1873.710
215
218
# > p-value = < 0.001
@@ -234,7 +237,7 @@ fitted model.
234
237
model <- glm(count ~ spp + mined , family = poisson , data = Salamanders )
235
238
check_zeroinflation(model )
236
239
# > # Check for zero-inflation
237
- # >
240
+ # >
238
241
# > Observed zeros: 387
239
242
# > Predicted zeros: 298
240
243
# > Ratio: 0.77
@@ -322,7 +325,7 @@ be r-squared, AIC, BIC, RMSE, ICC or LOOIC.
322
325
m1 <- lm(mpg ~ wt + cyl , data = mtcars )
323
326
model_performance(m1 )
324
327
# > # Indices of model performance
325
- # >
328
+ # >
326
329
# > AIC | AICc | BIC | R2 | R2 (adj.) | RMSE | Sigma
327
330
# > ---------------------------------------------------------------
328
331
# > 156.010 | 157.492 | 161.873 | 0.830 | 0.819 | 2.444 | 2.568
@@ -334,7 +337,7 @@ model_performance(m1)
334
337
m2 <- glm(vs ~ wt + mpg , data = mtcars , family = " binomial" )
335
338
model_performance(m2 )
336
339
# > # Indices of model performance
337
- # >
340
+ # >
338
341
# > AIC | AICc | BIC | Tjur's R2 | RMSE | Sigma | Log_loss | Score_log | Score_spherical | PCP
339
342
# > -----------------------------------------------------------------------------------------------------
340
343
# > 31.298 | 32.155 | 35.695 | 0.478 | 0.359 | 1.000 | 0.395 | -14.903 | 0.095 | 0.743
@@ -347,7 +350,7 @@ library(lme4)
347
350
m3 <- lmer(Reaction ~ Days + (1 + Days | Subject ), data = sleepstudy )
348
351
model_performance(m3 )
349
352
# > # Indices of model performance
350
- # >
353
+ # >
351
354
# > AIC | AICc | BIC | R2 (cond.) | R2 (marg.) | ICC | RMSE | Sigma
352
355
# > ----------------------------------------------------------------------------------
353
356
# > 1755.628 | 1756.114 | 1774.786 | 0.799 | 0.279 | 0.722 | 23.438 | 25.592
@@ -367,13 +370,27 @@ m4 <- glm(counts ~ outcome + treatment, family = poisson())
367
370
368
371
compare_performance(m1 , m2 , m3 , m4 , verbose = FALSE )
369
372
# > # Comparison of Model Performance Indices
370
- # >
371
- # > Name | Model | AIC (weights) | AICc (weights) | BIC (weights) | RMSE | Sigma | Score_log | Score_spherical | R2 | R2 (adj.) | Tjur's R2 | Log_loss | PCP | R2 (cond.) | R2 (marg.) | ICC | Nagelkerke's R2
372
- # > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
373
- # > m1 | lm | 156.0 (<.001) | 157.5 (<.001) | 161.9 (<.001) | 2.444 | 2.568 | | | 0.830 | 0.819 | | | | | | |
374
- # > m2 | glm | 31.3 (>.999) | 32.2 (>.999) | 35.7 (>.999) | 0.359 | 1.000 | -14.903 | 0.095 | | | 0.478 | 0.395 | 0.743 | | | |
375
- # > m3 | lmerMod | 1764.0 (<.001) | 1764.5 (<.001) | 1783.1 (<.001) | 23.438 | 25.592 | | | | | | | | 0.799 | 0.279 | 0.722 |
376
- # > m4 | glm | 56.8 (<.001) | 76.8 (<.001) | 57.7 (<.001) | 3.043 | 1.000 | -2.598 | 0.324 | | | | | | | | | 0.657
373
+ # >
374
+ # > Name | Model | AIC (weights) | AICc (weights) | BIC (weights) | RMSE | Sigma | Score_log
375
+ # > -----------------------------------------------------------------------------------------------
376
+ # > m1 | lm | 156.0 (<.001) | 157.5 (<.001) | 161.9 (<.001) | 2.444 | 2.568 |
377
+ # > m2 | glm | 31.3 (>.999) | 32.2 (>.999) | 35.7 (>.999) | 0.359 | 1.000 | -14.903
378
+ # > m3 | lmerMod | 1764.0 (<.001) | 1764.5 (<.001) | 1783.1 (<.001) | 23.438 | 25.592 |
379
+ # > m4 | glm | 56.8 (<.001) | 76.8 (<.001) | 57.7 (<.001) | 3.043 | 1.000 | -2.598
380
+ # >
381
+ # > Name | Score_spherical | R2 | R2 (adj.) | Tjur's R2 | Log_loss | PCP | R2 (cond.) | R2 (marg.)
382
+ # > ---------------------------------------------------------------------------------------------------
383
+ # > m1 | | 0.830 | 0.819 | | | | |
384
+ # > m2 | 0.095 | | | 0.478 | 0.395 | 0.743 | |
385
+ # > m3 | | | | | | | 0.799 | 0.279
386
+ # > m4 | 0.324 | | | | | | |
387
+ # >
388
+ # > Name | ICC | Nagelkerke's R2
389
+ # > ------------------------------
390
+ # > m1 | |
391
+ # > m2 | |
392
+ # > m3 | 0.722 |
393
+ # > m4 | | 0.657
377
394
```
378
395
379
396
#### General index of model performance
@@ -385,7 +402,7 @@ of model performance and sort the models from the best one to the worse.
385
402
``` r
386
403
compare_performance(m1 , m2 , m3 , m4 , rank = TRUE , verbose = FALSE )
387
404
# > # Comparison of Model Performance Indices
388
- # >
405
+ # >
389
406
# > Name | Model | RMSE | Sigma | AIC weights | AICc weights | BIC weights | Performance-Score
390
407
# > -----------------------------------------------------------------------------------------------
391
408
# > m2 | glm | 0.359 | 1.000 | 1.000 | 1.000 | 1.000 | 100.00%
@@ -423,20 +440,20 @@ lm4 <- lm(Sepal.Length ~ Species * Sepal.Width + Petal.Length + Petal.Width, dat
423
440
test_performance(lm1 , lm2 , lm3 , lm4 )
424
441
# > Name | Model | BF | Omega2 | p (Omega2) | LR | p (LR)
425
442
# > ------------------------------------------------------------
426
- # > lm1 | lm | | | | |
443
+ # > lm1 | lm | | | | |
427
444
# > lm2 | lm | > 1000 | 0.69 | < .001 | -6.25 | < .001
428
445
# > lm3 | lm | > 1000 | 0.36 | < .001 | -3.44 | < .001
429
446
# > lm4 | lm | > 1000 | 0.73 | < .001 | -7.77 | < .001
430
447
# > Each model is compared to lm1.
431
448
432
449
test_bf(lm1 , lm2 , lm3 , lm4 )
433
450
# > Bayes Factors for Model Comparison
434
- # >
451
+ # >
435
452
# > Model BF
436
453
# > [lm2] Species + Petal.Length 3.45e+26
437
454
# > [lm3] Species * Sepal.Width 4.69e+07
438
455
# > [lm4] Species * Sepal.Width + Petal.Length + Petal.Width 7.58e+29
439
- # >
456
+ # >
440
457
# > * Against Denominator: [lm1] Species
441
458
# > * Bayes Factor Type: BIC approximation
442
459
```
0 commit comments