Fits a linear or logistic regression on a 'tidyFit' R6
class. The function can be used with regress
and classify
.
Details
Hyperparameters:
None. Cross validation not applicable.
Important method arguments (passed to m
)
The function provides a wrapper for stats::glm
. See ?glm
for more details.
Implementation
No implementation notes
Examples
# Load data
data <- tidyfit::Factor_Industry_Returns
data$Return <- ifelse(data$Return > 0, 1, 0)
# Stand-alone function
fit <- m("glm", Return ~ ., data)
fit
#> # A tibble: 1 × 5
#> estimator_fct `size (MB)` grid_id model_object settings
#> <chr> <dbl> <chr> <list> <list>
#> 1 stats::glm 5.44 #0010000 <tidyFit> <tibble [1 × 1]>
# Within 'classify' function
fit <- classify(data, Return ~ ., m("glm"), .mask = c("Date", "Industry"))
coef(fit)
#> # A tibble: 7 × 4
#> # Groups: model [1]
#> model term estimate model_info
#> <chr> <chr> <dbl> <list>
#> 1 glm (Intercept) 0.0363 <tibble [1 × 3]>
#> 2 glm Mkt-RF 0.584 <tibble [1 × 3]>
#> 3 glm SMB 0.0211 <tibble [1 × 3]>
#> 4 glm HML 0.0361 <tibble [1 × 3]>
#> 5 glm RMW 0.155 <tibble [1 × 3]>
#> 6 glm CMA 0.104 <tibble [1 × 3]>
#> 7 glm RF 0.332 <tibble [1 × 3]>