View source: R/randomRendata.R
rRendata | R Documentation |
Simulate a random RenData
object that can be used within the
Renouv
function for tests.
rRendata(lambda = 1,
threshold = 0,
effDuration = 100,
distname.y = "exp",
par.y = c(rate = 1),
start = "1913-01-01",
name = NULL,
varName = "X", varUnit = "?",
simDate = TRUE, roundDate = FALSE,
MAX.effDuration = NULL,
MAX.r = rep(1L, length(MAX.effDuration)),
OTS.effDuration = NULL,
OTS.threshold = NULL)
lambda |
The rate of the Homogeneous Poisson Process. |
threshold |
The threshold for the exceedances. |
effDuration |
The effective duration of the main Over Threshold (OT) period. This must be a positive value. |
distname.y |
Name of the distribution for the excesses to be simulated. See Details. |
par.y |
A named vector or list giving the parameters values for the distribution. The name must conform to the chosen distribution. |
start |
A |
name |
A name for the dataset which will be attached to it and be used by
some methods for |
varName |
Name of the simulated variable. |
varUnit |
Unit for the simulated variable (is used by plot). |
simDate |
Logical. If |
roundDate |
Logical. If |
MAX.effDuration |
Vector of the durations for the |
MAX.r |
Vector of the (positive) numbers of observations for |
OTS.effDuration |
Vector of durations for the |
OTS.threshold |
Vector of numerical thresholds for the observations in |
The distribution of the excesses named in distname.y
can be
any known distribution, provided that when prefixed with the usual
"r"
letter, the name gives the wanted simulation function. For
example, with distname.y = "exp"
, the rexp
function is
used and par.y
must thus contain an element with name
"rate"
.
When a suitable numeric threshold is given, the simulated marks of the
marked process are the sum of the threshold and of a random excess
drawn from distname.y
. When the threshold is not a finite
numeric value, the observed marks are the simulated values themselves.
The main OT sample is assumed to begin at start
. Historical MAX
blocks (if any) are assumed to be just before start
, and OTS
are just before start
or just before the beginning of the MAX
blocks when there are some. The dates are computed without taking
into consideration the problems of leap years or leap seconds.
An object with S3 class "Rendata"
. This class currently has
plot
and summary
methods.
By construction, each MAX
block contains at least one
observation, while a random period of the same duration might have
none. The simulated number of events on a MAX block is generated using
a censored Poisson distribution. Care must be taken when estimations
are made on such data, since creating MAX
blocks obviously
create a positive bias on lambda
. Such bias then also affects
the other parameters concerning the excesses, because these
parameters are no longer orthogonal to the rate parameter
lambda
when historical data are used. The bias can be severe if
MAX
blocks with small durations are used, or if large number of
events are chosen in MAX.r
.
When effDuration
is small relative to the inverse of
lambda
the number of simulated marks in the OT sample may be
0
which can cause problems for some uses of the created data.
Yves Deville
plot.Rendata
, summary.Rendata
.
set.seed(1234)
rd <- rRendata(effDuration = 60,
MAX.effDuration = rep(3, 6),
MAX.r = rep(4, 6),
distname.y = "exp", par.y = c(rate = 1/100))
plot(rd)
summary(rd)
rd2 <- rRendata(effDuration = 10,
MAX.effDuration = rep(60, 2),
MAX.r = rep(3, 2),
simDate = FALSE,
distname.y = "gpd", par.y = c(scale = 20, shape = 0.16))
plot(rd2)
rd3 <- rRendata(effDuration = 10,
OTS.effDuration = rep(60, 2),
OTS.threshold = rep(80, 2),
simDate = FALSE,
distname.y = "gpd", par.y = c(scale = 20, shape = 0.16))
plot(rd3)
## Renouv fit with historical data
fit <- Renouv(rd)
summary(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.