Skip to contents

Create reports for model comparison as obtained by the performance::compare_performance() function in the performance package.

Usage

# S3 method for compare_performance
report(x, ...)

# S3 method for compare_performance
report_table(x, ...)

# S3 method for compare_performance
report_statistics(x, table = NULL, ...)

# S3 method for compare_performance
report_parameters(x, table = NULL, ...)

# S3 method for compare_performance
report_text(x, table = NULL, ...)

Arguments

x

Object of class NEW OBJECT.

...

Arguments passed to or from other methods.

table

Provide the output of report_table() to avoid its re-computation.

Value

An object of class report().

Examples

# \donttest{
library(report)
library(performance)

m1 <- lm(Sepal.Length ~ Petal.Length * Species, data = iris)
m2 <- lm(Sepal.Length ~ Petal.Length + Species, data = iris)
m3 <- lm(Sepal.Length ~ Petal.Length, data = iris)

x <- performance::compare_performance(m1, m2, m3)
r <- report(x)
r
#> We compared three models; lm (R2 = 0.84, adj. R2 = 0.83, AIC = 106.77, BIC =
#> 127.84, RMSE = 0.33, Sigma = 0.34), lm (R2 = 0.84, adj. R2 = 0.83, AIC =
#> 106.23, BIC = 121.29, RMSE = 0.33, Sigma = 0.34) and lm (R2 = 0.76, adj. R2 =
#> 0.76, AIC = 160.04, BIC = 169.07, RMSE = 0.40, Sigma = 0.41).
summary(r)
#> We compared three models; lm (adj. R2 = 0.83, BIC = 127.84), lm (adj. R2 =
#> 0.83, BIC = 121.29) and lm (adj. R2 = 0.76, BIC = 169.07).
as.data.frame(r)
#> Name | Model | AIC (weights) | AICc (weights) | BIC (weights) |   R2 | R2 (adj.) | RMSE | Sigma
#> -----------------------------------------------------------------------------------------------
#> m1   |    lm |  106.8 (0.43) |   107.6 (0.39) |  127.8 (0.04) | 0.84 |      0.83 | 0.33 |  0.34
#> m2   |    lm |  106.2 (0.57) |   106.6 (0.61) |  121.3 (0.96) | 0.84 |      0.83 | 0.33 |  0.34
#> m3   |    lm | 160.0 (<.001) |  160.2 (<.001) | 169.1 (<.001) | 0.76 |      0.76 | 0.40 |  0.41
summary(as.data.frame(r))
#> Name | Model | AIC (weights) | AICc (weights) | BIC (weights) |   R2 | R2 (adj.) | RMSE
#> ---------------------------------------------------------------------------------------
#> m1   |    lm |  106.8 (0.43) |   107.6 (0.39) |  127.8 (0.04) | 0.84 |      0.83 | 0.33
#> m2   |    lm |  106.2 (0.57) |   106.6 (0.61) |  121.3 (0.96) | 0.84 |      0.83 | 0.33
#> m3   |    lm | 160.0 (<.001) |  160.2 (<.001) | 169.1 (<.001) | 0.76 |      0.76 | 0.40

# Specific reports
report_table(x)
#> Name | Model | AIC (weights) | AICc (weights) | BIC (weights) |   R2 | R2 (adj.) | RMSE | Sigma
#> -----------------------------------------------------------------------------------------------
#> m1   |    lm |  106.8 (0.43) |   107.6 (0.39) |  127.8 (0.04) | 0.84 |      0.83 | 0.33 |  0.34
#> m2   |    lm |  106.2 (0.57) |   106.6 (0.61) |  121.3 (0.96) | 0.84 |      0.83 | 0.33 |  0.34
#> m3   |    lm | 160.0 (<.001) |  160.2 (<.001) | 169.1 (<.001) | 0.76 |      0.76 | 0.40 |  0.41
report_statistics(x)
#> R2 = 0.84, adj. R2 = 0.83, AIC = 106.77, BIC = 127.84, RMSE = 0.33, Sigma = 0.34
#> R2 = 0.84, adj. R2 = 0.83, AIC = 106.23, BIC = 121.29, RMSE = 0.33, Sigma = 0.34
#> R2 = 0.76, adj. R2 = 0.76, AIC = 160.04, BIC = 169.07, RMSE = 0.40, Sigma = 0.41
report_parameters(x)
#>   - lm (R2 = 0.84, adj. R2 = 0.83, AIC = 106.77, BIC = 127.84, RMSE = 0.33, Sigma = 0.34)
#>   - lm (R2 = 0.84, adj. R2 = 0.83, AIC = 106.23, BIC = 121.29, RMSE = 0.33, Sigma = 0.34)
#>   - lm (R2 = 0.76, adj. R2 = 0.76, AIC = 160.04, BIC = 169.07, RMSE = 0.40, Sigma = 0.41)
# }