楼主: sarah89323
16919 72

[问答] 跪求CKLS GMM法参数估计T_T [推广有奖]

  • 0关注
  • 0粉丝

大专生

28%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
1 点
热心指数
1 点
信用等级
1 点
经验
330 点
帖子
40
精华
0
在线时间
59 小时
注册时间
2010-2-25
最后登录
2013-10-7

楼主
sarah89323 发表于 2011-8-23 22:57:30 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
有大牛可以请教一下如何使用GMM library Matlab么?
已经使用了Norman Gaussian Estimation using MLE
希望能再用GMM做calibration 得到参数后做simulation对比how well it fit historical data compared to MLE.
已经下了GMM library matlab, 但不知如何使用, 望指教!!
QQ 86504728
隐身等待大牛出现
keep hoping :)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:ckls 参数估计 GMM calibration historical library matlab 如何

本帖被以下文库推荐

沙发
epoh 发表于 2011-8-25 15:46:54
gmm_with_R.pdf
  http://cran.r-project.org/web/packages/gmm/vignettes/gmm_with_R.pdf
3.1. Estimating the parameters of a normal distribution
# Implementing the 3 moment conditions
g <- function(tet, x)
{
m1 <- (tet[1] - x)
m2 <- (tet[2]^2 - (x - tet[1])^2)
m3 <- x^3 - tet[1]*(tet[1]^2 + 3*tet[2]^2)
f <- cbind(m1, m2, m3)
return(f)
}
# Implementing the jacobian
Dg <- function(tet, x)
{
jacobian <- matrix(c( 1, 2*(-tet[1]+mean(x)), -3*tet[1]^2-3*tet[2]^2,0, 2*tet[2],-6*return(jacobian)
}
# Now we want to estimate the two parameters using the GMM.
gmm(g, x, c(0, 0), grad = Dg)

感觉跟楼主要做的很像.

先供楼主参考.


已有 2 人评分学术水平 热心指数 信用等级 收起 理由
日新少年 + 1 + 1 + 1 精彩帖子
ywh19860616 + 1 + 1 + 1 epoh老师,这个GMM在plm包里面应该也有

总评分: 学术水平 + 2  热心指数 + 2  信用等级 + 2   查看全部评分

藤椅
ywh19860616 发表于 2011-8-25 16:48:05
experiment     t.dat;                    % load data on votes
hessz          : Calculate/update Inverse Hessian
lsfunc         : Evaluate least squares function m(b)'Wm(b) at b
lsgrad         : Evaluate M(b)'Wm(b) Gradient of objective function
minz           : minimize general function.  Special applications
nllsrho_minz   e of moment conditions
nllsrho_minz2  e to Calculate Spatial error parameter
numz           : Evaluate numerical derivs in MINZ package
prt_gmm        : Prints output of sem_gmm, sar_gmm, sac_gmm
sac_gmm        : computes Generalized Moments Estimates for general spatial model
sac_gmmd       : An example of using sac_gmm
sac_gmmd2      : An example of using sac_gmm on a large data set   
sar_gmm        : computes Generalized Moments Estimates for Spatial Autoregressive Model
sar_gmmd       : An example of using sar_gmm
sar_gmmd2      : An example of using sar_gmm on a large data set   
sar_gmmd3      : An example of using sar_gmm on a simulated large data set   
sar_gmmd4      : An example of using sar_gmm on a simulated large data set   
sar_gmmd5      : An example of using sar_gmm on a simulated large data set   
sem2_gmm       : computes Method of Moments Estimates for Spatial Error Model
sem2_gmmd      : An example of using sem2_gmm
sem_gmm        : computes GMM Estimates for Spatial Error Model
sem_gmmd       : An example of using sem_gmm
sem_gmmd2      : An example of using sem_gmm,sem2_gmm on a large data set   
sem_gmmd3      : A Monte Carlo comparison of sem_gmm and ML sem
sem_gmmd4      : A Monte Carlo example of using sem_gmm
sem_mcarlo     : A Monte Carlo comparison of GMM sem and ML sem
sem_monte1     : A DEMO FILE CONTAINS A MONTE CARLO SIMULATION for sem_gmm
sem_monte2     : A DEMO FILE CONTAINS A MONTE CARLO SIMULATION for sem2_gmm
step2          : Determine step size in NUMZ package
一份耕耘,一份收获。

板凳
ywh19860616 发表于 2011-8-25 16:50:03
pls see D:\...\jplv7\spatial\gmm_models in detail
Hope you can give the detail model.Is spatial econometric or ..?
一份耕耘,一份收获。

报纸
sarah89323 发表于 2011-8-31 06:05:37
ywh19860616 发表于 2011-8-25 16:50
pls see D:\...\jplv7\spatial\gmm_models in detail
Hope you can give the detail model.Is spatial eco ...
Hey, thxs for replying:)

I am doing a interest rate model: the CKLS model right now. It nests a range of different one-factor models. I figured out how to do it with GMM now, thanking to your advice.
But a new problem occurs, which bothers me pretty much... I want to do t-test, chi-square test and get p- value by setting 95% confidence level.  But i get stuck on these problems. Do u have any suggestions?

Thxs again

地板
sarah89323 发表于 2011-8-31 06:06:39
epoh 发表于 2011-8-25 15:46
gmm_with_R.pdf
  http://cran.r-project.org/web/packages/gmm/vignettes/gmm_with_R.pdf
3.1. Estimati ...
Thanks for ur help :))

