relate_env: Link abundances with environment

Description Usage Arguments Details Value Examples

View source: R/relate_env.R

Description

Link abundances with environment

Usage

1
2
3
4
5
6
7
8
9
relate_env(
  y,
  env,
  n = 3,
  tau = 0.75,
  min.node.size = 5,
  grid.resolution = 20,
  ...
)

Arguments

y

vector of the response variable: observed abundances/concentrations

env

data.frame or matrix of environmental variables associated with these observations

n

number of environmental variables to display, ordered in decreasing order of importance.

tau

quantile to predict. By default this is 0.75 in order to focus on the observations of large concentrations rather than on the mean; those observations are more relevant for HABs, where the most important cases are those featuring large abundances.

min.node.size

size of the nodes in the Random Forest trees. When this is large, this allows for more robust and smoother predictions; but making it too large just flattens the response curves.

grid.resolution

resolution of the grid for partial dependence plots. Making this larger gives more precise plots but is longer to compute.

...

passed to ranger::ranger()

Details

This function performs a quantile-based regression of the response variable on environmental variables using the Random Forest algorithm. Then it computes partial dependence plots depicting the univariate effect of the n most relevant variables.

Value

A ggplot2 plot, with one subplot per variable, ordered in decreasing order of importance (the percentage of "importance" is in the label of the subplot; this is the percentage of the part of the variance that the model explains which is attributable to that variable = sums to 100% for all variables, but that does not mean that the model explains 100% of the variance in the data of course).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library("dplyr")

# correlate raw benthic concentrations with a few variables
relate_env(ost$benthic, env=select(ost, chla, temperature, poc), n=3)

# correlate only non-zero, transformed concentrations
ost_present <- filter(ost, benthic > 0)
conc <- sqrt(ost_present$benthic)
env <- select(ost_present, chla, temperature, poc)
relate_env(conc, env, n=3)

# make a finer, but also more noisy, model
relate_env(conc, env, n=3, min.node.size=1, grid.resolution=50)

jiho/coclimer documentation built on July 26, 2020, 4:02 a.m.