mrBootstrap: Bootstrap mrIML model predictions

View source: R/mrBootstrap.R

mrBootstrapR Documentation

Bootstrap mrIML model predictions

Description

This function bootstraps model predictions and generates variable profiles for each response variable.

Usage

mrBootstrap(mrIMLobj, num_bootstrap = 10, downsample = FALSE)

Arguments

mrIMLobj

A list object output by mrIMLpredicts().

num_bootstrap

The number of bootstrap samples to generate (default: 10).

downsample

Logical. Should the bootstrap samples be downsampled? (default: FALSE).

Value

A list containing bootstrap samples of variable profiles for each response variable.

Examples


library(tidymodels)

data <- MRFcov::Bird.parasites
Y <- data %>%
  select(-scale.prop.zos) %>%
  select(order(everything()))
X <- data %>%
  select(scale.prop.zos)

# Specify a random forest tidy model
model_rf <- rand_forest(
  trees = 100, # 100 trees are set for brevity. Aim to start with 1000
  mode = "classification",
  mtry = tune(),
  min_n = tune()
) %>%
  set_engine("randomForest")

mrIML_rf <- mrIMLpredicts(
  X = X,
  Y = Y,
  X1 = Y,
  Model = model_rf,
  prop = 0.7,
  k = 5
)

#future::plan(multisession, workers = 4)

mrIML_bootstrap <- mrIML_rf %>%
  mrBootstrap(
    num_bootstrap = 50
  )


nfj1380/mrIML documentation built on June 2, 2025, 1:03 a.m.