Package 'bayfoxr'

Title: Global Bayesian Foraminifera Core Top Calibration
Description: A Bayesian, global planktic foraminifera core top calibration to modern sea-surface temperatures. Includes four calibration models, considering species-specific calibration parameters and seasonality.
Authors: Steven Malevich [aut, cre]
Maintainer: Steven Malevich <[email protected]>
License: GPL (>= 3)
Version: 0.0.2.9000
Built: 2025-03-05 05:18:01 UTC
Source: https://github.com/brews/bayfoxr

Help Index


Bass River planktic foraminiferal calcite d18O.

Description

A data set containing marine sediment core samples from the Paleocene-Eocene Thermal Maximum (PETM) section with well preservedforaminifera calcite d18O.

Usage

bassriver

Format

A data frame with 62 rows and 2 column variables:

depth

marine sediment down-core sample depth, in m

d18o

Morozovella spp. shell calcite d18O, in ‰ VPDB

Source

John, C. M., S. M. Bohaty, J. C. Zachos, A. Sulijs, S. Gibbs, H. Brinkhuis, and T. J. Bralower (2008), North American continental margin records of the Paleocene-Eocene thermal maximum: Implications for global carbon and hydrological cycling, Paleoceanography, 23(2), doi:10.1029/2007PA001465.


Parse trace dataframe column names to get vector of available forams.

Description

Parse trace dataframe column names to get vector of available forams.

Usage

get_available_forams(d)

Arguments

d

Data frame containing MCMC trace draws. Column names are model parameters with foram group name separated from model parameters name by "__"

Value

Character vector of available foram names.


Get MCMC trace draws.

Description

Get MCMC trace draws.

Usage

get_draws(foram = NULL, seasonal_seatemp = FALSE)

Arguments

foram

Optional. String or NULL. String indicating the foram species/subspecies to infer for hierarchical models. String must be one of "G. bulloides", "G. ruber white", "G. ruber pink", "G. sacculifer", "N. incompta", or "N. pachyderma sinistral". NULL indicates that a pooled model is desired.

seasonal_seatemp

Optional boolean indicating whether to use the seasonal sea-surface temperature calibrations. Default is FALSE, i.e. using annual SST calibrations.

Details

Four calibration models are available: an "annual pooled" model, a "seasonal pooled" model, an "annual hierarchical" model, and a "seasonal hierarchical" model. This function uses magic to determine which "pooled annual" model is used. Which is the simplest case with potential use for Deep Time reconstructions of nonexant foram species. Giving a valid string for foram will use a hierarchical model, which has foram-specific variability in calibration model parameters. Passing TRUE for seasonal_seatemp will use a model trained on season sea-surface temperatures. See reference paper for further details.

Value

Data frame with columns "alpha", "beta", "tau". Which are equal-length vectors of model parameter draws.


Plot a prediction object.

Description

Plot a prediction object.

Usage

## S3 method for class 'prediction'
plot(...)

Arguments

...

Arguments passed on to predictplot.

See Also

predictplot

Examples

data(bassriver)

# Using the "pooled annual" calibration model:
sst <- predict_seatemp(bassriver$d18o, d18osw=0.0, 
                       prior_mean=30.0, prior_std=20.0)

predictplot(x=bassriver$depth, y=sst, ylim=c(20, 40), 
            ylab="SST (°C)", xlab="Depth (m)")

Predict d18O of foram calcite given seawater temperature and seawater d18O.

Description

Predict d18O of foram calcite given seawater temperature and seawater d18O.

Usage

predict_d18oc(seatemp, d18osw, foram = NULL, seasonal_seatemp = FALSE,
  drawsfun = get_draws)

Arguments

seatemp

Numeric or vector of observed sea-surface temperatures (°C).

d18osw

Numeric or vector of observed seawater d18O (‰ VSMOW).

foram

Optional. String or NULL. String indicating the foram species/subspecies to infer for hierarchical models. String must be one of "G. bulloides", "G. ruber", "T. sacculifer", "N. incompta", or "N. pachyderma". NULL indicates that a pooled model is desired.

seasonal_seatemp

Optional boolean indicating whether to use the seasonal sea-surface temperature calibrations. Default is FALSE, i.e. using annual SST calibrations.

drawsfun

Optional function used to get get model parameter draws. Must take arguments for "foram" and "seasonal_seatemp" and return a list with members "alpha", "beta", "tau". This is for debugging and testing. See get_draws.

Details

Four calibration models are available: an "annual pooled" model, a "seasonal pooled" model, an "annual hierarchical" model, and a "seasonal hierarchical" model. This function uses magic to determine which "pooled annual" model is used. Which is the simplest case with potential use for Deep Time reconstructions of nonexant foram species. Giving a valid string for foram will use a hierarchical model, which has foram-specific variability in calibration model parameters. Passing TRUE for seasonal_seatemp will use a model trained on season sea-surface temperatures. See reference paper for further details.

Value

A prediction instance for inferred foraminiferal calcite d18O (‰ VPDB).

See Also

predict_seatemp, predictplot

Examples

