Description Usage Arguments Details Author(s) See Also Examples
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.
1 2 3 |
x |
A |
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 |
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
).
David Luethi
fit.schwartz2f
for parameter estimation,
plot
-method for
schwartz2f
-objects.
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.