schwartz97plotfit: Plot Schwartz two-factor fit-objects

Description Usage Arguments Details Author(s) See Also Examples

Description

This function plots the parameter evolution during the fit, the filtered state variables (i.e. the spot price and the convenience yield), forward curves, or trajectories of the state variables.

Usage

1
2
3
## S4 method for signature 'schwartz2f.fit,missing'
plot(x, type = c("trace.pars", "state", "forward.curve", "sim"),
     data, ttm, ...)

Arguments

x

A schwartz2f.fit object.

type

What shall be plotted (see Details).

data

A matrix containing futures prices to which parameters were fitted.

ttm

A matrix with the corresponding time to maturity (see Details).

...

Arguments passed to plot.

Details

If type == "trace.pars", the parameter evolution of the estimation is plotted. The horizontal lines denote the final value.
If type == "state", the filtered state variables are plotted and overlaid with the futures prices.
If type == "forward.curve", fitted forward curves are plotted.
If type == "sim", a bunch of simulated trajectories of the state variables are plotted.

The elements of data and ttm have the following interpretation: data[i,j] denotes the futures price whose time to maturity was ttm[i,j] when it was observed. The time unit was defined by the argument deltat of the function fit.schwartz2f (stored in x@deltat).

Author(s)

David Luethi

See Also

fit.schwartz2f for parameter estimation, plot-method for schwartz2f-objects.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# data(futures)
# 
# ## Estimate parameters for lumber data (stop after 100 iterations)
# fit.obj <- fit.schwartz2f(futures$lumber$price, futures$lumber$ttm / 260,
#                           deltat = 1 / 260,
#                           control = list(maxit = 100))
# 
# ## Plot parameter evolution
# plot(fit.obj, type = "trace.pars")
# 
# ## Plot the state variables
# plot(fit.obj, type = "state", data = futures$lumber$price,
#      ttm = futures$lumber$ttm / 260)
# 
# ## Plot fitted and real forward curves of wheat data since Jan 2010.
# lumber.1995 <- lapply(futures$lumber, function(x)x[as.Date(rownames(x)) < "2000-01-01",])
# par(mfrow = c(1, 2))
# plot(fit.obj, type = "forward.curve", data = lumber.1995$price,
#      ttm = lumber.1995$ttm / 260)
# futuresplot(lumber.1995)
# 
# ## Plot trajectories from the state variables
# plot(fit.obj, type = "sim")

schwartz97 documentation built on May 29, 2017, 12:18 p.m.