Package 'trps'

Title: Bayesian trophic position models using stan
Description: Bayesian trophic position models using stan by leveraging 'brms' for stable isotope data. Trophic position models are derived by using equations from Post (2002) <doi:10.1890/0012-9658(2002)083[0703:USITET]2.0.CO;2>, and Huevel et al. (2024) <doi:10.1139/cjfas-2024-0028>.
Authors: Benjamin L. Hlina [aut, cre]
Maintainer: Benjamin L. Hlina <[email protected]>
License: CC0
Version: 0.1.0
Built: 2025-03-15 02:24:47 UTC
Source: https://github.com/benjaminhlina/trps

Help Index


Calculate and add α\alpha

Description

Calculate α\alpha for a two source trophic position model using equations from Post 2002.

Usage

add_alpha(data, abs = FALSE)

Arguments

data

data.frame of stable isotope samples with mean values for two baselines. For aquatic ecosystems, baseline one needs to come from a benthic source and baseline two needs to come from a pelagic source. Baseline δ13\delta^{13}C columns need to be named c1 and c2, with the consumer's δ13\delta^{13}C column named d13c.

abs

logical that controls whether the absolute value is taken for the numerator and denominator. Default is FALSE meaning that the absolute value is not taken.

Details

α=(δ13Ccδ13C2)/(δ13C1δ13C2)\alpha = (\delta^{13}C_c - \delta ^{13}C_2) / (\delta ^{13}C_1 - \delta ^{13}C_2)

where δ13Cc\delta^{13}C_c is the isotopic value for consumer, δ13C1\delta^{13}C_1 is the mean isotopic value for baseline 1 and δ13C2\delta^{13}C_2 is the mean isotopic value for baseline 2.

Value

a data.frame that has alpha, min_alpha, and max_alpha added.

Examples

combined_iso |>
  add_alpha()

Stable isotope data for amphipods (baseline 1)

Description

Stable isotope data (δ13\delta^{13}C and δ15\delta^{15}N) for amphipods collected from an ecoregion in Lake Ontario.

Usage

baseline_1_iso

Format

data.frame containing 14 rows and 5 variables

common_name

name of the spcies (i.e., Amphipoda)

ecoregion

ecoregion where samples were collected

d13c_b1

observed values for δ13\delta^{13}C

d15n_b1

observed values for δ15\delta^{15}N


Stable isotope data for dreissenids (baseline 2)

Description

Stable isotope data (δ13\delta^{13}C and δ15\delta^{15}N) for dreissenid collected from an ecoregion in Lake Ontario.

Usage

baseline_2_iso

Format

data.frame containing 12 rows and 5 variables

common_name

name of the spcies (i.e., Dreissenids)

ecoregion

ecoregion where samples were collected

d13c_b2

observed values for δ13\delta^{13}C

d15n_b2

observed values for δ15\delta^{15}N


Stable isotope data for lake trout, amphipods (benthic baseline; baseline 1) and dreissenids (pelagic baseline; baseline 2),

Description

Stable isotope data (δ13\delta^{13}C and δ15\delta ^{15}N) for lake trout collected from two ecoregions in Lake Ontario. Values of δ13\delta ^{13}C and δ15\delta ^{15}N for a benthic baseline (amphipods; baseline 1; d13c_b1 and d15n_b1) and pelagic baseline (dreissenids; baseline 2; d13c_b2 and d15n_b2) with the means for each baseline calculated (c1, n1, c2, and n2).

Usage

combined_iso

Format

data.frame containing 117 rows and 13 variables

id

row id number

common_name

name of the spcies (i.e., Lake Trout)

ecoregion

ecoregion where samples were collected

d13c

observed values for δ13\delta^{13}C of consumer

d15n

observed values for δ15\delta^{15}N of consumer

d13c_b1

observed values for δ13\delta^{13}C of baseline 1

d15n_b1

observed values for δ15\delta^{15}N of baseline 1

d13c_b2

observed values for δ13\delta^{13}C of baseline 2

d15n_b2

observed values for δ15\delta^{15}N of baseline 2

c1

mean values for δ13\delta^{13}C of baseline 1

n1

mean values for δ15\delta^{15}N of baseline 1

c2

mean values for δ13\delta^{13}C of baseline 2

n2

mean values for δ15\delta^{15}N of baseline 2


Stable isotope data for lake trout (consumer)

Description

Stable isotope data (δ13\delta^{13}C and δ15\delta^ {15}N) for lake trout collected from an ecoregion in Lake Ontario.

Usage

consumer_iso

Format

data.frame containing 30 rows and 6 variables

common_name

name of the spcies (i.e., Lake Trout)

ecoregion

ecoregion where samples were collected