7
epoh 发表于 2011-8-31 13:54:03

你要的数据,程序不是都有帮你带出?

Ex:Estimate the CIR model

EVALUATING S at FINAL PARAMETER ESTIMATES

  ------------------  GMM PARAMETER ESTIMATES  -----------------
  Parameter        Coeff    Std Err   Null   t-stat    p-val
  alpha         0.028733   0.013869   0.00     2.07   0.0383
  beta         -0.420795   0.242914   0.00    -1.73   0.0832
  sigma^2       0.006557   0.001677   0.00     3.91   0.0001

  -------------------  GMM MOMENT CONDITIONS  ------------------
                    Moment    Std Err   t-stat    p-val
     Moment 1     0.000061   0.000033     1.83   0.0679
     Moment 2    -0.000007   0.000004    -1.83   0.0680
     Moment 3     0.000029   0.000016     1.83   0.0680
     Moment 4     0.000004   0.000002     1.83   0.0680

      J-stat = 4.0487    Prob[Chi-sq.(1) > J] = 0.0442
%%%%%%%%%%%

当然你也可以自己算.

PARAMETERS Std Err
sqrt(diag(gout.bcov))
ans =

    0.0139
    0.2429
    0.0017

%%%%%%%%%%
Ex: Estimate Nine Nested Models
                   alpha    beta     Sigma^2    gamma
Full              0.0419   -0.6077    1.7788    1.5081
                ( 0.0159) ( 0.2698) ( 2.9056) ( 0.3135)

Merton            0.0051    0.0000    0.0004    0.0000
                           ( 0.0034)           ( 0.0001)         

Vasicek           0.0301   -0.4485    0.0004    0.0000
                ( 0.0141) ( 0.2468) ( 0.0001)         

CIR SR            0.0287   -0.4208    0.0066    0.5000
                ( 0.0139) ( 0.2429) ( 0.0017)         

Dothan            0.0000    0.0000    0.1061    1.0000
                                    ( 0.0219)         

GBM               0.0000    0.0772    0.1034    1.0000
                          ( 0.0603) ( 0.0224)         

Brennan-Schwarz   0.0316   -0.4527    0.1139    1.0000
                ( 0.0140) ( 0.2434) ( 0.0222)         

CIR VR            0.0000    0.0000    1.4687    1.5000
                                     ( 0.2569)         

CEV               0.0000    0.0805    0.6898    1.3579
                          ( 0.0615) ( 1.4675) ( 0.4076)

                      J_T   p-value   df    R^2_1    R^2_2
Full               0.0000              0   0.0266   0.1576
Merton             4.8451    0.0887    2   0.0000   0.0000
Vasicek            4.3807    0.0363    1   0.0145   0.0000
CIR SR             4.0487    0.0442    1   0.0128   0.0038
Dothan             7.0385    0.0707    3   0.0000   0.0282
GBM                5.7120    0.0575    2   0.0004   0.0268
Brennan-Schwarz    1.9755    0.1599    1   0.0148   0.0325
CIR VR             7.1974    0.0659    3   0.0000   0.1145
CEV                5.5478    0.0185    1   0.0005   0.0761

已有 3 人评分学术水平 热心指数 信用等级 收起 理由
日新少年 + 1 + 1 + 1 精彩帖子
zhangtao + 5 + 5 + 5 好的意见建议
ywh19860616 + 2 + 2 + 2 非常赞同

