simulate.hydromad {hydromad}R Documentation

Simulate hydromad models by parameter sampling.

Description

Run many simulations by sampling within parameter ranges.

Usage

## S3 method for class 'hydromad'
simulate(object, nsim, seed, ...,
         sampletype = c("latin.hypercube", "random", "all.combinations"),
         FUN = NULL, objective = NULL, bind = !is.null(objective))

Arguments

object

a hydromad object (produced by the hydromad() function) that is not fully specified (i.e. so some parameter values are given as ranges).

nsim

number of parameter samples to run.

seed

optional random seed, for repeatability.

...

further arguments to FUN.

sampletype

sampling method; see parameterSets.

FUN

optional function to apply to each simulated model. Typical examples would be objFunVal, summary or predict.

objective

an objective function (or statistic function); this is just an argument to be passed on to FUN, which in this case defaults to objFunVal to calculate the statistic value from each model. It is treated as a special argument because it is cached before the simulation run for efficiency.

bind

to bind the result from FUN as one or more columns onto the matrix of parameter values, and return as a data frame.

Details

none yet.

Value

a list of results, where each element is named by its parameter set. The result also has an attribute "psets" which gives the parameter values used in each simulation (as a data frame).

If bind = TRUE, a data frame.

Author(s)

Felix Andrews felix@nfrac.org

See Also

parameterSets, fitBySampling

Examples

data(Canning)
mod0 <- hydromad(Canning[1:500,], sma = "cwi")
sim0 <- simulate(mod0, nsim = 5, sampletype = "latin")
coef(sim0)
summary(sim0)

## plot the objective function surface over two parameters
mod1 <- update(mod0, routing = "armax", rfit = list("ls", order = c(2,1)))
sim1 <- simulate(mod1, 144, sampletype = "all", FUN = objFunVal,
          objective = ~ nseStat(Q, X, trans = sqrt))
levelplot(result ~ tw + f, sim1, cex = 2,
          panel = panel.levelplot.points,
          main = "R Squared (of sq.rt. data) over parameter space") +
layer_(panel.2dsmoother(...))

## dotty plots (list any number of parameters in formula)
xyplot(result ~ tw + f, sim1, outer = TRUE)

[Package hydromad version 0.9-18 Index]