Fits a hierarchical feature regression on a 'tidyFit' R6
class. The function can be used with regress
.
Arguments
- self
a 'tidyFit' R6 class.
- data
a data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr).
Details
Hyperparameters:
kappa (proportional size of regression graph)
Important method arguments (passed to m
)
The hierarchical feature regression is estimated using the hfr::cv.hfr
function. See ?cv.hfr
for more details.
Implementation
Features are standardized by default with coefficients transformed to the original scale.
If no hyperparameter grid is provided (is.null(control$kappa)
), the default is seq(0, 1, by = 0.1)
.
References
Pfitzinger J (2022). hfr: Estimate Hierarchical Feature Regression Models. R package version 0.5.0, https://CRAN.R-project.org/package=hfr.
Examples
# Load data
data <- tidyfit::Factor_Industry_Returns
# Stand-alone function
fit <- m("hfr", Return ~ ., data, kappa = 0.5)
fit
#> # A tibble: 1 × 5
#> estimator_fct `size (MB)` grid_id model_object settings
#> <chr> <dbl> <chr> <list> <list>
#> 1 hfr::cv.hfr 7.41 #001|001 <tidyFit> <tibble [1 × 1]>
# Within 'regress' function
fit <- regress(data, Return ~ ., m("hfr", kappa = c(0.1, 0.5)),
.mask = c("Date", "Industry"))
coef(fit)
#> # A tibble: 14 × 5
#> # Groups: model [1]
#> model term estimate grid_id model_info
#> <chr> <chr> <dbl> <chr> <list>
#> 1 hfr (Intercept) 0.0865 #001|001 <tibble [1 × 1]>
#> 2 hfr Mkt-RF 0.285 #001|001 <tibble [1 × 1]>
#> 3 hfr SMB -0.0114 #001|001 <tibble [1 × 1]>
#> 4 hfr HML 0.0117 #001|001 <tibble [1 × 1]>
#> 5 hfr RMW -0.0156 #001|001 <tibble [1 × 1]>
#> 6 hfr CMA 0.0171 #001|001 <tibble [1 × 1]>
#> 7 hfr RF 0.129 #001|001 <tibble [1 × 1]>
#> 8 hfr (Intercept) -0.000103 #001|002 <tibble [1 × 1]>
#> 9 hfr Mkt-RF 0.971 #001|002 <tibble [1 × 1]>
#> 10 hfr SMB 0.0176 #001|002 <tibble [1 × 1]>
#> 11 hfr HML 0.0681 #001|002 <tibble [1 × 1]>
#> 12 hfr RMW 0.126 #001|002 <tibble [1 × 1]>
#> 13 hfr CMA 0.0998 #001|002 <tibble [1 × 1]>
#> 14 hfr RF 1.04 #001|002 <tibble [1 × 1]>