d13c

observed values for δ13\delta^{13}C

d15n

observed values for δ15\delta^{15}N


Bayesian model - One Source Trophic Position

Description

Estimate trophic position using a one source model derived from Post 2002 using a Bayesian framework.

Usage

one_source_model(bp = FALSE)

Arguments

bp

logical value that controls whether informed priors are supplied to the model for δ15\delta^{15}N baseline. Default is FALSE meaning the model will use uninformed priors, however, the supplied data.frame needs values for δ15\delta^{15}N baseline (n1).

Details

δ15N=δ15N1+ΔN×(tpλ1)\delta^{15}N = \delta^{15} N_1 + \Delta N \times (tp - \lambda_1)

δ15\delta^{15}N are values from the consumer, δ15N1\delta^{15} N_1 is mean δ15\delta^{15}N values of baseline 1, Δ\DeltaN is the trophic discrimination factor for N (i.e., dn mean of 3.4), tptp is trophic position, and λ1\lambda_1 is the trophic level of baselines which are often a primary consumer (e.g., 2).

The data supplied to brms() needs to have the following variables d15n, n1, and l1 (λ\lambda) which is usually 2.

Value

returns model structure for one source model to be used in a brms() call.

See Also

brms::brms()

Examples

one_source_model()

Bayesian priors - One Source Trophic Position

Description

Create priors for one source trophic position model derived from Post 2002.

Usage

one_source_priors(bp = FALSE)

Arguments

bp

logical value that controls whether informed priors are supplied to the model for δ15\delta^{15}N baseline. Default is FALSE meaning the model will use uninformed priors, however, the supplied data.frame needs values for δ15\delta^{15}N baseline (n1).

Value

returns priors for one source model to be used in a brms() call.

See Also

brms::brms()

Examples

one_source_priors()

Adjust Bayesian priors - One Source Trophic Position

Description

Adjust priors for one source trophic position model derived from Post 2002.

Usage

one_source_priors_params(
  n1 = NULL,
  n1_sigma = NULL,
  dn = NULL,
  dn_sigma = NULL,
  tp_lb = NULL,
  tp_ub = NULL,
  sigma_lb = NULL,
  sigma_ub = NULL,
  bp = FALSE
)

Arguments

n1

mean (μ\mu) prior for the mean δ15\delta^{15}N baseline. Defaults to 9.

n1_sigma

variance (σ\sigma) for the mean δ15\delta^{15}N baseline. Defaults to 1.

dn

mean (μ\mu) prior value for Δ\DeltaN. Defaults to 3.4.

dn_sigma

variance (σ\sigma) for δ15\delta^{15}N. Defaults to 0.25.

tp_lb

lower bound prior for trophic position. Defaults to 2.

tp_ub

upper bound prior for trophic position. Defaults to 10.

sigma_lb

lower bound prior for σ\sigma. Defaults to 0.

sigma_ub

upper bound prior for σ\sigma. Defaults to 10.

bp

logical value that controls whether informed priors are supplied to the model for δ15\delta^{15}N baseline. Default is FALSE meaning the model will use uninformed priors, however, the supplied data.frame needs values for δ15\delta^{15}N baseline (n1).

Details

δ15N=δ15N1+δN×(tpλ1)\delta^{15}N = \delta^{15} N_1 + \delta N \times (tp - \lambda_1)

This function allows the user to adjust the priors for the following variables in the equation above:

  • The mean (n1; μ\mu) and variance (n1_sigma; σ\sigma) for the mean δ15\delta^{15}N for a given baseline (δ15N1\delta^{15}N_1). This prior assumes a normal distribution.

  • The mean (dn; μ\mu) and variance (dn_sigma; σ\sigma) of Δ\DeltaN (i.e, trophic enrichment factor). This prior assumes a normal distribution.

  • The lower (tp_lb) and upper (tp_ub) bounds for trophic position. This prior assumes a uniform distribution.

  • The lower (sigma_lb) and upper (sigma_ub) bounds for variance (σ\sigma). This prior assumes a uniform distribution.

Value

stanvars object to be used with brms() call.

See Also

one_source_priors(), one_source_model(), and brms::brms()

Examples

one_source_priors_params()

Bayesian model - Two Source Trophic Position

Description

Trophic position using a two source model derived from Post 2002 using a Bayesian framework.

Usage

two_source_model(bp = FALSE, lambda = NULL)

Arguments

bp

logical value that controls whether informed priors are supplied to the model for both δ15\delta^{15}N and δ15\delta^{15}C baselines. Default is FALSE meaning the model will use uninformed priors, however, the supplied data.frame needs values for both δ15\delta^{15}N and δ15\delta^{15}C baseline (c1, c2, n1, and n2).

