create paleoclimate composite ensembles from a list of LiPD timeseries. A revised version of compositeEnsembles by Chris Hancock (2024)

compositeEnsembles2(
  fTS,
  binvec,
  nens = 100,
  stanFun = standardizeOverRandomInterval,
  ageVar = "age",
  uncVar = NA,
  weights = NA,
  samplePct = 1,
  scale = FALSE,
  spread = TRUE,
  gaussianizeInput = FALSE,
  alignInterpDirection = TRUE,
  scope = "climate",
  binFun = sampleEnsembleThenBinTs,
  verbose = TRUE,
  ...
)

Arguments

fTS

TS list of the timeseries that you want to composite

binvec

A vector that describes the edges of the bins to bin to

nens

the number of ensembles to create

stanFun

function to use for standardization (either standardizeOverRandomInterval, standardizeMeanIteratively, or standardizeOverInterval)

ageVar

age variable to use

uncVar

uncertainty variable
- Use a string to identify a fTS variable name or use a number to provide a uniform value to all records.
- This is used if stanFun == sampleEnsembleThenBinTs but not for simpleBinTs.

weights

weights for calculating the composite mean.
- For example, you may want to weight each record in a region relative to the number of total records from a single site.
- Use a string to identify a fTS variable name, otherwise all values will be weighted equally.

samplePct

the percent of records to used for each ensemble.
- If length(fTS)*samplePct <= 3, this is ignored.
- Default = 1 which means that 100 percent of records are used for each ensemble

scale

scale each composite ensemble member to have a mean of zero and unit variance at the end of the compiting

spread

"Spread" data before binning to prevent aliasing of bins (default = TRUE)

gaussianizeInput

"Gaussianize" the data before compositing to avoid impacts of irregularly distributed data (default = TRUE)

alignInterpDirection

align data by interpretation direction

scope

which scope of interpretation to use

binFun

function to use for binning (either sampleEnsembleThenBinTs or simpleBinTS)

verbose

should a progress bar be printed?

...

additional options to pass to stanFun

Value

a composite list class with three tibbles:
(1) The composite [dims = length(binvec) x (nens + 1 for age column)]
(2) the standardized values [dims = length(binvec) x (length(fTS) + 1 for age column)], and
(3) a count of when proxy values are used in the compilation [same dims as 2]