Learn R Programming

SVDNF (version 0.1.10)

plot.SVDNF: DNF Filtering Distribution Plot Function

Description

This function plots the median of the filtering and prediction distributions estimated from the DNF along with user-selected upper and lower percentiles.

Usage

# S3 method for SVDNF
plot(x, lower_p = 0.05, upper_p = 0.95, tlim = 'default', type = "l",
  location = 'topright', ...)

Value

No return value; this function generates two plots.

The first has the median of the volatility factor obtained from the prediction distribution as well as its upper and lower percentiles from lower_p and upper_p.

The second has the median of the volatility factor obtained from the filtering distribution as well as its upper and lower percentiles from lower_p and upper_p.

Arguments

x

An SVDNF object. The plot plots the median and selected percentiles from the filtering distribution.

lower_p

Lower percentile of the filtering distribution to plot.

upper_p

Upper percentile of the filtering distribution to plot.

tlim

The tlim argument gives the range over which to plot the filtering and prediction distributions are displayed.

For example to plot the first 500 steps, set tlim = c(1, 500). By default, filtering and prediction distribution estimates for every step in the time-series are generated.

If tlim is set to a single number (e.g., tlim = c(5)), plot graphs the estimated probability density functions of the filtering (in magenta) and prediction (in blue) distributions at that timestep.

If the data are passed in an xts object, standard date-based subsetting can be used for subsetting (e.g., setting tlim = "2005" to get the filtering and prediction distributions for that year).

location

Location keyword passed to the legend function to determine the location of the legend. The keyword should be selected from the list "bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right", and "center".

type

Line type argument passed to the plot function. See help(plot.default) for more details.

...

Other parameters to be passed through to function.

Examples

Run this code
set.seed(1)
# Generate 500 returns from the Bates model.
Bates_mod <- dynamicsSVM(model = "Bates")
Bates_sim <- modelSim(t = 500, dynamics = Bates_mod)

# Runs DNF on the data.
dnf_filter <- DNF(data = Bates_sim$returns, dynamics = Bates_mod)

# Plot whole interval (default)
plot(dnf_filter, ylim = c(0, 0.15),
ylab = "Volatility Factor", xlab = 'Time')

# Plot specific interval
tlim <- c(100,350)
plot(dnf_filter, ylim = c(0, 0.15),
  ylab = "Volatility Factor", xlab = 'Time', tlim = tlim)

# Plot specific point 
tlim <- c(100)
plot(dnf_filter, ylim = c(0, 0.15), type = 'l',
  ylab = "Volatility Factor", xlab = 'Time', tlim = tlim)

Run the code above in your browser using DataLab