lambda

numerical value, 1 or 2, that controls whether one or two λ\lambdas are used. See details for equations and when to use 1 or 2. Defaults to 1.

Details

We will use the following equations from Post 2002:

  1. δ13Cc=α×(δ13C1δ13C2)+δ13C2\delta^{13}C_c = \alpha \times (\delta ^{13}C_1 - \delta ^{13}C_2) + \delta ^{13}C_2

  2. δ15N=ΔN×(tpλ1)+n1×α+n2×(1α)\delta^{15}N = \Delta N \times (tp - \lambda_1) + n_1 \times \alpha + n_2 \times (1 - \alpha)

  3. δ15N=ΔN×(tp(λ1×α+λ2×(1α)))+n1×α+n2×(1α)\delta^{15}N = \Delta N \times (tp - (\lambda_1 \times \alpha + \lambda_2 \times (1 - \alpha))) + n_1 \times \alpha + n_2 \times (1 - \alpha)

For equation 1)

where δ13Cc\delta^{13}C_c is the isotopic value for consumer, α\alpha is the ratio between baselines and consumer δ13C\delta^{13}C, δ13C1\delta^{13}C_1 is the mean isotopic value for baseline 1, and δ13C2\delta^{13}C_2 is the mean isotopic value for baseline 2

For equation 2) and 3)

δ15\delta^{15}N are values from the consumer, n1n_1 is δ15\delta^{15}N values of baseline 1, n2n_2 is δ15\delta^{15}N values of baseline 2, Δ\DeltaN is the trophic discrimination factor for N (i.e., mean of 3.4), tp is trophic position, and λ1\lambda_1 and/or λ2\lambda_2 are the trophic levels of baselines which are often a primary consumer (e.g., 2 or 2.5).

The data supplied to brms() when using baselines at the same trophic level (lambda argument set to 1) needs to have the following variables, d15n, c1, c2, n1, n2, l1 (λ1\lambda_1) which is usually 2. If using baselines at different trophic levels (lambda argument set to 2) the data frame needs to have l1 and l2 with a numerical value for each trophic level (e.g.,2 and 2.5; λ1\lambda_1 and λ2\lambda_2).

Value

returns model structure for two source model to be used in a brms() call.

See Also

brms::brms()

Examples

two_source_model()

Bayesian model - Two Source Trophic Position with αr\alpha_r

Description

Estimate trophic position using a two source model with αr\alpha_r derived from Post 2002 and Heuvel et al. 2024 using a Bayesian framework.

Usage

two_source_model_ar(bp = FALSE, lambda = NULL)

Arguments

bp

logical value that controls whether informed priors are supplied to the model for both δ15\delta^{15}N baselines. Default is FALSE meaning the model will use uninformed priors, however, the supplied data.frame needs values for both δ15\delta^{15}N baseline (n1 and n2).

lambda

numerical value, 1 or 2, that controls whether one or two lambdas are used. See details for equations and when to use 1 or 2. Defaults to 1.

Details

We will use the following equations derived from Post 2002 and Heuvel et al. 2024:

  1. α=(δ13Ccδ13C2)/(δ13C1δ13C2)\alpha = (\delta^{13} C_c - \delta ^{13}C_2) / (\delta ^{13}C_1 - \delta ^{13}C_2)

  2. α=αr×(αmaxαmin)+αmin\alpha = \alpha_r \times (\alpha_{max} - \alpha_{min}) + \alpha_{min}

  3. δ15N=ΔN×(tpλ1)+n1×αr+n2×(1αr)\delta^{15}N = \Delta N \times (tp - \lambda_1) + n_1 \times \alpha_r + n_2 \times (1 - \alpha_r)

  4. δ15N=ΔN×(tp(λ1×αr+λ2×(1αr)))+n1×αr+n2×(1αr)\delta^{15}N = \Delta N \times (tp - (\lambda_1 \times \alpha_r + \lambda_2 \times (1 - \alpha_r))) + n_1 \times \alpha_r + n_2 \times (1 - \alpha_r)

For equation 1)

This equation is a carbon source mixing model with δ13Cc\delta^{13}C_c is the isotopic value for consumer, δ13C1\delta^{13}C_1 is the mean isotopic value for baseline 1 and δ13C2\delta^{13}C_2 is the mean isotopic value for baseline 2. This equation is added to the data frame using add_alpha().

For equation 2)

α\alpha is being corrected using equations in Heuvel et al. 2024 with αr\alpha_r being the corrected value (bound by 0 and 1), αmin\alpha_{min} is the minimum α\alpha value calculated using add_alpha() and αmax\alpha_{max} being the maximum α\alpha value calculated using add_alpha().

