csmp: Assess climate-sensitivity of model performance

Description Usage Arguments Value Author(s) Examples

View source: R/csmp.R

Description

Assess climate-sensitivity of model performance

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
csmp(
  airtemp,
  precip,
  objective,
  fixed_var = NULL,
  fixed_return = NULL,
  ref_airtemp = NULL,
  ref_precip = NULL,
  new_airtemp = NULL,
  new_precip = NULL,
  return_model = F,
  return_plot_df = F,
  return_plot = F,
  return_pred = F,
  airtemp_limits = c(-3, 1),
  precip_limits = c(250, 580),
  k_val = 3
)

Arguments

airtemp

Numeric vector of observed annual average air temperatures (°C)

precip

Numeric vector of observed annual average precipitation values (mm)

objective

Numeric vector of model objective function results (e.g., RMSE, NSE)

fixed_var

If desired, a variable to be used for a fixed effect. Should be a vector of observations of this effect that correspond to the positions of other vectors given to the function. This vector can be of class numeric, factor, or character.

fixed_return

If a fixed effect variable is provided, this should be a numeric value of the fixed effect variable that should be used to return answers. Must be a value from within the fixed effect variable vector. If not provided, will take first value in fixed_var

ref_airtemp

The reference value of air temperature (°C) in a historical average year. If not provided, will be set to mean of observed vector.

ref_precip

The reference value of precipitation (mm) in a historical average year. If not provided, will be set to mean of observed vector.

new_airtemp

The air temperature values (°C) to be used for comparison. If not supplied, will be set to the 5th and 95th percentiles of the range of observations. This should be a vector of length one (representing unidirectional climate change) or two (representing potential change in two directions - e.g., wetting or drying).

new_precip

The precipitation values (mm) for comparison. See notes for new_airtemp.

return_model

Should the function return the model object? This is useful for examining residuals, but could lead to large outputs.

return_plot_df

Should the function return a data frame that can be used to make a contour plot?

return_plot

Should the function return a contour plot showing the results? The plot returned is a ggplot() object and can be modified with additional calls to ggplot2 (see package readme).

return_pred

Should the function return predicted error for the supplied values of airtemp and precip?

airtemp_limits

Limits of range on which to predict air temp if returning plot_df

precip_limits

Limits of range on which to predict precip if returning plot_df

k_val

Number of knots to use in gam - equivalent to k in gam(). Defaults to 3.

Value

A list that may contain the following items, depending on input parameters:

Author(s)

Adrienne M. Marshall

Examples

1
2
3
4
5
6
7
airtemp <- rnorm(20, mean = 0, sd = 1)
precip <- rnorm(20, mean = 500, sd = 100)
objective <- rbeta(20, 1, 1)

ans <- csmp(airtemp, precip, objective, return_plot = TRUE)
ans$stats
ans$contour_plot

adrienne-marshall/csmp documentation built on Dec. 18, 2021, 10:30 p.m.