# Infer d18Oc for a G. bulloides core top sample using annual hierarchical model.
# The true, d18Oc for this sample is -2.16 (‰ VPDB).
delo_ann <- predict_d18oc(seatemp=28.6, d18osw=0.48, foram="G. bulloides")
head(quantile(delo_ann, probs=c(0.159, 0.5, 0.841)))  # ± 1 standard deviation

# Now using seasonal hierarchical model:
delo_sea <- predict_d18oc(seatemp=28.6, d18osw=0.48, foram="G. bulloides",
                          seasonal_seatemp = TRUE)
head(quantile(delo_sea, probs=c(0.159, 0.5, 0.841)))  # ± 1 standard deviation

Predict sea-surface temperature given d18O of foram calcite and seawater d18O.

Description

Predict sea-surface temperature given d18O of foram calcite and seawater d18O.

Usage

predict_seatemp(d18oc, d18osw, prior_mean, prior_std, foram = NULL,
  seasonal_seatemp = FALSE, drawsfun = get_draws)

Arguments

d18oc

Numeric or vector of observed foram calcite d18O (‰ VPDB).

d18osw

Numeric or vector of observed seawater d18O (‰ VSMOW).

prior_mean

Numeric indicating prior mean for sea-surface temperature (°C).

prior_std

Numeric indicating prior standard deviation for sea-surface temperature (°C).

foram

Optional. String or NULL. String indicating the foram species/subspecies to infer for hierarchical models. String must be one of "G. bulloides", "G. ruber", "T. sacculifer", "N. incompta", or "N. pachyderma". NULL indicates that a pooled model is desired.

seasonal_seatemp

Optional boolean indicating whether to use the seasonal sea-surface temperature calibrations. Default is FALSE, i.e. using annual SST calibrations.

drawsfun

Optional function used to get get model parameter draws. Must take arguments for "foram" and "seasonal_seatemp" and return a list with members "alpha", "beta", "tau". This is for debugging and testing.

Details

Four calibration models are available: an "annual pooled" model, a "seasonal pooled" model, an "annual hierarchical" model, and a "seasonal hierarchical" model. This function uses magic to determine which "pooled annual" model is used. Which is the simplest case with potential use for Deep Time reconstructions of nonexant foram species. Giving a valid string for foram will use a hierarchical model, which has foram-specific variability in calibration model parameters. Passing TRUE for seasonal_seatemp will use a model trained on season sea-surface temperatures. See reference paper for further details.

Value

A prediction instance for inferred sea-surface temperature (°C).

See Also

predict_d18oc

Examples

data(bassriver)

# Using the "pooled annual" calibration model:
sst <- predict_seatemp(bassriver$d18o, d18osw=0.0, 
                       prior_mean=30.0, prior_std=20.0)
head(quantile(sst))  # Show only the top few values

predictplot(x=bassriver$depth, y=sst, ylim=c(20, 40), 
            ylab="SST (°C)", xlab="Depth (m)")

Constructor for S3 prediction class.

Description

Constructor for S3 prediction class.

Usage

prediction(ensemble)

Arguments

ensemble

A matrix (m x n) of the prediciton posteriors. Where m is the number of values inferred and n is the number of trace draws.

Value

A prediction object.


Simple plot of prediction with intervals.

Description

Simple plot of prediction with intervals.

Usage

predictplot(y, x = NULL, probs = c(0.05, 0.5, 0.95),
  poly_col = grDevices::rgb(0, 0, 0, 0.1), ...)

Arguments

y

A prediction object to plot.

x

Optional vector or NULL, indicating were prediction inferences fall along x-axis. Must be the same length as the inferred values in y.

probs

Optional 3-member Vector of numerics indicating low, middle, and high probability intervals to plot. All must be <= 1.

poly_col

Optional color for interval polygon.

...

Additional arguments passed to plot.

Examples

data(bassriver)

# Using the "pooled annual" calibration model:
sst <- predict_seatemp(bassriver$d18o, d18osw=0.0, 
                       prior_mean=30.0, prior_std=20.0)

predictplot(x=bassriver$depth, y=sst, ylim=c(20, 40), 
            ylab="SST (°C)", xlab="Depth (m)")

Quantiles for a prediction.

Description

Quantiles for a prediction.

Usage

## S3 method for class 'prediction'
quantile(x, ...)

Arguments

x

A prediction object.

...

Arguments to be passed on to quantile.


Internal function for 'predict_seatemp()'.

Description

Internal function for 'predict_seatemp()'.

Usage

target_timeseries_pred(d18osw_now, alpha_now, beta_now, tau_now, proxy_ts,
  prior_mu, prior_inv_cov)

Arguments

d18osw_now

Numeric or vector giving seawater d18O. Note, should be in units (‰ VPDB).

alpha_now

Numeric, alpha model parameter.

beta_now

Numeric, beta model parameter.

tau_now

Numeric, tau model parameter.

proxy_ts

Numeric or vector of proxy time series (foram d18O).

prior_mu

Matrix (n X 1) giving prior mean.

prior_inv_cov

Matrix (n X x) giving prior inverse covariance matrix.

Value

Sample of time time series vector conditional on the other args