The function generates predictions for all models in a tidyfit.models
frame and outputs a tidy frame.
Usage
# S3 method for class 'tidyfit.models'
predict(object, newdata, ..., .keep_grid_id = FALSE)
Arguments
Details
The function uses the 'model_object' column in a tidyfit.model
frame to return predictions using the newdata
argument for each model.
When the response variable is found in newdata
, it is automatically included as a 'truth' column.
Examples
data <- dplyr::group_by(tidyfit::Factor_Industry_Returns, Industry)
fit <- regress(data, Return ~ ., m("lm"), .mask = "Date")
predict(fit, data)
#> # A tibble: 7,080 × 4
#> # Groups: Industry, model [10]
#> Industry model prediction truth
#> <chr> <chr> <dbl> <dbl>
#> 1 Durbl lm -0.939 -0.22
#> 2 Durbl lm 6.82 6.55
#> 3 Durbl lm -2.15 -0.24
#> 4 Durbl lm 3.09 9.72
#> 5 Durbl lm -0.317 -4.84
#> 6 Durbl lm 1.94 0.27
#> 7 Durbl lm 3.69 1.19
#> 8 Durbl lm 3.00 2.14
#> 9 Durbl lm 3.26 0.93
#> 10 Durbl lm -0.814 1.93
#> # ℹ 7,070 more rows