calculate_re: Calculate relative error

Description Usage Arguments Value Author(s) See Also Examples

View source: R/calculate_re.R

Description

Calculate the relative error (RE; [EM - OM]/OM) of parameters and derived quantities stored in a scalar or time series data frame generated by get_results_all.

Usage

1
calculate_re(dat, add = TRUE)

Arguments

dat

An input data frame. Should be either a scalar or time series data frame as returned from get_results_all or a related get results function. Specifically, the data frame needs to have columns with _em and _om as names.

add

Logical: should the relative error columns be added to dat or should the original EM and OM columns be dropped? If FALSE then the returned data frame will have only the identifying columns and the new relative error columns. You could then merge selected columns back into dat if you wished. The default is to return all columns.

Value

The default is to return a data frame structured the same as the input data frame, i.e., dat, but with additional columns, where '_re' is appended to the base string of the column name. All NAN and Inf values are returned as NA values, typically because you cannot divide by zero.

Author(s)

Sean Anderson and Cole Monnahan

See Also

get_results_all, link{get_results_scenario}

Examples

1
2
3
4
5
6
7
# Example with built in package data:
data("ts_dat", package = "ss3sim")
data("scalar_dat", package = "ss3sim")
head(calculate_re(ts_dat))
head(calculate_re(ts_dat, add = FALSE))
head(calculate_re(scalar_dat, add = FALSE))
rm("ts_dat", "scalar_dat")

ss3sim documentation built on Nov. 9, 2019, 1:06 a.m.