Summarise a model with statistics indicators

model_summarise(
  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

y

y variable name

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 %>% model_summarise()
#>    n         r        r2       bias       mse      rmse      nrmse         d
#> 1 10 0.9959883 0.9919927 -0.4439794 0.2771491 0.5264495 0.09571809 0.9919352
data %>% model_summarise(digits = 2)
#>    n r   r2  bias  mse rmse nrmse    d
#> 1 10 1 0.99 -0.44 0.28 0.53   0.1 0.99
# Export as long format
data %>% model_summarise(digits = 2, direction = "long")
#> # A tibble: 8 × 2
#>   indicator value
#>   <chr>     <dbl>
#> 1 n         10   
#> 2 r          1   
#> 3 r2         0.99
#> 4 bias      -0.44
#> 5 mse        0.28
#> 6 rmse       0.53
#> 7 nrmse      0.1 
#> 8 d          0.99