cvLDS: Cross validate LDS model. This is a wrapper for...

Description Usage Arguments Value Examples

View source: R/LDS_reconstruction.R

Description

Cross validate LDS model. This is a wrapper for LDS_reconstruction

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
cvLDS(
  Qa,
  u,
  v,
  start.year,
  method = "EM",
  transform = "log",
  num.restarts = 50,
  Z = make_Z(Qa$Qa),
  metric.space = "transformed",
  use.raw = FALSE,
  ub = NULL,
  lb = NULL,
  num.islands = 4,
  pop.per.island = 100,
  niter = 1000,
  tol = 1e-05
)

Arguments

Qa

Observations: a data.frame of annual streamflow with at least two columns: year and Qa.

u

Input matrix for a single-model reconstruction, or a list of input matrices for an ensemble reconstruction.

v

Same as u.

start.year

Starting year of the climate proxies, i.e, the first year of the paleo period. start.year + nrow(pc) - 1 will determine the last year of the study horizon, which must be greater than or equal to the last year in Qa.

method

By default this is "EM". There are experimental methods but you should not try.

transform

Flow transformation, either "log", "boxcox" or "none". Note that if the Box-Cox transform is used, the confidence interval after back-transformation is simply the back-transform of the trained onfidence interval; this is hackish and not entirely accurate.

num.restarts

The number of initial conditions to start the EM search; ignored if init is provided.

Z

A list of cross-validation folds. If NULL, will be created with make_Z() with default settings. Users are advised to use make_Z() to create the cross-validation folds beforehand. See make_Z for details.

metric.space

Either "transformed" or "original", the space to calculate the performance metrics.

use.raw

Whether performance metrics are calculated on the raw time series. Experimental; don't use.

ub

Upper bounds, a vector whose length is the number of parameters

lb

Lower bounds

num.islands

Number of islands (if method is GA; experimental)

pop.per.island

Initial population per island (if method is GA; experimental)

niter

Maximum number of iterations, default 1000

tol

Tolerance for likelihood convergence, default 1e-5. Note that the log-likelihood is normalized by dividing by the number of observations.

Value

A list of cross validation results

Examples

1
2
3
4
5
6
7
# Make a shorter time horizon so that this example runs fast
u <- v <- t(NPpc[601:813])
# We run this example without parallelism.
foreach::registerDoSEQ()
cvLDS(NPannual, u, v, start.year = 1800, num.restarts = 2,
      Z = make_Z(NPannual$Qa, nRuns = 1))
# Please refer to the vignette for the full run with parallel options. It takes a minute or two.

ldsr documentation built on May 4, 2020, 5:06 p.m.