For equation 3) and 4)

δ15\delta^{15}N are values from the consumer, n1n_1 is δ15\delta^{15}N values of baseline 1, n2n_2 is δ15\delta^{15}N values of baseline 2, Δ\DeltaN is the trophic discrimination factor for N (i.e., mean of 3.4), tp is trophic position, and λ1\lambda_1 and/or λ2\lambda_2 are the trophic levels of baselines which are often a primary consumer (e.g., 2 or 2.5).

The data supplied to brms() when using baselines at the same trophic level (lambda argument set to 1) needs to have the following variables, d15n, n1, n2, l1 (λ1\lambda_1) which is usually 2. If using baselines at different trophic levels (lambda argument set to 2) the data frame needs to have l1 and l2 with a numerical value for each trophic level (e.g., 2 and 2.5; λ1\lambda_1 and λ2\lambda_2).

Value

returns model structure for two source model to be used in a brms() call.

See Also

brms::brms()

Examples

two_source_model_ar()

Bayesian model - Two Source Trophic Position with αr\alpha_r and carbon mixing model

Description

Estimate trophic position using a two source model with αr\alpha_r derived from Post 2002 and Heuvel et al. 2024 using a Bayesian framework.

Usage

two_source_model_arc(bp = FALSE, lambda = NULL)

Arguments

bp

logical value that controls whether informed priors are supplied to the model for both δ15\delta^{15}N and δ15\delta^{15}C baselines. Default is FALSE meaning the model will use uninformed priors, however, the supplied data.frame needs values for both δ15\delta^{15}N and δ15\delta^{15}C baseline (c1, c2, n1, and n2).

lambda

numerical value, 1 or 2, that controls whether one or two lambdas are used. See details for equations and when to use 1 or 2. Defaults to 1.

Details

We will use the following equations derived from Post 2002 and Heuvel et al. 2024:

  1. α=(δ13Ccδ13C2)/(δ13C1δ13C2)\alpha = (\delta^{13} C_c - \delta ^{13}C_2) / (\delta ^{13}C_1 - \delta ^{13}C_2)

  2. α=αr×(αmaxαmin)+αmin\alpha = \alpha_r \times (\alpha_{max} - \alpha_{min}) + \alpha_{min}

  3. δ13C=c1×αc+c2×(1αc)\delta^{13}C = c_1 \times \alpha_c + c_2 \times (1 - \alpha_c)

  4. δ15N=ΔN×(tpλ1)+n1×αc+n2×(1αc)\delta^{15}N = \Delta N \times (tp - \lambda_1) + n_1 \times \alpha_c + n_2 \times (1 - \alpha_c)

  5. δ15N=ΔN×(tp(λ1×αc+λ2×(1αc)))+n1×αc+n2×(1αc)\delta^{15}N = \Delta N \times (tp - (\lambda_1 \times \alpha_c + \lambda_2 \times (1 - \alpha_c))) + n_1 \times \alpha_c + n_2 \times (1 - \alpha_c)

For equation 1)

This equation is a carbon source mixing model with δ13Cc\delta^{13}C_c is the isotopic value for consumer, δ13C1\delta^{13}C_1 is the mean isotopic value for baseline 1 and δ13C2\delta^{13}C_2 is the mean isotopic value for baseline 2.

For equation 2)

α\alpha is being corrected using equations in Heuvel et al. 2024. with αr\alpha_r being the corrected value (bound by 0 and 1), αmin\alpha_{min} is the minimum α\alpha value calculated using add_alpha() and αmax\alpha_{max} being the maximum α\alpha value calculated using add_alpha().

For equation 3)

This equation is a carbon source mixing model with δ13\delta^{13}C being estimated using c_1, c_2 and αc\alpha_c calculated in equation 1.

For equation 4) and 5)

δ15\delta^{15}N are values from the consumer, n1n_1 is δ15\delta^{15}N values of baseline 1, n2n_2 is δ15\delta^{15}N values of baseline 2, Δ\DeltaN is the trophic discrimination factor for N (i.e., mean of 3.4), tp is trophic position, and λ1\lambda_1 and/or λ2\lambda_2 are the trophic levels of baselines which are often a primary consumer (e.g., 2 or 2.5).

The data supplied to brms() when using baselines at the same trophic level (lambda argument set to 1) needs to have the following variables, d15n, n1, n2, l1 (λ1\lambda_1) which is usually 2. If using baselines at different trophic levels (lambda argument set to 2) the data frame needs to have l1 and l2 with a numerical value for each trophic level (e.g., 2 and 2.5; λ1\lambda_1 and λ2\lambda_2).

Value

returns model structure for two source model to be used in a brms() call.

