Learn R Programming

ReturnCurves (version 1.0.1)

margtransf: Marginal Transformation

Description

Marginal transformation of a bivariate random vector to standard exponential margins following ColesTawn1991;textualReturnCurves. Variables within each margin are assumed identically distributed.

Usage

margtransf(data, qmarg = rep(0.95, 2), constrainedshape = TRUE)

Value

An object of S4 class margtransf.class. This object returns the arguments of the function, a slot parameters containing a matrix with the shape and scale parameters of the Generalised Pareto Distribution (GPD) for each variable, a slot thresh containing a vector with the threshold uu above which the GPD is fitted, and a slot dataexp containing a matrix with the data on standard exponential margins.

The plot function takes an object of S4 class margtransf.class, and a which argument specifying the type of plot desired (see Examples):

"hist"

Plots the marginal distributions of the two variables on original and standard exponential margins.

"ts"

Plots the time series of the two variables on original and standard exponential margins.

"joint"

Plots the joint distribution of the two variables on original and standard exponential margins.

"all"

Plots all the above mentioned plots (default).

Arguments

data

A matrix containing the data on the original margins.

qmarg

A vector containing the marginal quantile used to fit the Generalised Pareto Distribution (GPD) for each variable. Default is rep(0.95, 2).

constrainedshape

Logical. If TRUE (Default), the estimated shape parameter of the Generalised Pareto Distribution (GPD) is constrained to lie strictly above -1.

Details

Given a threshold value uu, each stationary random vector is transformed by using the empirical cumulative distribution function (cdf) below uu, and a Generalise Pareto Distribution (GPD) fit above uu.

The option to constrain > -1 is included as -1 implies that the fitted upper endpoint of the distribution's support is the maximum data point. This situation is rarely encountered in practice.

References

Examples

Run this code
library(ReturnCurves)

data(airdata)

n <- dim(airdata)[1]

margdata <- margtransf(airdata)

# Plots the marginal distributions of X and Y on original vs standard exponential margins
plot(margdata, which = "hist") 

# Plots the time series of X and Y on original vs standard exponential margins
plot(margdata, which = "ts") 

# Plots the joint distribution of X and Y on original vs standard exponential margins
plot(margdata, which = "joint") 

# Plots all the available plots
plot(margdata, which = "all") 

# To see the the S4 object's slots
str(margdata)

# To access the matrix with the data on standard exponential margins
margdata@dataexp

Run the code above in your browser using DataLab