rRendata: Simulate a random RenData object

View source: R/randomRendata.R

rRendataR Documentation

Simulate a random RenData object

Description

Simulate a random RenData object that can be used within the Renouv function for tests.

Usage

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)

Arguments

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 POSIXct object, or character that can be coerced to POSIXct (e.g. a date given as a character in the "YYYY-MM-DD" format) giving the start of the main OT sample.

name

A name for the dataset which will be attached to it and be used by some methods for "Rendata".

varName

Name of the simulated variable.

varUnit

Unit for the simulated variable (is used by plot).

simDate

Logical. If TRUE the dates will be reported for the historical data (MAX and OTS).

roundDate

Logical. If TRUE the time part ot the date column will be rounded. Not implemented yet.

MAX.effDuration

Vector of the durations for the MAX historical blocks.

MAX.r

Vector of the (positive) numbers of observations for MAX historical blocks. Must have the same length as MAX.effDuration. See Caution below for the effect of selection large values.

OTS.effDuration

Vector of durations for the OTS historical blocks.

OTS.threshold

Vector of numerical thresholds for the observations in OTS historical blocks. Must have the same length as OTS.effDuration. All values must be >= threshold.

Details

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.

Value

An object with S3 class "Rendata". This class currently has plot and summary methods.

Caution

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.

Note

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.

Author(s)

Yves Deville

See Also

plot.Rendata, summary.Rendata.

Examples

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)

Renext documentation built on Aug. 30, 2023, 1:06 a.m.