See Also

brms::brms()

Examples

two_source_model_arc()

Bayesian priors - Two Source Trophic Position

Description

Create priors for two source trophic position model derived from Post 2002.

Usage

two_source_priors(bp = FALSE)

Arguments

bp

logical value that controls whether informed priors are supplied to the model for both δ15\delta^{15}N and δ15\delta^{15}C baselines. Default is FALSE meaning the model will use uninformed priors, however, the supplied data.frame needs values for both δ15\delta^{15}N and δ15\delta^{15}C baseline (c1, c2, n1, and n2).

Value

returns priors for two source model to be used in a brms() call.

See Also

two_source_model() and brms::brms()

Examples

two_source_priors()

Bayesian priors - Two Source Trophic Position with αr\alpha_r

Description

Create priors for trophic position using a two source model with αr\alpha_r derived from Post 2002 and Heuvel et al. 2024.

Usage

two_source_priors_ar(bp = FALSE)

Arguments

bp

logical value that controls whether informed priors are supplied to the model for δ15\delta^{15}N baselines. Default is FALSE meaning the model will use uninformed priors, however, the supplied data.frame needs values for both δ15\delta^{15}N baseline (n1, and n2).

Value

returns priors for two source model to be used in a brms() call.

See Also

brms::brms()

Examples

two_source_priors_ar()

Bayesian priors - Two Source Trophic Position with αr\alpha_r and carbon mixing model

Description

Create priors for trophic position using a two source model with αr\alpha_r derived from Post 2002 and Heuvel et al. 2024.

Usage

two_source_priors_arc(bp = FALSE)

Arguments

bp

logical value that controls whether informed priors are supplied to the model for both δ15\delta^{15}N and δ15\delta^{15}C baselines. Default is FALSE meaning the model will use uninformed priors, however, the supplied data.frame needs values for both δ15\delta^{15}N and δ15\delta^{15}C baseline (c1, c2, n1, and n2).

Value

returns priors for two source model to be used in a brms() call.

See Also

brms::brms()

Examples

two_source_priors_arc()

Adjust Bayesian priors - Two Source Trophic Position

Description

Adjust priors for two source trophic position model derived from Post 2002.

Usage

two_source_priors_params(
  a = NULL,
  b = NULL,
  c1 = NULL,
  c1_sigma = NULL,
  c2 = NULL,
  c2_sigma = NULL,
  n1 = NULL,
  n1_sigma = NULL,
  n2 = NULL,
  n2_sigma = NULL,
  dn = NULL,
  dn_sigma = NULL,
  tp_lb = NULL,
  tp_ub = NULL,
  sigma_lb = NULL,
  sigma_ub = NULL,
  bp = FALSE
)

Arguments

a

(α\alpha) exponent of the random variable for beta distribution. Defaults to 1. See beta distribution for more information.

b

(β\beta) shape parameter for beta distribution. Defaults to 1. See beta distribution for more information.

c1

mean (μ\mu) prior for the mean of the first δ13\delta^{13}C baseline. Defaults to -21.

c1_sigma

variance (σ\sigma)for the mean of the first δ13\delta^{13}C baseline. Defaults to 1.

c2

mean (μ\mu) prior for or the mean of the second δ13\delta^{13}C baseline. Defaults to -26.

c2_sigma

variance (σ\sigma)for the mean of the first δ13\delta^{13}C baseline. Defaults to 1.

n1

mean (μ\mu) prior for the mean of the first δ15\delta^{15}N baseline. Defaults to 8.

n1_sigma

variance (σ\sigma)for the mean of the first δ15\delta^{15}N baseline. Defaults to 1.

n2

mean (μ\mu) prior for or the mean of the second δ15\delta^{15}N baseline. Defaults to 9.5.

n2_sigma

variance (σ\sigma) for the mean of the second δ15\delta^{15}N baseline. Defaults to 1.

dn

mean (μ\mu) prior value for Δ\DeltaN. Defaults to 3.4.

dn_sigma

variance (σ\sigma) for δ15\delta^{15}N. Defaults to 0.5.

tp_lb

lower bound for priors for trophic position. Defaults to 2.

tp_ub

upper bound for priors for trophic position. Defaults to 10.

sigma_lb

lower bound for priors for σ\sigma. Defaults to 0.

sigma_ub

upper bound for priors for σ\sigma. Defaults to 10.

bp

logical value that controls whether informed priors are supplied to the model for both δ15\delta^{15}N and δ15\delta^{15}C baselines. Default is FALSE meaning the model will use uninformed priors, however, the supplied data.frame needs values for both δ15\delta^{15}N and δ15\delta^{15}C baseline (c1, c2, n1, and n2).

Details

