mrBootstrap: Bootstrap model predictions

View source: R/MrBootstrap.R

mrBootstrapR Documentation

Bootstrap model predictions

Description

This function bootstraps model predictions and generates variable profiles for each response variable based on the provided yhats.

Usage

mrBootstrap(yhats, num_bootstrap = 10, Y = Y, downsample = FALSE)

Arguments

yhats

A list of model predictions mrIMLpredicts

num_bootstrap

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

Y

The response data (default: Y).

downsample

Do the bootstrap samples need to be downsampled? Default is FALSE

Value

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

Examples

## Not run: 
# Example usage:
#set up analysis
Y <- dplyr::select(Bird.parasites, -scale.prop.zos)%>% 
dplyr::select(sort(names(.)))#response variables eg. SNPs, pathogens, species....
X <- dplyr::select(Bird.parasites, scale.prop.zos) # feature set
X1 <- Y %>%
dplyr::select(sort(names(.)))
model_rf <- 
rand_forest(trees = 100, mode = "classification", mtry = tune(), min_n = tune()) %>% #100 trees are set for brevity. Aim to start with 1000
set_engine("randomForest")
yhats_rf <- mrIMLpredicts(X=X, Y=Y,
X1=X1,'Model=model_rf , 
balance_data='no',mode='classification',
tune_grid_size=5,seed = sample.int(1e8, 1),'morans=F,
prop=0.7, k=5, racing=T) #

bs_analysis <- mrBootstrap(yhats=yhats_rf,Y=Y, num_bootstrap = 50)

## End(Not run) 

nfj1380/mrIML documentation built on May 17, 2024, 7:41 a.m.