PIT: Probability integral transform.

View source: R/Pit.R

PITR Documentation

Probability integral transform.

Description

Method returning the probability integral transform (PIT).

Usage

PIT(object, ...)

## S3 method for class 'MSGARCH_SPEC'
PIT(
  object,
  x = NULL,
  par = NULL,
  data = NULL,
  do.norm = FALSE,
  do.its = FALSE,
  nahead = 1L,
  do.cumulative = FALSE,
  ctr = list(),
  ...
)

## S3 method for class 'MSGARCH_ML_FIT'
PIT(
  object,
  x = NULL,
  newdata = NULL,
  do.norm = TRUE,
  do.its = FALSE,
  nahead = 1L,
  do.cumulative = FALSE,
  ctr = list(),
  ...
)

## S3 method for class 'MSGARCH_MCMC_FIT'
PIT(
  object,
  x = NULL,
  newdata = NULL,
  do.norm = TRUE,
  do.its = FALSE,
  nahead = 1L,
  do.cumulative = FALSE,
  ctr = list(),
  ...
)

Arguments

object

Model specification of class MSGARCH_SPEC created with CreateSpec or fit object of type MSGARCH_ML_FIT created with FitML or MSGARCH_MCMC_FIT created with FitMCMC.

...

Not used. Other arguments to PIT.

x

Vector (of size n). Used when do.its = FALSE.

par

Vector (of size d) or matrix (of size nmcmc x d) of parameter estimates where d must have the same length as the default parameters of the specification.

data

Vector (of size T) of observations.

do.norm

Logical indicating if the PIT values are transformed into standard Normal variate. (Default: do.norm = FALSE)

do.its

Logical indicating if the in-sample PIT is returned. (Default: do.its = FALSE)

nahead

Scalar indicating the number of step-ahead evaluation. Valid only when do.its = FALSE. (Default: nahead = 1L)

do.cumulative

Logical indicating if the PIT is computed on the cumulative simulations (typically log-returns, as they can be aggregated). Only available for do.its = FALSE. (Default: do.cumulative = FALSE)

ctr

A list of control parameters:

  • nsim (integer >= 0): Number indicating the number of simulation done for the evaluation of the PIT at nahead > 1. (Default: nsim = 10000L)

newdata

Vector (of size T*) of new observations. (Default: newdata = NULL)

Details

If a matrix of MCMC posterior draws is given, the Bayesian probability integral transform is calculated. Two or more step-ahead probability integral transform are estimated via simulation of nsim paths up to t = T + T* + nahead. The empirical probability integral transforms is then inferred from these simulations.
If do.its = FALSE, the vector x are evaluated as t = T + T* + 1, ... ,t = T + T* + nahead realizations.
If do.its = TRUE, x is evaluated at each time t up to time t = T + T*.
Finally if x = NULL the vector data is evaluated for sample evaluation of the PIT.
The do.norm argument transforms the PIT value into Normal variates so that normality test can be done.

Value

A vector or matrix of class MSGARCH_PIT.
If do.its = FALSE: Probability integral transform of the points x at
t = T + T* + 1, ... ,t = T + T* + nahead or Normal variate derived from the probability integral transform of x (matrix of size nahead x n).
If do.its = TRUE: In-sample probability integral transform or Normal variate derived from the probability integral transform of data if x = NULL (vector of size T + T*) or in-sample probability integral transform or Normal variate derived from the probability integral transform of x (matrix of size (T + T*) x n).

Examples

# create model specification
spec <- CreateSpec()

# load data
data("SMI", package = "MSGARCH")

# fit the model on the data by ML
fit <- FitML(spec = spec, data = SMI)

# run PIT method in-sample
pit.its <- PIT(object = fit, do.norm = TRUE, do.its = TRUE)

# diagnostic of PIT with qqnorm
qqnorm(pit.its)
qqline(pit.its)

# simulate a serie from the model
set.seed(123)
sim.series <- simulate(object = spec, par = fit$par, nahead= 1000L, nsim = 1L)
sim.series <- as.vector(sim.series$draw)

# run PIT method on the simualed serie with the true par
pit.x <- PIT(object = spec, par = fit$par, data = sim.series, do.norm = TRUE, do.its = TRUE)
qqnorm(pit.x)
qqline(pit.x)

MSGARCH documentation built on Dec. 6, 2022, 1:06 a.m.