总评分: 学术水平 + 8  热心指数 + 8  信用等级 + 8   查看全部评分

8
zhangtao 发表于 2011-8-31 15:40:59
epoh 发表于 2011-8-31 13:54
你要的数据,程序不是都有帮你带出?Ex:Estimate the CIR model EVALUATING S at FINAL PARAMETER ESTIMATES  ...
epoh老师,您好!
     您的估计结果用的程序和结果能粘上来,我看看吗?
这些结果不知道具体的程序和数据,所以很难看懂。
非常感谢!
数学好就是要天天学

9
epoh 发表于 2011-8-31 18:35:29

哈哈zhangtao兄也有兴趣.

GMM Libraries for Matlab:

主网站目前已不提供下载

http://www.feweb.vu.nl/econometriclinks/mcliffprogs.html

但可由底下帖子免费下载

https://bbs.pinggu.org/forum.php?mod=viewthread&tid=114904&highlight=gmm

执行文件:ckls_d.m

但由于matlab版本更新

ckls_d.m请修改底下两行

% --- Estimate Nine Nested Models -------------

gmmopt.prt = 0;      -->gmmopt.prt = 1;

gmmopt.infoz.prt = 0;-->gmmopt.infoz.prt = 1;

否则fprintf会产生错误信息.

%%%%%%%%%%%%%%%%%%

相同数据ckls.dat,也有S-plus code.

Modelling Financial Time Series with S-PLUS
chap21. Generalized Method of Moments
21.7.5 Interest Rate Diffusion Model
#ckls
ckls.moments <- function(parm, data = NULL,dt = 1/12) {
# parm = (alpha,beta,sigma,gamma)’
# data = [r(t+dt)-r(t),r(t)]
# dt = discretization step
e.hat = as.vector(data[,1] -(parm[1] + parm[2]*data[,2])*dt)
m2 = e.hat*as.vector(data[,2])
m3 = e.hat^2 - dt*parm[3]*parm[3]*(as.vector(data[,2])^(2*parm[4]))
m4 = m3*data[,2]
cbind(e.hat,m2,m3,m4)
}
data.ckls.ts = seriesMerge(diff(ckls.ts), tslag(ckls.ts))
colIds(data.ckls.ts)[1] = "RF.diff"
data.ckls = as.matrix(seriesData(data.ckls.ts))
summaryStats(data.ckls)
start.vals = c(0.06,-0.5,1,1)
names(start.vals) = c("alpha","beta","sigma","gamma")
gmm.ckls = GMM(start.vals,ckls.moments,ts = T,data = data.ckls,dt = 1/12)
summary(gmm.ckls)

####
#GMM estimates for the restricted models cir
cir.moments <- function(parm, data = NULL, dt = 1/12) {
# parm = (alpha,beta,sigma)’
# data = [r(t+dt)-r(t),r(t)]
# dt = discretization step
e.hat = as.vector(data[,1] -(parm[1] + parm[2]*data[,2])*dt)
m2 = e.hat*as.vector(data[,2])
m3 = e.hat^2 - dt*parm[3]*parm[3]*(as.vector(data[,2]))
m4 = m3*data[,2]
cbind(e.hat,m2,m3,m4)
}
start.vals = c(0.06,-0.5,1)
names(start.vals) = c("alpha","beta","sigma")
gmm.cir = GMM(start.vals, cir.moments, ts = T,data = data.ckls, dt = 1/12)
summary(gmm.cir,print.moments = F)

已有 2 人评分学术水平 热心指数 信用等级 收起 理由
zhangtao + 5 + 5 + 5 非常感谢epoh大师!
sarah89323 + 1 + 1 + 1 very helpful

总评分: 学术水平 + 6  热心指数 + 6  信用等级 + 6   查看全部评分

10
sarah89323 发表于 2011-8-31 21:37:33
epoh 发表于 2011-8-31 18:35
哈哈zhangtao兄也有兴趣.GMM Libraries for Matlab:主网站目前已不提供下载 http://www.feweb.vu.nl/econom ...
谢谢epoh老师, 不知道是否对Nowman Gaussian estimation 做CKLS 也有研究?我用matlab编写的code运行有问题,方便的话,可否指教。

Besides, 想请问你给的表格中t-stat和p-val 是通过library的哪个code得出?针对MLE method, 是否通用呢?

希望能加QQ to discuss more. Thxs!!

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-3 01:02