mr_Covar: Calculate covariate partial dependencies for mrIML JSDMs...

View source: R/mrCovar.R

mr_CovarR Documentation

Calculate covariate partial dependencies for mrIML JSDMs (Joint species distirbution models)

Description

This function calculates the covariate partial dependency plot for a specified environmental/host variable. It also filters the taxa based on standard deviation thresholds and visualizes the results.

Usage

mr_Covar(yhats, Y, X, X1, var, sdthresh = 0.05)

Arguments

yhats

A list of model predictions.

Y

The response data.

X

The predictor data.

X1

Additional predictor data excluding the variable of interest.

var

The variable of interest for calculating the profile.

sdthresh

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

Value

A plot displaying the covariate profile and change in probability for the specified 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) #
ModelPerf <- mrIMLperformance(yhats_rf, Model=model_rf, Y=Y, mode='classification')

covar <- mr_Covar(yhats, X=X,X1=X1, Y=Y, var='scale.prop.zos', sdthresh =0.01) #sdthrsh just plots taxa responding the most.

## End(Not run)

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