Description Usage Arguments Details Value Author(s) References See Also Examples
Filter a series of futures prices to obtain state variables.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## S4 method for signature 'ANY,ANY,numeric'
filter.schwartz2f(data, ttm, s0 = 50, delta0 = 0,
mu = 0.1, sigmaS = 0.3, kappa = 1, alpha = 0, sigmaE = 0.5,
rho = 0.75, r = 0.05, lambda = 0, alphaT = NULL,
deltat = 1/260, meas.sd = rep(1e-3, ncol(data)),
P0 = 0.5 * diag(c(log(s0), abs(delta0))))
## S4 method for signature 'ANY,ANY,schwartz2f'
filter.schwartz2f(data, ttm, s0,
r = 0.05, lambda = 0, alphaT = NULL, deltat = 1/260,
meas.sd = rep(1e-3, ncol(data)),
P0 = 0.1 * diag(2))
## S4 method for signature 'ANY,ANY,schwartz2f.fit'
filter.schwartz2f(data, ttm, s0)
|
data |
A matrix with futures prices. |
ttm |
A matrix with the corresponding time to maturity (see Details). |
s0 |
Either a |
delta0 |
Initial value of the convenience yield. |
mu |
enters the drift of the commodity spot price. |
sigmaS |
Diffusion parameter of the spot price process. |
kappa |
Speed of mean-reversion of the convenience yield process. |
alpha |
Mean-level of the convenience yield process. |
sigmaE |
Diffusion parameter of the convenience yield process. |
rho |
Correlation coefficient between the Brownian motion driving the spot price and the convenience yield process. |
r |
Instantaneous risk-free interest rate. |
lambda |
Market price of convenience yield risk. |
alphaT |
Mean-level of the convenience yield process with respect to the equivalent martingale measure. |
deltat |
Time increment. |
meas.sd |
The standard deviation of the measurement equation (see
Details section of |
P0 |
Variance of the state variables |
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
is defined by deltat
.
deltat
is the time between observation data[i,j]
and
data[i + 1,j]
. It is assumed to be constant, i.e., that
data
is a regular time-series.
A list with components:
state | A matrix with colnames are “S” and
“delta” giving the the expected spot price and the
convenience yield. |
fkf.obj | The filter output from the package
fkf . Note that the log of the commodity spot
price is filtered. |
Philipp Erb, David Luethi, Juri Hinz
The Stochastic Behavior of Commodity Prices: Implications for
Valuation and Hedging by Eduardo S. Schwartz
Journal of Finance
52, 1997, 923-973
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # data(futures)
#
# ## Estimate parameters for coffee data (stop after 20 iterations)
# fit.obj <- fit.schwartz2f(futures$coffee$price, futures$coffee$ttm / 260,
# deltat = 1 / 260, control = list(maxit = 20))
#
# ## Filter the futures data to get the spot price and the convenience yield.
# filtered <- filter.schwartz2f(futures$coffee$price, futures$coffee$ttm / 260, fit.obj)
#
# ## ...and plot it.
# par(mfrow = c(2, 1))
# plot(filtered$state[,1], ylab = "Spot price", type = "l")
# lines(futures$coffee$price[,1], col = "red") # Closest to maturity futures
# plot(filtered$state[,2], ylab = "Convenience yield", type = "l")
# abline(h = 0)
|
Loading required package: FKF
Loading required package: RUnit
Loading required package: mvtnorm
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.