gof: Goodness-of-fit for a 1D dynamic, multi-component model

Description Usage Arguments Value Note Author(s) Examples

Description

Compares observation data with the model output.

Usage

1
gof(obj, obs, f = function(sim, obs) {     mean((sim - obs)^2) })

Arguments

obj

Object created with sim1D.create.

obs

Data frame of observations. See notes below.

f

A function taking two numeric vectors with observed and simulated data as input. It should return a numeric vector (which can be of length 1).

Value

A list with as many elements as there are corresponding variables in dyn and obs. Each element contains the output of f. If, for a particular variable, no corresponding data are found (because of a missing overlap of spatial and/or time interval), the list element for that variable is set to NULL. If there aren't any corresponding variables (due to a lack of matching names), the return value is a list of length 0.

Note

The data frame of observations passed as obs needs to have 4 columns named 'time', 'coordinate', 'variable', and 'value'. Entries in column 'time' are coerced to numbers using as.numeric. The corresponding simulated values are picked from the matching spatial box/layer and the nearest time point available in the model output.

Author(s)

David Kneis david.kneis@tu-dresden.de

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
gr <- makeGrid(dz0=0.01, dzMax=0.02, zMax=0.1, beta=1)
times <- 0:2
vars <- c("A","B")
pros <- c("X","Y")
values <- matrix(1:(length(times)*nrow(gr)*(length(vars)+length(pros))),
  nrow=length(times))
dyn <- cbind(times, values)
colnames(dyn) <- c("time", paste(rep(vars, each=nrow(gr)), 1:nrow(gr),sep="."),
  paste(rep(pros, each=nrow(gr)), 1:nrow(gr),sep="."))
obj <- sim1D.create(dyn, namesVars=vars, namesPros=pros, xMin=gr$zUp, xMax=gr$zLw)
obs <- data.frame(time=c(1,1,2,2), coordinate=c(0.03, 0.04, 0.05, 0.04),
  variable=c("X","X","X","Y"), value=0)
fun <- function(sim,obs) {c(bias=mean(sim-obs), rmse=mean((sim-obs)^2))}
gof(obj, obs, f=fun)

dkneis/diatools documentation built on May 15, 2019, 9:12 a.m.