cvLDS {ldsr} | R Documentation |
Cross validate LDS model. This is a wrapper for LDS_reconstruction
Description
Cross validate LDS model. This is a wrapper for LDS_reconstruction
Usage
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. |
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 |
Z |
A list of cross-validation folds. If |
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
metrics.dist: distribution of performance metrics across all cross-validation runs; a matrix, one column for each metric, with column names.
metrics: average performance metrics; a named vector.
target: the (transformed) observations used for cross-validation; a data.table with two columns (year, y)
Ycv: the predicted streamflow in each cross validation run; a matrix, one column for each cross-validation run
Z: the cross-validation
Examples
# 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.