forked from hydromad/hydromad
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevalPars.Rd
77 lines (68 loc) · 2.5 KB
/
evalPars.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/evalPars.R
\name{evalPars}
\alias{evalPars}
\alias{getFreeParsRanges}
\title{Evaluate a model for a matrix of parameters}
\usage{
evalPars(
par.matrix,
object,
objective = hydromad.getOption("objective"),
parallel = hydromad.getOption("parallel")[["evalPars"]]
)
}
\arguments{
\item{par.matrix}{Named matrix or data.frame of parameter values, with each
row corresponding to a model realisation to evaluate}
\item{object}{an object of class \code{hydromad}.}
\item{objective}{the objective function or expression, which can refer to Q
and X. See \code{\link{objFunVal.hydromad}}}
\item{parallel}{Which parallelisation method to use. Options are
\code{"clusterApply"} and \code{"foreach"}. For any other value, parameters
will be evaluated sequentially. Default is \code{"none"}. For more
information see \code{\link{hydromad_parallelisation}}.}
}
\value{
evalPars returns a vector of objective function values,
corresponding to the evaluation of each row of \code{par.matrix}.
}
\description{
\code{evalPars} evaluates a model for a named matrix of parameters.
}
\details{
\code{evalPars} is used in conjunction with \code{getFreeParsRanges}
and the \code{sensitivity} package to perform sensitivity analysis. See
\code{demo(sensitivity)}. Note that the objective function may more
generally return any scalar result, e.g. a scalar prediction calculated only
using X.
Individual model evaluations are generally very fast, so parallelisation is
only really worthwhile when large numbers of evaluations are needed.
\code{"clusterApply"} has a slightly lower overhead. \code{"foreach"} allows
a broader range of options.
}
\examples{
data(Cotter)
obs <- Cotter[1:1000]
modx <- hydromad(obs,
sma = "cmd", routing = "expuh",
tau_s = c(2, 100), v_s = c(0, 1)
)
## Sample 10 random parameter sets for parameters with defined ranges
pars <- parameterSets(getFreeParsRanges(modx), 10, method = "random")
## Return the default objective function value for each model realisation
evalPars(pars, object = modx)
## Calculate the 20\%ile flow for each model realisation
evalPars(pars, object = modx, objective = ~ quantile(X, 0.2))
## Alternatively, sample 10 random parameter sets from all parameters
## This allows specifying discrete values of parameters
pars <- parameterSets(coef(modx, warn = FALSE), 10, method = "random")
}
\seealso{
\code{\link{objFunVal.hydromad}}, \code{\link{parameterSets}},
\code{getFreeParsRanges}
}
\author{
Joseph Guillaume
}
\keyword{models}