bremla_prepare: Bremla preparation function

View source: R/bremla_prepare.R

bremla_prepareR Documentation

Bremla preparation function

Description

Prepares input and formats data for bremla and functions therein.

Usage

bremla_prepare(
  formula,
  data,
  nsims = NULL,
  reference.label = NULL,
  x.label = NULL,
  y.label = NULL,
  events = NULL,
  synchronization = NULL,
  control.fit = NULL,
  control.sim = NULL,
  control.linramp = NULL,
  control.transition_dating = NULL,
  control.bias = NULL
)

Arguments

formula

Formula describing the response and covariates (partial covariates (phi) can be filled out using events$fill_formula)

data

data.frame including response, all covariates included in formula, as well as 'depth' and 'age' describing both axes of reference chronology. First row is used to extract initial values 'y0' and 'z0', the remaining variables in the first row is typically not used and can be left as NA. Partial covariates (phi) can be filled out using 'events$fill_data'.

nsims

Number of chronologies to be simulated.

reference.label

Character label of reference timescale. Used in plot,summary.

x.label

Character label for the x-axis (depth).

y.label

Character label for the y-axis (age).

events

List object describing the specifics of the climate transitions used in 'formula'. Must include an item called locations. See ?events.default for details.

synchronization

List object describing specifics related to tie-points and their distribution. If synchronization$method="adolphi" a specific set of instructions are employed. If not, this list must include locations argument and preferably locations_unit to determine which axis (default unit="depth"). See synchronization.default for details.

control.fit

List object describing specifics related to the fitting procedure. See control.fit.default for details.

control.sim

List object describing specifics related to simulating chronologies. See control.sim.default for details.

control.linramp

List containing specifications for fitting a linear ramp model to given data. If used, must include control.linramp\$proxy and control.linramp\$interval. See control.linramp.default for details.

control.transition_dating

List object describing specifics related to the estimation of a given transition. Must include interval and proxy used in linear ramp estimation. See control.transition_dating.default for details.

control.bias

List object describing specifics related to the simulation of unknown stochastic bias. See control.bias.default for details.

Value

Returns a list containing data in internal formatting (data), linear regression formula (ls.formula), inla formula (formula), input settings and indices corresponding to climate transitions (.args) and z_0, y_0 and x_0 (preceeding)

Author(s)

Eirik Myrvoll-Nilsen, eirikmn91@gmail.com

See Also

bremla,bremla_chronology_simulation

Examples

require(stats)
set.seed(1)
n <- 1000
phi <- 0.8
sigma <- 1.2
a_lintrend <- 0.3; a_proxy = 0.8
dy_noise <- as.numeric(arima.sim(model=list(ar=c(phi)),n=n,sd=sqrt(1-phi^2)))
lintrend <- seq(from=10,to=15,length.out=n)

proxy <- as.numeric(arima.sim(model=list(ar=c(0.9)),n=n,sd=sqrt(1-0.9^2)))
dy <- a_lintrend*lintrend + a_proxy*proxy + sigma*dy_noise

y0 = 11700;z0=1200
age = y0+cumsum(dy)
depth = 1200 + 1:n*0.05


formula = dy~-1+depth2 + proxy
depth2 = depth^2/depth[1]^2 #normalize for stability

data = data.frame(age=age,dy=dy,proxy=proxy,depth=depth,depth2=depth2)
data = rbind(c(y0,NA,NA,z0,NA),data) #First row is only used to extract y0 and z0.

events=list(locations=c(1210,1220,1240))
control.fit = list(ncores=2,noise="ar1")
synchronization=list(method="gauss")
control.sim=list(synchronized=2,
                 summary=list(compute=TRUE))

control.bias=NULL
object = bremla_prepare(formula,data,nsims=5000,reference.label="simulated timescale",
                        events = events,
                        synchronization=synchronization,
                        control.fit=control.fit,
                        control.sim=control.sim,
                        control.bias=control.bias)
summary(object)

eirikmn/bremla documentation built on Jan. 25, 2025, 4:41 a.m.