Summarise a model with statistics indicators

summarise_model(
  data,
  x = "x",
  y = "y",
  digits = NULL,
  direction = c("wide", "long"),
  extra = FALSE,
  .groups = "drop",
  ...
)

Arguments

data

A data frame to summarise

x

x variable name. Supports bare column names (e.g. x) and strings (e.g. "x").

y

y variable name. Supports bare column names (e.g. y) and strings (e.g. "y").

digits

integer indicating the number of decimal places (round) or significant digits (signif) to be used.

direction

the wide (default) or long format for the output

extra

summarise extra variables. FALSE in default.

.groups

Grouping structure passing to summarise function. "drop" in default.

...

other arguments passing to functions. Supporting arguments

  • nrmse_method: Method for nrmse

Value

A data frame with statistics indicators in columns including:

  • n: Number of rows

  • r: Coefficient of correlation

  • r2: Squared coefficient of correlation

  • bias: Average amount by which actual is greater than predicted

  • mse: Average squared difference

  • rmse: Root mean squared error

  • nrmse: Normalized root mean squared error

  • d: Willmott degree of agreement

  • error7day: Percentabe of errors less than 7 days if extra is TRUE

Examples

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
data <- data.frame(x = 1:10, y = 1:10 + runif(10))
data |> summarise_model()
#>    n         r        r2       bias       mse      rmse     nrmse         d
#> 1 10 0.9941612 0.9883565 -0.5720203 0.4232793 0.6505992 0.1182908 0.9871722
data |> summarise_model(x = x, y = y)
#>    n         r        r2       bias       mse      rmse     nrmse         d
#> 1 10 0.9941612 0.9883565 -0.5720203 0.4232793 0.6505992 0.1182908 0.9871722
data |> summarise_model(x = "x", y = "y")
#>    n         r        r2       bias       mse      rmse     nrmse         d
#> 1 10 0.9941612 0.9883565 -0.5720203 0.4232793 0.6505992 0.1182908 0.9871722
data |> summarise_model(digits = 2)
#>    n    r   r2  bias  mse rmse nrmse    d
#> 1 10 0.99 0.99 -0.57 0.42 0.65  0.12 0.99
# Export as long format
data |> summarise_model(digits = 2, direction = "long")
#> # A tibble: 8 × 2
#>   indicator value
#>   <chr>     <dbl>
#> 1 n         10   
#> 2 r          0.99
#> 3 r2         0.99
#> 4 bias      -0.57
#> 5 mse        0.42
#> 6 rmse       0.65
#> 7 nrmse      0.12
#> 8 d          0.99