mrCovar: Investigate partial dependencies of a covariate for mrIML...

View source: R/mrCovar.R

mrCovarR Documentation

Investigate partial dependencies of a covariate for mrIML JSDMs (Joint Species Distribution Models)

Description

This function is a wrapper around mrFlashlight() that plots the covariate partial dependencies for a specified environmental/host variable. It also filters the taxa based on standard deviation thresholds.

Usage

mrCovar(mrIMLobj, var, sdthresh = 0.05, ...)

Arguments

mrIMLobj

A list object output by mrIMLpredicts().

var

The variable of interest for calculating the profile.

sdthresh

The standard deviation threshold for filtering taxa (default: 0.05).

...

Arguments passed to flashlight::light_profile()

Value

A list of figures:

  • ⁠$partial_dep_curves⁠: The covariate partial dependence profiles for those models that meet the sdthresh requirement.

  • ⁠$partial_dep_avg⁠: The average partial dependence profile for all models. All individual model partial dependence profiles are silhouetted in the background.

  • ⁠$partial_dep_diff⁠: The distribution of the rates of change in probability for the specified variable (the derivatives of the PD curves). Useful to identify key threshold values in the variable.

Examples

library(tidymodels)

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

model_rf <- rand_forest(
  trees = 50, # 50 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 = 2,
  racing = FALSE
)

mrIML_rf %>%
  mrCovar(var = "scale.prop.zos", sdthresh = 0.05)


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