[程式] 關於RATs跑雙變量ANST-GARCH

看板Statistics作者 (哈)時間14年前 (2011/10/12 11:11), 編輯推噓1(102)
留言3則, 2人參與, 最新討論串1/1
[軟體程式類別]: RATs [程式問題]: ANST-GARCH [軟體熟悉度]: 中(3個月到1年) [問題敘述]: 想請問有沒有人寫過雙變量ANST-GARCH的程式碼 因為最近在寫這個程式碼的時候遇到了一個奇怪的問題 就是跑一次程式碼跟跑第二次會跑出不同的結果 但是如果有關閉RATs程式之後,再重跑一次結果又會跟原本第一次的結果相同 我是以之前寫的雙變量GARCH-M模型當作基礎, 再加入smooth transition function的部分 [程式範例]: compute n=2 compute gstart=1,gend=1555 * dec series[vect] Y dec frml[vect] R dec vect[series] U(n) dec series[vect] ECT * * The paths of the covariance matrices and uu' are saved in the * SERIES[SYMM] named H and UU. UX and HX are used for the current values * of the residual vector and H matrices * declare series[symm] G uu * * ux is used when extracting a u vector * declare symm Gx(n,n) declare vect ux(n) * * These will be the parameters for the mean equations. These are adjusted to add * variance or covariance terms as needed. * dec vect EC(n) C1(n) C2(n) C3(n) dec rect T1(n,n) T2(n,n) T3(n,n) F1(n,n) F2(n,n) F3(n,n) dec frml[vect] Ts dec frml[vect] Tf dec frml[symm] Vs dec frml[symm] Vf * *construct a error correct term * linreg LSP / ECTEQ # constant LF1M gset ECT = ||ECTEQ,ECTEQ|| nonlin(parmset=standmean) EC C1 T1 F1 C2 C3 T2 T3 F2 F3 nonlin(parmset=transmean) L * * Mean model = VAR(1) with sqrt(G) "M" term * frml R = Y-EC.*ECT{1}-C1-C2.*Ts-C3.*Tf-T1*Y{1}-T2*Y{1}.*Ts-T3*Y{1}.*Tf-F1*%sqrt(%xdiag(G))-F2*%sqrt(%xdiag(G)).*Ts-F3*%sqrt(%xdiag(G)).*Tf gset Y = ||dLSP|dLF1M|| * * Run preliminary VAR(1) to get estimates of residuals * * linreg dLSP / u(1) # constant dLSP{1} dLF1M{1} ecteq{1} linreg dLF1M / u(2) # constant dLSP{1} dLF1M{1} ecteq{1} * linreg dLSP # constant dLSP{1} DLF1M{1} u(1) u(2) ecteq{1} compute C1(1)=%beta(1),$ T1(1,1)=%beta(2),$ T1(1,2)=%beta(3),$ F1(1,1)=%beta(4),$ F1(1,2)=%beta(5),$ EC(1)=%beta(6) linreg dLF1M # constant dLSP{1} dLF1M{1} u(1) u(2) ecteq{1} compute C1(2)=%beta(1),$ T1(2,1)=%beta(2),$ T1(2,2)=%beta(3),$ F1(2,1)=%beta(4),$ F1(2,2)=%beta(5),$ EC(2)=%beta(6) compute L = 14 vcv(matrix=WWW) # u * * These are used to initialize pre-sample variances. * gset G * gend = WWW gset uu * gend = WWW set u(1) = 0.0 set u(2) = 0.0 * declare frml[symm] Gf * frml logl = $ Gx = Gf(t) , $ G(t) = Gx, $ ux = R , $ uu(t) = %outerxx(ux), $ %pt(u,t,ux),$ %logdensity(Gx,ux) * * *create smooth translation function * frml rs = u(1) frml rf = u(2) frml fs = %logistic(L*rs{1},1) frml ff = %logistic(L*rf{1},1) frml Ts = ||fs|fs|| frml Tf = ||ff|ff|| frml Vs = ||fs|fs,fs|| frml Vf = ||ff|ff,ff|| * * This does a BEKK model for the variance * dec symm A1(n,n) B1(n,n) D1(n,n) dec rect AA2(n,n) AA3(n,n) BB2(n,n) BB3(n,n) CC2(n,n) CC3(n,n) compute AA2=.05*%identity(n),AA3=.50*%identity(n) compute A1=%decomp(WWW) nonlin(parmset=standgarch) A1 AA2 AA3 B1 BB2 BB3 D1 CC2 CC3 frml Gf = A1*tr(A1)+AA3*G{1}*tr(AA3)+AA2*uu{1}*tr(AA2)+B1*tr(B1).*Vs+BB3*G{1}*tr(BB3).*Vs+BB2*uu{1}*tr(BB2).*Vs+D1*tr(D1).*Vf+CC3*G{1}*tr(CC3).*Vf+CC2*uu{1}*tr(CC2).*Vf maximize(trace,parmset=standmean+standgarch,pmethod=simplex,piters=200,method=bfgs,iters=150) logl gstart+2 gend maximize(trace,parmset=standmean+transmean+standgarch,pmethod=simplex,piters=200,method=bfgs,iters=150) logl gstart+2 gend 以上是很恐怖的程式碼 >< ----------------------------------------------------------------------------- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.227.96.243

10/13 23:27, , 1F
重跑前有先clear program嗎?
10/13 23:27, 1F

10/16 20:57, , 2F
我沒有耶~ 因為之前跑單純的GARCH沒有做這個動作~ 所以是因
10/16 20:57, 2F

10/16 20:57, , 3F
要先把舊東西清掉的關係嗎?
10/16 20:57, 3F
文章代碼(AID): #1EbGL_9g (Statistics)