Fitting of model parameters can be performed in two ways:
A single scenario is fitted to a single dataset.
The dataset must represent a time-series of an output variable of the
model, e.g. observed biomass over time (effect data). The dataset can represent
results of one or more experimental replicates under identical conditions.
One or more datasets of observed data are fitted each to a scenario which
describes the experimental conditions during observation, such as exposure
level and environmental properties. Each combination of dataset and scenario
is represented by a calibration set. During fitting,
all calibration sets are evaluated and a total error term is calculated
over all observed and predicted values.
Observed data
Experimental, or effect, data must be supplied as a data.frame
in long format
with at least two columns: the first column contains numeric
timestamps and
the remaining columns must contain the observed quantity. The dataset must
contain a column that which matches with the contents of parameter output
.
As an example, the simulation result of Lemna_Schmitt model contains the
output column biomass (BM
), amongst others. To fit model parameters of said
Lemna_Schmitt scenario based on observed biomass, the observed data must
contain a column named BM
which represents the observed biomass.
A minimal observed dataset could look like this:
observed <- data.frame(time=c(0, 7, 14, 21),
BM=c( 12, 23, 37, 56))
Error function
By default, the total sum of squared errors is used as the target
function which is minimized during fitting. A custom error function can be
supplied by the user: The function must accept four vectorized
arguments and return a numeric of length one, i.e. the total error value
which gets minimized by calibrate()
.
Example of a custom error function which returns the sum of absolute errors:
my_absolute_error <- function(observed, predicted, weights, tags) {
sum(abs(observed - predicted))
}
The arguments to the error function will contain all observed and predicted
values, as well as any weights and tags that were defined by the calibration sets.
As tags are optional, the fourth argument may be a list containing NULL
values.
The fourth argument can be used to pass additional information to the error
function: For example, the tag may identify the study from where the data
originates from and the error function could group and evaluate the data
accordingly.