parameter-estimation(schwartz97)
parameter-estimation()所属R语言包:schwartz97
Schwartz 1997 two factor parameter estimation
施瓦茨1997年两个因素的参数估计
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Fit the Schwartz 1997 two factor commodity model to futures data.
适合1997年的施瓦茨两个因素的商品模型的期货数据。
用法----------Usage----------
fit.schwartz2f(data, ttm, deltat = 1 / 260,
s0 = data[1,1], delta0 = 0,
mu = 0.1, sigmaS = 0.3, kappa = 1, alpha = 0, sigmaE = 0.3,
rho = 0.7, lambda = 0,
meas.sd = rep(0.1, ncol(data)),
opt.pars = c(s0 = FALSE, delta0 = FALSE, mu = TRUE, sigmaS = TRUE,
kappa = TRUE, alpha = TRUE, sigmaE = TRUE,
rho = TRUE, lambda = FALSE),
opt.meas.sd = c("scalar", "all", "none"),
r = 0.03, silent = FALSE, ...)
参数----------Arguments----------
参数:data
A matrix with futures prices. NA-values are allowed.
矩阵与期货价格。 NA值是允许的。
参数:ttm
A matrix with the corresponding time to maturity (see Details).
一个矩阵,相应的到期时间(见详情)。
参数:deltat
Time increment (see Details).
时间增量(见详情)。
参数:s0
Initial value of the commodity spot price.
大宗商品现货价格的初始值。
参数:delta0
Initial value of the convenience yield.
便利收益的初始值。
参数:mu
Initial value of the drift parameter of the commodity spot price.
大宗商品现货价格的漂移参数的初始值。
参数:kappa
Initial parameter of the speed of mean-reversion of the convenience yield process.
均值回归的便利收益过程的速度的初始参数。
参数:alpha
Initial parameter of the mean-level of the convenience yield process.
初始参数方便收率过程的平均水平。
参数:sigmaS
Initial parameter of the diffusion parameter of the spot price process.
初始参数的现货价格过程中的扩散系数。
参数:sigmaE
Initial parameter of the diffusion parameter of the convenience yield process.
便利收益过程的扩散参数的初始参数。
参数:rho
Initial parameter of the correlation coefficient between the Brownian motion driving the spot price and the convenience yield process.
初始参数之间的相关系数的布朗运动驱动的现货价格和便利收益的过程。
参数:meas.sd
Initial parameter of the standard deviation of the measurement equation (see Details).
初始参数的标准偏差的测量方程(见详细情况)。
参数:lambda
Initial value of the market price of convenience yield risk.
初步价值的便利收益风险的市场价格。
参数:opt.pars
A logical vector giving the parameters which shall be fitted. The order is as given in the function header, names are discarded.
一个逻辑向量,应安装参数。给出的顺序中的函数头,名称将被丢弃。
参数:opt.meas.sd
States how the standard deviation of the measurement equation should be treated (see Details).
国的标准偏差的测量方程应如何处理(见详情)。
参数:r
Instantaneous risk-free interest rate.
瞬时无风险利率。
参数:silent
If FALSE the log-likelihood and parameters will be printed in each iteration.
如果FALSElog的可能性和参数将被印在每一次迭代。
参数:...
Arguments passed to optim.
传递参数到optim。
Details
详细信息----------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 (in units of deltat).
的元素data和ttm有如下解释:data[i,j]表示期货价格至到期日的时间是ttm[i,j],当它被观察到(单位deltat )。
The time increment between observation data[i,j] and data[i + 1,j] is denoted with deltat. Note that this specification requires a regularly spaced data series.
之间的时间增量观察data[i,j]和data[i + 1,j]表示deltat。请注意,本规范要求定期间隔的数据系列。
opt.meas.sd specifies how measurement uncertainty is treated in the fit: According to the model there should be a one-to-one correspondence between the spot and the futures price. In reality, the term structure does not fully match for any set of parameters. This is reflected in the measurement uncertainty-vector meas.sd. All components of meas.sd can be fitted. However, it might be sufficient to fit only a scalar where the measurement uncertainty is parametrized by scalar * meas.sd. In this case define the vector meas.sd and set opt.meas.sd to “scalar”. meas.sd can be set to a vector with each component set to, e.g., 2%, giving each point in the term structure equal weight. Another reasonable specification takes open interest or volumes into account: The higher the volume, the higher the weight and therefore the lower the corresponding component of meas.sd. If all components of meas.sd shall be fitted choose “all”. If the measurement uncertainty is known set meas.sd to “none”. Note that the measurement errors are assumed to be independent in this implementation (even though the model and the filter do not require independence).
opt.meas.sd指定如何测量不确定度在合适的处理:根据模型应该是一对现货和期货价格之间的对应关系。在现实中,期限结构不完全匹配,任何一组参数。这反映在测量不确定度向量meas.sd。可以安装所有组件meas.sd。但是,它可能是足够的,只适合一个标量的测量不确定度的参数化scalar * meas.sd。在这种情况下,定义向量meas.sd“,并设置opt.meas.sd”标量“。 meas.sd可以被设置为一个向量与每个组件设置为,例如,2%,给人期限结构相等的权重中的每个点。另一个考虑,合理规范未平仓合约或卷的音量越高,越高的重量,因此越低,相应的组件meas.sd。如果所有组件meas.sd应安装选择“全部”。如果测量的不确定性被称为设置meas.sd为“无”。请注意,在测量误差被假定为独立在此实现中(即使模型和过滤器不要求独立)。
The model and its parameters are described in the Details section of the schwartz2f-class documentation and in the package vignette Technical Document.
该模型及其参数的描述,在“详细信息”部分的schwartz2f级的文件和技术文件包中的小插曲。
值----------Value----------
An object of class schwartz2f.fit.
对象的类schwartz2f.fit。
注意----------Note----------
Parameter estimation is statistically fragile and computationally demanding. Multiple local maxima of the likelihood may exist which can result in absurd parameter estimates as, e.g., a yearly drift of 300% and or a market price of convenience yield risk of -200%. Therefore, a reasonable parameter estimation is most likely an iteration where several initial values are used and different combinations of parameters are held constant during estimation. Also, simulation studies showed that a fairly large sample is required to get adequate estimates (e.g. 20000 daily observations, depending on the number of parameters which shall be estimated). For this reason the default is to hold s0, delta0, and lambda constant.
参数估计是统计脆弱和计算能力的要求。多个局部可能存在极大的可能性,这可能会导致荒谬的参数估计值,例如,每年漂移的300%或-200%的的便利收益风险的市场价格。因此,一个合理的参数估计很可能是一个迭代数的初始值,使用不同的参数组合在估算过程中保持不变。此外,模拟研究表明,足够的估计数(例如20000每日观察应当估计的参数的数目),这取决于是需要得到一个相当大的样品。由于这个原因,默认情况下是保持s0,delta0和lambda不变。
Several utility functions may help to investigate the fit (see e.g. fitted, resid, plot, coef).
几个实用程序可以帮助飞度(如:fitted,resid,plot,coef)。
The fitting procedure generally requires a large number of iterations to achieve a reasonable tolerance level. Each optimization iteration involves the filtering of the data set by the Kalman filter. Therefore, an efficient implementation of the Kalman filter is key. Hence, the fkf function of the package FKF can be considered as the backbone of the estimation procedure.
的拟合过程通常需要大量的迭代,以达到一个合理的公差水平。每一步优化迭代涉及的数据集的卡尔曼滤波器的滤波。因此,有效地实现了卡尔曼滤波器是关键。因此,fkf功能的包FKF可以考虑为骨干的估计过程。
(作者)----------Author(s)----------
Philipp Erb, David Luethi, Juri Hinz
参考文献----------References----------
Valuation and Hedging by Eduardo S. Schwartz <br> Journal of Finance 52, 1997, 923-973
参见----------See Also----------
schwartz2f.fit class, fitted, resid, plot, coef), pricefutures, futures-data.
schwartz2f.fit类,fitted,resid,plot,coef)pricefutures,futures-data。
实例----------Examples----------
data(futures)
## Estimate parameters for wheat data.[#参数估计的小麦数据。]
## (little precision required with reltol = 1e-3)[#(小,精度要求与RELTOL = 1E-3)]
fit.obj <- fit.schwartz2f(futures$wheat$price, futures$wheat$ttm / 260,
deltat = 1 / 260, control = list(reltol = 1e-3))
## See how parameter values evolved during the fit[#请参阅如何在合适的参数值进化]
plot(fit.obj, type = "trace.pars")
## Not run: [#不运行:]
## Do the same but with lower tolerance level:[#执行相同的操作,但较低的公差等级:]
high.precision.fit <- fit.schwartz2f(futures$wheat$price, futures$wheat$ttm / 260,
control = list(maxit = 3000, reltol = 5e-8))
high.precision.fit
plot(high.precision.fit, type = "trace.pars") # ...concerning parameter evolution.[...有关参数演化。]
## Alpha becomes nonsensically high, kappa (speed of mean-reversion[#阿尔法变得荒谬的高,KAPPA(均值回归速度]
## of the convenience yield) goes to zero. Solution: Choose different[#方便收率)变为零。解决方案:选择不同的]
## initial values and/or hold kappa constant at 1.[#初始值和/或保持在1κ恒定。]
constrained.fit <- fit.schwartz2f(futures$wheat$price, futures$wheat$ttm / 260,
opt.pars = c(s0 = FALSE, delta0 = FALSE, mu = TRUE,
sigmaS = TRUE, kappa = FALSE, alpha = TRUE,
sigmaE = TRUE, rho = TRUE, lambda = TRUE),
alpha = 0, kappa = 1,
control = list(maxit = 3000, reltol = 5e-8))
constrained.fit
plot(constrained.fit, type = "trace.pars")
## The above parameters based on a fit - where kappa was held constant at 1 -[#以上参数基于一个合适的 - 卡巴保持不变在1 - ]
## look more reasonable.[#看起来更合理。]
## End(Not run)[#(不执行)]
## These residuals should be iid standard normal[#这些残差应独立同分布的标准正态]
model.resid <- resid(fit.obj, data = futures$wheat$price, ttm = futures$wheat$ttm / 260,
type = "filter.std")
acf(model.resid, na.action = na.pass)
par(mfrow = c(3, 2))
apply(model.resid, 2, function(x)plot(density(na.omit(x))))
## ...but are anything but iid standard normal.[#...是什么,但独立同分布的标准正态分布。]
## ...though the fitted values look fine:[#...虽然看起来很好的拟合值:]
fitted.futures <- fitted(fit.obj, futures$wheat$price, futures$wheat$ttm / 260)
par(mfrow = c(1, 3))
### Plot futures prices[##图期货价格]
plot(as.ts(futures$wheat$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$wheat$price) / fitted.futures), plot.type = "single",
ylab = "Relative difference", col = gray(seq(0.1, 0.9, length = 4)))
## Try with kappa = 1, alpha = 0, and flexible standard deviationss of[#试用与Kappa值= 1,α= 0,和灵活的标准deviationss的影响]
## the measurement errors. Stop at 200 iterations.[#测量误差。在200次迭代停止。]
fit.obj.2 <- fit.schwartz2f(futures$wheat$price, futures$wheat$ttm / 260,
opt.pars = c(s0 = FALSE, delta0 = FALSE, mu = TRUE,
sigmaS = TRUE, kappa = FALSE, alpha = FALSE,
sigmaE = TRUE, rho = TRUE, lambda = TRUE),
alpha = 0, kappa = 1, opt.meas.sd = "all",
deltat = 1 / 260, control = list(maxit = 200))
model.resid.2 <- resid(fit.obj.2, data = futures$wheat$price, ttm = futures$wheat$ttm / 260,
type = "filter.std")
## Residuals seem to be better:[#残差似乎是更好的:]
acf(model.resid.2, na.action = na.pass)
par(mfrow = c(3, 2))
apply(model.resid.2, 2, function(x)plot(density(na.omit(x))))
## The schwartz2f.fit-object 'fit.obj' can be used to do further calculations as[#schwartz2f.fit - 的对象的fit.obj“可以用来做进一步的计算]
## pricing a put option on the wheat futures which matures in 1.1[#对小麦期货价格的认沽期权到期1.1]
## years. The option expires in 1 year. The strike price is the[#年。该选项在1年内到期。行使价是]
## expected futures price in 1.1 years.[#预计期货价格在1.1年。]
priceoption("put", time = 1, Time = 1.1, K = pricefutures(1.1, fit.obj),
fit.obj)
## Parameter estimation for weekly soybean meal data:[#参数估计每周豆粕数据:]
## Get Wednesday observations:[#周三观察:]
futures.w <- rapply(futures, function(x)x[format(as.Date(rownames(x)), "%w") == 3,],
classes = "matrix", how = "list")
## Estimate soybean meal parameters (stop after 500 iterations).[#估计豆粕参数(500次迭代后停止)。]
## ttm (time-to-maturity) is divided by 260 as it is in unit of days and[TTM(至到期日的时间)除以260,因为它以天为单位,]
## deltat = 1/52 because weekly price observations are used.[#则DeltaT = 1/52,因为每周价格观察。]
## Estimate all measurement error standard deviations (opt.meas.sd == "all"),[估计所有的测量误差标准偏差:(opt.meas.sd ==“所有”),]
## but hold kappa, alpha, and lambda constant.[#但持有卡伯值,α,和lambda不变的。]
soybean.meal.fit <- fit.schwartz2f(data = futures.w$soybean.meal$price,
ttm = futures.w$soybean.meal$ttm / 260,
opt.meas.sd = "all",
mu = 0, kappa = 1, alpha = 0.03, r = 0.04,
opt.pars = c(s0 = FALSE, delta0 = FALSE, mu = TRUE,
sigmaS = TRUE, kappa = FALSE, alpha = FALSE,
sigmaE = TRUE, rho = TRUE, lambda = FALSE),
deltat = 1 / 52, control = list(maxit = 500))
soybean.meal.fit
plot(soybean.meal.fit, type = "trace.pars") # plot the parameter evolution[绘制参数演化]
## Plot real and predicted forward curves:[#图的实际和预测的远期曲线:]
par(mfrow = c(1, 2))
futuresplot(futures.w$soybean.meal, type = "forward.curve")
plot(soybean.meal.fit, type = "forward.curve", data = futures.w$soybean.meal$price,
ttm = futures.w$soybean.meal$ttm / 260)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|