pRsim.wave {PRSim} | R Documentation |
Simulate for multiple stations
Description
Applies the wavelet-based simulation algorithm to multiple sites (single site possible as well)
Usage
prsim.wave(data, station_id="Qobs", number_sim=1, win_h_length=15,
marginal=c("kappa","empirical"), n_par=4, n_wave=100, marginalpar=TRUE,
GoFtest=NULL, verbose=TRUE, suppWarn=FALSE, ...)
Arguments
data |
list of data frames. One list entry, i.e. data frame, corresponds to one station. Each data frame contains the time indications and runoff of one station. See ‘Details’. |
station_id |
identifies the station in case several time series are present in |
number_sim |
number of simulations to be carried out. |
win_h_length |
(half-)length of moving window size. |
marginal |
marginal distribution to be used for the backtransformation. Can be either |
n_par |
number of parameters of the marginal distribution used |
GoFtest |
If (non-null) a GoF test for daily data should be performed: |
verbose |
logical. Should progress be reported? |
marginalpar |
logical. Should the estimated parameters of the distribution used be returned? |
n_wave |
number of scales to be considered in the continuous wavelet transform. |
suppWarn |
logical. See ‘Details’. |
... |
any other argument passed to the sub-function specifying the cdf for fitting. See ‘Details’ and ‘Examples’. |
Details
Time can be given with three columns named "YYYY"
, "MM"
, "DD"
, or as in POSIXct format YYYY-MM-DD
.
All leap days (Feb 29th) will be omitted from the analysis, but no missing observations are allowed.
Stations are identified by list index.
The function homtest::par.kappa
might issue quite a few warnings of type In fn(par, ...) : value out of range in 'gammafn'
. The argument suppWarn
allows to silence warnings for the specific function call via suppressWarnings()
. Of course, a subsequent check via warnings()
is recommended.
Alternative distributions can be specified by providing three functions: (1) a function fitting the parameters of a distributions and providing a vector of these parameters as output (CDF_fit), (2) a function simulating random numbers from this distribution (rCDF), and (3) a function specifying the distribution (pCDF). See ‘Examples’ for the generalized beta for the second kind and for the Generalized Extreme Values (GEV) distribution.
When using the kappa distribution, the AD test can for certain values of the parameter h not be performed.
Value
A list with elements
simulation |
A data frame with time information, observations, and
|
pars |
A matrix containing the estimated parameters of the marginal distribution (if |
p_val |
A vector containing the p-values of |
Author(s)
Manuela Brunner
References
Brunner, M. I., and E. Gilleland (2020). Stochastic simulation of streamflow and spatial extremes: a continuous, wavelet-based approach, Hydrology and Earth System Sciences, https://doi.org/10.5194/hess-24-3967-2020.
See Also
ks.test
Examples
data(runoff_multi_sites)
## Specifying particular CDFs:
## (1) example with the Generalized Extreme Value (GEV) distribution
require("evd")
require("ismev")
rGEV <- function(n, theta) rgev(n, theta[1], theta[2], theta[3])
pGEV <- function(x, theta) pgev(x, theta[1], theta[2], theta[3])
GEV_fit <- function( xdat, ...) gev.fit( xdat, ...)$mle
## (2) example with generalized Beta distribution of the second kind
require( "GB2")
rGB2 <- function(n, theta) rgb2(n, theta[1], theta[2], theta[3], theta[4])
pGB2 <- function(x, theta) pgb2(x, theta[1], theta[2], theta[3], theta[4])
GB2_fit <- function( xdat, ...) ml.gb2( xdat, ...)$opt1$par