We will use the following equations from Post 2002:

  1. δ13Cc=α(δ13C1δ13C2)+δ13C2\delta^{13}C_c = \alpha * (\delta ^{13}C_1 - \delta ^{13}C_2) + \delta ^{13}C_2

  2. δ15N=ΔN×(tpλ1)+n1×α+n2×(1α)\delta^{15}N = \Delta N \times (tp - \lambda_1) + n_1 \times \alpha + n_2 \times (1 - \alpha)

  3. δ15N=ΔN×(tp(λ1×α+λ2×(1α)))+n1×α+n2×(1α)\delta^{15}N = \Delta N \times (tp - (\lambda_1 \times \alpha + \lambda_2 \times (1 - \alpha))) + n_1 \times \alpha + n_2 \times (1 - \alpha)

  • The random exponent (α\alpha; a) and shape parameters (β\beta; b) for α\alpha. This prior assumes a beta distribution.

  • The mean (c1; μ\mu) and variance (c1_sigma; σ\sigma) of the mean for the first δ13C\delta^{13}C for a given baseline. This prior assumes a normal distributions.

  • The mean (c2;μ\mu) and variance (c2_sigma; σ\sigma) of the mean for the second δ13C\delta^{13}C for a given baseline. This prior assumes a normal distributions.

  • The mean (n1; μ\mu) and variance (n1_sigma; σ\sigma) of the mean for the first δ15N\delta^{15}N for a given baseline. This prior assumes a normal distributions.

  • The mean (n2;μ\mu) and variance (n2_sigma; σ\sigma) of the mean for the second δ15\delta^{15}N for a given baseline. This prior assumes a normal distributions.

  • The mean (dn; μ\mu) and variance (dn_sigma; σ\sigma) of Δ\DeltaN (i.e, trophic enrichment factor). This prior assumes a normal distributions.

  • The lower (tp_lb) and upper (tp_ub) bounds for priors for trophic position. This prior assumes a uniform distributions.

  • The lower (sigma_lb) and upper (sigma_ub) bounds for variance (σ\sigma). This prior assumes a uniform distributions.

Value

stanvars object to be used with brms() call.

See Also

two_source_priors(), two_source_model(), and brms::brms()

Examples

two_source_priors_params()

Adjust Bayesian priors - Two Source Trophic Position with αr\alpha_r

Description

Create priors for trophic position using a two source model with αr\alpha_r derived from Post 2002 and Heuvel et al. 2024.

Usage

two_source_priors_params_ar(
  a = NULL,
  b = NULL,
  n1 = NULL,
  n1_sigma = NULL,
  n2 = NULL,
  n2_sigma = NULL,
  dn = NULL,
  dn_sigma = NULL,
  tp_lb = NULL,
  tp_ub = NULL,
  sigma_lb = NULL,
  sigma_ub = NULL,
  bp = FALSE
)

Arguments

a

(α\alpha) exponent of the random variable for beta distribution. Defaults to 1. See beta distribution for more information.

b

(β\beta) shape parameter for beta distribution. Defaults to 1. See beta distribution for more information.

n1

mean (μ\mu) prior for first δ15\delta^{15}N baseline. Defaults to 8.0.

n1_sigma

variance (σ\sigma)for first δ15\delta^{15}N baseline. Defaults to 1.

n2

mean (μ\mu) prior for second δ15\delta^{15}N baseline. Defaults to 9.5.

n2_sigma

variance (σ\sigma) for second δ15\delta^{15}N baseline. Defaults to 1.

dn

mean (μ\mu) prior value for Δ\DeltaN. Defaults to 3.4.

dn_sigma

variance (σ\sigma) for δ15\delta^{15}N. Defaults to 0.5.

tp_lb

lower bound for priors for trophic position. Defaults to 2.

tp_ub

upper bound for priors for trophic position. Defaults to 10.

sigma_lb

lower bound for priors for σ\sigma. Defaults to 0.

sigma_ub

upper bound for priors for σ\sigma. Defaults to 10.

bp

logical value that controls whether informed baseline priors are supplied to the model for δ15\delta^{15}N baselines. Default is FALSE meaning the model will use uninformed priors, however, the supplied data.frame needs values for both δ15\delta^{15}N baseline (n1 and n2)

Details

