Calculates Pearson's Chi-squared test on a 'tidyFit' R6
class. The function can be used with classify
.
Details
Hyperparameters:
None. Cross validation not applicable.
Important method arguments (passed to m
)
The function provides a wrapper for stats::chisq.test
. See ?chisq.test
for more details.
Implementation
Results can be viewed using coef
.
Examples
# Load data
data <- tidyfit::Factor_Industry_Returns
data <- dplyr::mutate_at(data, dplyr::vars(-Date, -Industry), dplyr::ntile, n = 10)
# Within 'classify' function
fit <- classify(data, Return ~ ., m("chisq"), .mask = c("Date", "Industry"))
tidyr::unnest(coef(fit), model_info)
#> # A tibble: 6 × 7
#> # Groups: model [1]
#> model term estimate statistic p.value parameter method
#> <chr> <chr> <lgl> <dbl> <dbl> <int> <chr>
#> 1 chisq Mkt-RF NA 8066. 0 81 Pearson's Chi-squar…
#> 2 chisq SMB NA 744. 8.35e-108 81 Pearson's Chi-squar…
#> 3 chisq HML NA 654. 1.87e- 90 81 Pearson's Chi-squar…
#> 4 chisq RMW NA 395. 6.68e- 43 81 Pearson's Chi-squar…
#> 5 chisq CMA NA 727. 1.65e-104 81 Pearson's Chi-squar…
#> 6 chisq RF NA 336. 8.84e- 33 81 Pearson's Chi-squar…