simulate.hydromad {hydromad} | R Documentation |
Run many simulations by sampling within parameter ranges.
## S3 method for class 'hydromad' simulate(object, nsim, seed, ..., sampletype = c("latin.hypercube", "random", "all.combinations"), FUN = NULL, objective = NULL, bind = !is.null(objective))
object |
a |
nsim |
number of parameter samples to run. |
seed |
optional random seed, for repeatability. |
... |
further arguments to |
sampletype |
sampling method; see |
FUN |
optional function to apply to each simulated model. Typical examples
would be |
objective |
an objective function (or statistic function); this is just an
argument to be passed on to |
bind |
to bind the result from |
none yet.
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.
Felix Andrews felix@nfrac.org
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)