We will use the following equations derived from Post 2002 and Heuvel et al. 2024:

  1. α=(δ13Ccδ13C2)/(δ13C1δ13C2)\alpha = (\delta^{13} C_c - \delta ^{13}C_2) / (\delta ^{13}C_1 - \delta ^{13}C_2)

  2. α=αr×(αmaxαmin)+αmin\alpha = \alpha_r \times (\alpha_{max} - \alpha_{min}) + \alpha_{min}

  3. δ15N=ΔN×(tpλ1)+n1×αr+n2×(1αr)\delta^{15}N = \Delta N \times (tp - \lambda_1) + n_1 \times \alpha_r + n_2 \times (1 - \alpha_r)

  4. δ15N=ΔN×(tp(λ1×αr+λ2×(1αr)))+n1×αr+n2×(1αr)\delta^{15}N = \Delta N \times (tp - (\lambda_1 \times \alpha_r + \lambda_2 \times (1 - \alpha_r))) + n_1 \times \alpha_r + n_2 \times (1 - \alpha_r)

For equation 1)

This equation is a carbon source mixing model with δ13Cc\delta^{13}C_c is the isotopic value for consumer, δ13C1\delta^{13}C_1 is the mean isotopic value for baseline 1 and δ13C2\delta^{13}C_2 is the mean isotopic value for baseline 2. This equation is added to the data frame using add_alpha().

For equation 2)

α\alpha is being corrected using equations in Heuvel et al. 2024 with αr\alpha_r being the corrected value (bound by 0 and 1), αmin\alpha_{min} is the minimum α\alpha value calculated using add_alpha() and αmax\alpha_{max} being the maximum α\alpha value calculated using add_alpha().

For equation 3) and 4)

δ15\delta^{15}N are values from the consumer, n1n_1 is δ15\delta^{15}N values of baseline 1, n2n_2 is δ15\delta^{15}N values of baseline 2, Δ\DeltaN is the trophic discrimination factor for N (i.e., mean of 3.4), tp is trophic position, and λ1\lambda_1 and/or λ2\lambda_2 are the trophic levels of baselines which are often a primary consumer (e.g., 2 or 2.5).

This function allows the user to adjust the priors for the following variables in the equation above:

  • The random exponent (α\alpha; a) and shape parameters (β\beta; b) for αr\alpha_r. This prior assumes a beta distribution.

  • The mean (n2;μ\mu) and variance (n2_sigma; σ\sigma) of the second δ15\delta^{15}N for a given baseline. This prior assumes a normal distributions.

  • The mean (c1;μ\mu) and variance (c1_sigma; σ\sigma) of the second δ13\delta^{13}C for a given baseline. This prior assumes a normal distributions.

  • The mean (c2;μ\mu) and variance (c2_sigma; σ\sigma) of the second δ13\delta^{13}C for a given baseline. This prior assumes a normal distributions.

  • The mean (dn; μ\mu) and variance (dn_sigma; σ\sigma) of Δ\DeltaN (i.e, trophic enrichment factor). This prior assumes a normal distributions.

  • The lower (tp_lb) and upper (tp_ub) bounds for priors for trophic position. This prior assumes a uniform distributions.

  • The lower (sigma_lb) and upper (sigma_ub) bounds for variance (σ\sigma). This prior assumes a uniform distributions.

Value

stanvars object to be used with brms() call.

See Also

two_source_priors_ar(), two_source_model_ar(), and brms::brms()

Examples

two_source_priors_params_ar()

Adjust Bayesian priors - Two Source Trophic Position with αr\alpha_r and carbon mixing model

Description

Adjust priors for trophic position using a two source model with αr\alpha_r derived from Post 2002 and Heuvel et al. 2024

Usage

two_source_priors_params_arc(
  a = NULL,
  b = NULL,
  n1 = NULL,
  n1_sigma = NULL,
  n2 = NULL,
  n2_sigma = NULL,
  c1 = NULL,
  c1_sigma = NULL,
  c2 = NULL,
  c2_sigma = NULL,
  dn = NULL,
  dn_sigma = NULL,
  tp_lb = NULL,
  tp_ub = NULL,
  sigma_lb = NULL,
  sigma_ub = NULL,
  bp = FALSE
)

Arguments

a

(α\alpha) exponent of the random variable for beta distribution. Defaults to 1. See beta distribution for more information.

b

(β\beta) shape parameter for beta distribution. Defaults to 1. See beta distribution for more information.

n1

mean (μ\mu) prior for first δ15\delta^{15}N baseline. Defaults to 8.0.

n1_sigma

variance (σ\sigma)for first δ15\delta^{15}N baseline. Defaults to 1.

n2

mean (μ\mu) prior for second δ15\delta^{15}N baseline. Defaults to 9.5.

n2_sigma

variance (σ\sigma) for second δ15\delta^{15}N baseline. Defaults to 1.

c1

mean (μ\mu) prior for first δ13\delta^{13}C baseline. Defaults to -21.

c1_sigma

variance (σ\sigma)for first δ13\delta^{13}C baseline. Defaults to 1.

c2

