tidyfit.models
frameR/coef.tidyfit.models.R
coef.tidyfit.models.Rd
The function extracts and prepares coefficients from all models in a tidyfit.models
frame and outputs a tidy frame of estimates.
# S3 method for class 'tidyfit.models'
coef(
object,
...,
.add_bootstrap_interval = FALSE,
.bootstrap_alpha = 0.05,
.keep_grid_id = FALSE
)
currently not used
calculate bootstrap intervals for the parameters. See 'Details'.
confidence level used for the bootstrap interval. Default is .bootstrap_alpha = 0.05
.
boolean. By default the grid ID column is dropped, if there is only one unique setting per model or group. .keep_grid_id = TRUE
ensures that the column is never dropped.
A 'tibble'.
The function uses the 'model_object' column in a tidyfit.model
frame to return a data frame of estimated coefficients.
Results are 'tidied' using broom::tidy
whenever possible.
All coefficients are transformed to ensure statistical comparability. For instance, standardized coefficients are always transformed back to the original data scale, naming conventions are harmonized etc.
Bootstrap intervals can be calculated using rsample::int_pctl
. Only set .add_bootstrap_interval = TRUE
if you are using .cv = "bootstraps"
in combination with .return_slices = TRUE
to generate the model frame.
data <- tidyfit::Factor_Industry_Returns
fit <- regress(data, Return ~ ., m("lm"), .mask = c("Date", "Industry"))
coef(fit)
#> # A tibble: 7 × 4
#> # Groups: model [1]
#> model term estimate model_info
#> <chr> <chr> <dbl> <list>
#> 1 lm (Intercept) -0.0312 <tibble [1 × 3]>
#> 2 lm Mkt-RF 0.977 <tibble [1 × 3]>
#> 3 lm SMB 0.0182 <tibble [1 × 3]>
#> 4 lm HML 0.0605 <tibble [1 × 3]>
#> 5 lm RMW 0.164 <tibble [1 × 3]>
#> 6 lm CMA 0.117 <tibble [1 × 3]>
#> 7 lm RF 1.00 <tibble [1 × 3]>