#load example data
data(
vi_smol,
vi_predictors_numeric
)
##OPTIONAL: parallelization setup
# future::plan(
# future::multisession,
# workers = future::availableCores() - 1
# )
##OPTIONAL: progress bar
##does not work in R examples
# progressr::handlers(global = TRUE)
#ranking predictors from lower to higher multicollinearity
#------------------------------------------------
x <- preference_order(
df = vi_smol,
responses = NULL, #default value
predictors = vi_predictors_numeric[1:10],
f = NULL #must be explicit
)
x
#automatic selection of ranking function
#------------------------------------------------
x <- preference_order(
df = vi_smol,
responses = c("vi_numeric", "vi_categorical"),
predictors = vi_predictors_numeric[1:10],
f = f_auto
)
x
#user selection of ranking function
#------------------------------------------------
#Poisson GLM for a integer counts response
x <- preference_order(
df = vi_smol,
responses = "vi_binomial",
predictors = vi_predictors_numeric[1:10],
f = f_binomial_glm
)
x
#cross-validation
#------------------------------------------------
x <- preference_order(
df = vi_smol,
responses = "vi_binomial",
predictors = vi_predictors_numeric[1:10],
f = f_binomial_glm,
cv_training_fraction = 0.5,
cv_iterations = 10
)
x
#custom pairwise correlation function
#------------------------------------------------
#custom functions need the ellipsis argument
f_rsquared <- function(df, ...){
stats::cor(
x = df$x,
y = df$y,
use = "complete.obs"
)^2
}
x <- preference_order(
df = vi_smol,
responses = "vi_numeric",
predictors = vi_predictors_numeric[1:10],
f = f_rsquared
)
x
#resetting to sequential processing
#future::plan(future::sequential)
Run the code above in your browser using DataLab