mean (μ\mu) prior for second δ13\delta^{13}C baseline. Defaults to -26.

c2_sigma

variance (σ\sigma) for second δ13\delta^{13}C baseline. Defaults to 1.

dn

mean (μ\mu) prior value for Δ\DeltaN. Defaults to 3.4.

dn_sigma

variance (σ\sigma) for δ15\delta^{15}N. Defaults to 0.25.

tp_lb

lower bound for priors for trophic position. Defaults to 2.

tp_ub

upper bound for priors for trophic position. Defaults to 10.

sigma_lb

lower bound for priors for σ\sigma. Defaults to 0.

sigma_ub

upper bound for priors for σ\sigma. Defaults to 10.

bp

logical value that controls whether informed baseline priors are supplied to the model for δ15\delta^{15}N baselines. Default is FALSE meaning the model will use uninformed priors, however, the supplied data.frame needs values for both δ15\delta^{15}N baseline (n1 and n2)

Details

We will use the following equations derived from Post 2002 and Heuvel et al. 2024:

  1. α=(δ13Ccδ13C2)/(δ13C1δ13C2)\alpha = (\delta^{13} C_c - \delta ^{13}C_2) / (\delta ^{13}C_1 - \delta ^{13}C_2)

  2. α=αr×(αmaxαmin)+αmin\alpha = \alpha_r \times (\alpha_{max} - \alpha_{min}) + \alpha_{min}

  3. δ13C=c1×αr+c2×(1αr)\delta^{13}C = c_1 \times \alpha_r + c_2 \times (1 - \alpha_r)

  4. δ15N=ΔN×(tpλ1)+n1×αr+n2×(1αr)\delta^{15}N = \Delta N \times (tp - \lambda_1) + n_1 \times \alpha_r + n_2 \times (1 - \alpha_r)

  5. δ15N=ΔN×(tp(λ1×αr+λ2×(1αr)))+n1×αr+n2×(1αr)\delta^{15}N = \Delta N \times (tp - (\lambda_1 \times \alpha_r + \lambda_2 \times (1 - \alpha_r))) + n_1 \times \alpha_r + n_2 \times (1 - \alpha_r)

For equation 1)

This equation is a carbon source mixing model with δ13Cc\delta^{13}C_c is the isotopic value for consumer, δ13C1\delta^{13}C_1 is the mean isotopic value for baseline 1 and δ13C2\delta^{13}C_2 is the mean isotopic value for baseline 2.

For equation 2)

α\alpha is being corrected using equations in Heuvel et al. 2024. with αr\alpha_r being the corrected value (bound by 0 and 1), αmin\alpha_{min} is the minimum α\alpha value calculated using add_alpha() and αmax\alpha_{max} being the maximum α\alpha value calculated using add_alpha().

For equation 3)

This equation is a carbon source mixing model with δ13\delta^{13}C being estimated using c_1, c_2 and αr\alpha_r calculated in equation 1.

For equation 4) and 5)

δ15\delta^{15}N are values from the consumer, n1n_1 is δ15\delta^{15}N values of baseline 1, n2n_2 is δ15\delta^{15}N values of baseline 2, Δ\DeltaN is the trophic discrimination factor for N (i.e., mean of 3.4), tp is trophic position, and λ1\lambda_1 and/or λ2\lambda_2 are the trophic levels of baselines which are often a primary consumer (e.g., 2 or 2.5).

This function allows the user to adjust the priors for the following variables in the equation above:

  • The random exponent (α\alpha; a) and shape parameters (β\beta; b) for αr\alpha_r. This prior assumes a beta distribution.

  • The mean (n2;μ\mu) and variance (n2_sigma; σ\sigma) of the second δ15\delta^{15}N for a given baseline. This prior assumes a normal distributions.

  • The mean (c1;μ\mu) and variance (c1_sigma; σ\sigma) of the second δ13\delta^{13}C for a given baseline. This prior assumes a normal distributions.

  • The mean (c2;μ\mu) and variance (c2_sigma; σ\sigma) of the second δ13\delta^{13}C for a given baseline. This prior assumes a normal distributions.

  • The mean (dn; μ\mu) and variance (dn_sigma; σ\sigma) of Δ\DeltaN (i.e, trophic enrichment factor). This prior assumes a normal distributions.

  • The lower (tp_lb) and upper (tp_ub) bounds for priors for trophic position. This prior assumes a uniform distributions.

  • The lower (sigma_lb) and upper (sigma_ub) bounds for variance (σ\sigma). This prior assumes a uniform distributions.

Value

stanvars object to be used with brms() call.

See Also

two_source_priors_arc(), two_source_model_arc(), and brms::brms()

Examples

two_source_priors_params_ar()