This utility plots the HMM expected volatility of SPX overlaid with the VIX index adjusted by a ratio. The expected volatility is shown to have a long-term ratio of 0.79 relative to the VIX index. This plot will show how HMM deviates from VIX in a shorter time window. Optionally the insert shows the relation between the return and volatility indicated by each state. This plot is also called "volatility yield curve".
ldhmm.plot_spx_vix_obs(
object,
days.pa = 252,
start.date = NULL,
end.date = NULL,
px.origin = NULL,
px.scale = NULL,
vix.adj.ratio = NULL,
insert.plot = TRUE,
insert.viewport = NULL
)an ldhmm object with a stationary solution. If this is set to NULL,
an internal 10-state HMM object will be used.
a positive integer specifying trading days per year, default is 252.
Date or character of ISO format (YYYY-MM-DD),
specifying the start date of the plot, default is NULL, which is converted to 1.5 years ago.
Date or character of ISO format (YYYY-MM-DD),
specifying the end date of the plot, default is NULL, which means the latest date.
numeric, specifying the starting value of the index price line,
the default is NULL, which will start the index price line from the middle of y-axis.
numeric, specifying the scaling factor when plotting price trend, default is 15. The closing price is converted to cumulative return by the price of the first date. Then plot from the mid-point of volatility axis with this scale.
numeric, if specified, VIX index is adjusted and plotted, default is NULL.
Default is to use the long-term ratio between VIX and 10-state HMM, which is about 0.79.
logical, if true, also plot the volatility-return as insert in upper-right corner, default is TRUE.
optional viewport for the insert, default is NULL,
which is internally set to grid::viewport(.8, .75, .3, .3).
Stephen H. Lihn
if (FALSE) {
ldhmm.plot_spx_vix_obs(h)
}
Run the code above in your browser using DataLab