| ordered-package | R Documentation |
ordered provides engines for ordinal regression models for the parsnip package. The models may have cumulative, sequential, or adjacent-category structure, and in future these may be disaggregated into separate model types. A vignette will provide thorough illustrations of ordered functionality. See below for examples of fitting ordinal regression models with ordered.
Maintainer: Jason Cory Brunson cornelioid@gmail.com (ORCID)
Authors:
Jason Cory Brunson cornelioid@gmail.com (ORCID)
Max Kuhn max@posit.co (ORCID)
Other contributors:
Posit Software PBC [copyright holder]
Useful links:
if (rlang::is_installed("MASS")) {
# Weighted sample
set.seed(561246)
house_sub <- MASS::housing %>%
dplyr::sample_n(size = 120, replace = TRUE, weight = Freq) %>%
subset(select = -Freq)
train_inds <- sample(120, 80)
house_train <- house_sub[train_inds, ]
house_test <- house_sub[-train_inds, ]
# Cumulative-link proportional-odds probit regression model
fit_cpop <- ordinal_reg() %>%
set_engine("polr") %>%
set_args(ordinal_link = "probit") %>%
fit(Sat ~ Infl + Type + Cont, data = house_train)
predict(fit_cpop, house_test, type = "prob")
if (rlang::is_installed("ordinalForest")) {
# Ordinal forest
fit_orf <- rand_forest(mode = "classification") %>%
set_engine("ordinalForest") %>%
set_args(nsets = 50, trees = 100, perffunction = "probability") %>%
fit(Sat ~ Infl + Type + Cont, data = house_train)
predict(fit_orf, house_test, type = "prob")
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.