Skip to content

The function generates residuals for all models in a tidyfit.models frame and outputs a tidy frame.

Usage

# S3 method for tidyfit.models
residuals(object, ...)

Arguments

object

model.frame created using regress, classify or m

...

currently not used

Value

A 'tibble'.

Details

The function uses the 'model_object' column in a tidyfit.model frame to return residuals for each model.

Author

Johann Pfitzinger

Examples

data <- dplyr::group_by(tidyfit::Factor_Industry_Returns, Industry)
fit <- regress(data, Return ~ ., m("lm"), .mask = "Date")
resid(fit)
#> # A tibble: 7,080 × 3
#> # Groups:   Industry, model [10]
#>    Industry model residual
#>    <chr>    <chr>    <dbl>
#>  1 Durbl    lm       0.719
#>  2 Durbl    lm      -0.270
#>  3 Durbl    lm       1.91 
#>  4 Durbl    lm       6.63 
#>  5 Durbl    lm      -4.52 
#>  6 Durbl    lm      -1.67 
#>  7 Durbl    lm      -2.50 
#>  8 Durbl    lm      -0.856
#>  9 Durbl    lm      -2.33 
#> 10 Durbl    lm       2.74 
#> # ℹ 7,070 more rows