Skip to content

Performs Analysis of Variance on a 'tidyFit' R6 class. The function can be used with regress or classify.

Usage

# S3 method for class 'anova'
.fit(self, data = NULL)

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).

Value

A fitted 'tidyFit' class model.

Details

Hyperparameters:

None. Cross validation not applicable.

Important method arguments (passed to m)

The function provides a wrapper for stats::anova. See ?anova for more details.

First a glm model is fitted which is passed to anova.

See also

.fit.lm, .fit.glm and m methods

Author

Johann Pfitzinger

Examples

# Load data
data <- tidyfit::Factor_Industry_Returns

# Stand-alone function
fit <- m("anova", Return ~ `Mkt-RF` + HML + SMB, data)
fit
#> # A tibble: 1 × 5
#>   estimator_fct `size (MB)` grid_id  model_object settings        
#>   <chr>               <dbl> <chr>    <list>       <list>          
#> 1 stats::anova      0.00186 #0010000 <tidyFit>    <tibble [1 × 1]>

# Within 'regress' function
fit <- regress(data, Return ~ ., m("anova"), .mask = c("Date", "Industry"))
tidyr::unnest(coef(fit), model_info)
#> # A tibble: 7 × 6
#> # Groups:   model [1]
#>   model term      df deviance df.residual residual.deviance
#>   <chr> <chr>  <int>    <dbl>       <int>             <dbl>
#> 1 anova NULL      NA     NA          7079           198728.
#> 2 anova Mkt-RF     1 122219.         7078            76509.
#> 3 anova SMB        1     19.7        7077            76489.
#> 4 anova HML        1    896.         7076            75593.
#> 5 anova RMW        1    612.         7075            74981.
#> 6 anova CMA        1    172.         7074            74809.
#> 7 anova RF         1    505.         7073            74303.