Description Usage Arguments Details Value Author(s) See Also Examples
Function to extract fitted values from
schwartz2f.fit
-objects.
1 2 |
object |
A |
data |
A matrix with futures prices. |
ttm |
A matrix with the corresponding times to maturity (see Details). |
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 unit of
ttm
was defined by the argument deltat
of
fit.schwartz2f
.
A matrix containing the fitted values of the same dimension as
data
.
Philipp Erb, David Luethi, Juri Hinz
fit.schwartz2f
, schwartz2f.fit
-class,
resid
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # data(futures)
#
# ## Estimate parameters for lumber data. Fit only 'mu', 'sigmaS',
# ## 'sigmaE', and 'rho' (and stop after 100 iterations).
# fit.obj <- fit.schwartz2f(futures$lumber$price, futures$lumber$ttm / 260,
# opt.pars = c(s0 = FALSE, delta0 = FALSE, mu = TRUE,
# sigmaS = TRUE, kappa = FALSE, alpha = FALSE,
# sigmaE = TRUE, rho = TRUE, lambda = FALSE),
# alpha = 0, kappa = 1.2, lambda = 0,
# deltat = 1 / 260, control = list(maxit = 100))
# fit.obj
#
# ## Get the fitted values
# fitted.futures <- fitted(fit.obj, futures$lumber$price, futures$lumber$ttm / 260)
#
# par(mfrow = c(1, 3))
# ## Plot futures prices
# plot(as.ts(futures$lumber$price), plot.type = "single", ylab = "Futures prices",
# col = gray(seq(0.1, 0.9, length = 4)))
# ## Plot fitted values
# plot(as.ts(fitted.futures), plot.type = "single", ylab = "Fitted values",
# col = gray(seq(0.1, 0.9, length = 4)))
# ## Plot relative difference
# plot(as.ts((fitted.futures - futures$lumber$price) / fitted.futures), plot.type = "single",
# ylab = "Relative difference", col = gray(seq(0.1, 0.9, length = 4)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.