哈哈!使用KROLZIG's MSVAR package
需要时光倒流,把时间调回2006.
画出的Regime probabilities图形倒是很漂亮.
安装,使用说明,及三个范例
参考MSVAR package,msvardoc.pdf
epoh 发表于 2011-10-12 09:18
哈哈!使用KROLZIG's MSVAR package需要时光倒流,把时间调回2006.画出的Regime probabilities图形倒是很漂亮 ...
哈哈!zhangtao兄对此模型也有兴趣
我先说明一下:
MSVAR for Ox,需要配合旧版的软件
GiveWin2 & oxpro340
且使用的时候,电脑时间,要调回2006以前 .
请先check你是否有这些软件
如果没有,请向楼主购买.
我们总该遵守原则,尊重楼主.哈哈!
%%%%%%%%
MSVAR package的确网站已不再提供
网上流传的可能比较不完全.
不知楼主提供的是否完整
应该要有
msvardoc.pdf
Msvar130.h
msvar130.oxo
HAMILTON.OX
HAMILTON2.OX
KROTO.OX
KROTO.xls
.....
.....
等17个文件.
如果有缺我再提供
以及说明如何使用
epoh 发表于 2011-10-12 16:06
哈哈!zhangtao兄对此模型也有兴趣我先说明一下:MSVAR for Ox,需要配合旧版的软件GiveWin2 & oxpro340且使用 ...
1.请注意短信息
请将文件放在正确路径:
C:\Program Files\Ox\packages\MSVAR\HAMILTON.OX
\GNP82.xls
\msvar130.oxo
......
......
2.add MSVAR package in GiveWin2
start GiveWin2:
Modules \Start OxPAck
in the OxPack window:
Add/Remove PAckages\Browse\
Go to C:\Program Files\Ox\packages\msvar and choos msvar130.oxo
"Package class name (case must match exactly): change Msvar130 to MSVAR
you see MSVAR under Packeges
3. run HAMILTON.OX
in GiveWin2 window
open C:\Program Files\...\HAMILTON.OX
Modules \Start OxRun
/************************
************************/
Ox version 3.40 (Windows) (C) J.A. Doornik, 1994-2004
MSVAR (c) H-M Krolzig, 1996-2005, package version 1.32a, object created on 1-10-2003
---------- EM algorithm converged after 43 iterations ------------
EQ( 1) MSM(2)-AR(4) model of DUSGNP
Estimation sample: 1952 (2) - 1984 (4)
no. obs. per eq. : 131 in the system : 131
no. parameters : 9 linear system : 6
no. restrictions : 1
no. nuisance p. : 2
log-likelihood : -181.4236 linear system : -183.6692
AIC criterion : 2.9072 linear system : 2.8957
HQ criterion : 2.9875 linear system : 2.9492
SC criterion : 3.1048 linear system : 3.0274
LR linearity test: 4.4911 Chi(1) =[0.0341] * Chi(3)=[0.2131] DAVIES=[0.2131]
---------- matrix of transition probabilities ------
Regime 1 Regime 2
Regime 1 0.7620 0.2380
Regime 2 0.0986 0.9014
---------- regime properties ----------------------
nObs Prob. Duration
Regime 1 38.5 0.2929 4.20
Regime 2 92.5 0.7071 10.14
---------- coefficients ----------------------------
Coef StdError t-val
Mean (Reg.1) -0.3403 0.2441 -1.3940
Mean (Reg.2) 1.1727 0.1423 8.2395
DUSGNP_1 0.0108 0.0895 0.1203
DUSGNP_2 -0.0627 0.0811 -0.7731
DUSGNP_3 -0.2462 0.0859 -2.8669
DUSGNP_4 -0.2009 0.0867 -2.3170
Standard error 0.76987
---------------------------
这个例子MSM(2)-AR(4) model的结果
跟在winrats是接近的
MAXIMIZE - Estimation by BFGS
Convergence in 33 Iterations. Final criterion was 0.0000077 <= 0.0000100
Quarterly Data From 1952:02 To 1984:04
Usable Observations 131
Function Value -181.2634
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. MU(1)(1) 1.163516284 0.074908621 15.53248 0.00000000
2. MU(2)(1) -0.358817491 0.268297584 -1.33739 0.18109660
3. PHI(1)(1,1) 0.013485547 0.124157302 0.10862 0.91350658
4. PHI(2)(1,1) -0.057524674 0.136019028 -0.42292 0.67235628
5. PHI(3)(1,1) -0.246984366 0.110325418 -2.23869 0.02517612
6. PHI(4)(1,1) -0.212921583 0.105591977 -2.01646 0.04375231
7. SIGMA(1,1) 0.591366786 0.106496665 5.55291 0.00000003
8. P(1,1) 0.904084488 0.037787519 23.92548 0.00000000
9. P(1,2) 0.245329958 0.094997335 2.58249 0.00980893
---------------
4.如果嫌调整时间不方便
你也可以使用:
MSVARlib Version 2.0 - For Gauss users
MSVARlib is a new open source Gauss library to estimate Multivariate Markov-Switching
regression Models in their most generic specification. These new programs are based
upon the works of Hamilton (1994) and Krolzig (1998) and allow assessment of models
with M states through classical optimization of the maximum likelihood method
http://bellone.ensae.net/MSVARlib.html
哈哈!zhangtao兄,执行速度真快
KROTO.OX,我跑出的结果跟你一样,有错.
/*********/
estimate Markov switching VAR's in winrats
/*********/
MARKOV.src
mssetup.src
MSVARSetup.src
excute file:msvar_hamilton.prg
winrats v7 or later.
两者相容性不佳
后续会延伸很多问题.
请选:scilab-5.1.1 & Grocer_V1.5_SCI_5.1moins
Grocer_V1.5_SCI_5.1moins解压缩后
将文件夹grocer放在c碟
开启 scilab
然后输入exec('c:/grocer/loader.sce',-1)
就OK了
**********
GROCER 1.5 installed
Please, we would greatly appreciate if you could send us an e-mail at grocer.toolbox@free.fr to inform us that you have installed grocer
-->hendryericsson()
ols estimation results for dependent variable: delts(lm1-lp)
estimation period: 1964q3-1989q2
number of observations: 100
number of variables: 5
R2 = 0.7616185 adjusted R2 =0.7515814
Overall F test: F(4,95) = 75.880204 p-value = 0
standard error of the regression: 0.0131293
sum of squared residuals: 0.0163761
DW(0) =2.1774376
Belsley, Kuh, Welsch Condition index: 9
variable coeff t-statistic p value
delts(lp) -0.6870384 -5.4783422 0.0000004
delts(lagts(1,lm1-lp-ly)) -0.1746071 -3.0101342 0.0033444
rnet -0.6296264 -10.46405 0
lagts(1,lm1-lp-ly) -0.0928556 -10.873398 0
cte 0.0234367 5.818553 7.987D-08
就是一般解压缩软件
ex:winrar
这跟R一样
譬如你要安装 package "coda"
要自行由本机安装,下载coda_0.14-4.zip
Windows binary: coda_0.14-4.zip
要看sourcr code,下载coda_0.14-4.tar.gz
Package source: coda_0.14-4.tar.gz
http://cran.r-project.org/web/packages/coda/index.html
zhangtao兄
今天看了下Oxmetrics6.2,
New features in PcGive 13
发现PcGive 13已经可以做 Regime Switching Models.
( only univariate models allowed)
而且有图形介面,可以存贮各项数据及结果.
Hamilton(1989) MSM(2)-AR(4)的结果如下:
GNP82.xls loaded from C:\Program Files\OxMetrics6\Ox\packages\MSVAR\GNP82.xls
Ox Professional version 6.20 (Windows/U) (C) J.A. Doornik, 1994-2011
---- Switching - PcGive 1.0 session started at 15:21:14 on 18-10-2011 ----
Switching( 1) Modelling DUSGNP by MS_ARMA(2, 4, 0)
The dataset is: C:\Program Files\OxMetrics6\Ox\packages\MSVAR\GNP82.xls
The estimation sample is: 1951(2) - 1984(4)
Coefficient Std.Error t-value t-prob
AR-1 0.00887396 0.1193 0.0744 0.941
AR-2 -0.0666548 0.1379 -0.483 0.630
AR-3 -0.247527 0.1053 -2.35 0.020
AR-4 -0.201927 0.1068 -1.89 0.061
Constant(0) -0.351190 0.2721 -1.29 0.199
Constant(1) 1.17192 0.07436 15.8 0.000
sigma 0.768240 0.06658 11.5 0.000
p_{0|0} 0.759808 0.09817 7.74 0.000
p_{0|1} 0.0982972 0.03828 2.57 0.011
log-likelihood -181.422782
no. of observations 131 no. of parameters 9
AIC.T 380.845565 AIC 2.90721805
mean(DUSGNP) 0.744598 var(DUSGNP) 1.13768
Linearity LR-test Chi^2(3) = 4.4927 [0.2129] approximate upperbound: [0.5810]
Transition probabilities p_{i|j} = P(Regime i at t+1 | Regime j at t)
Regime 0,t Regime 1,t
Regime 0,t+1 0.75981 0.098297
Regime 1,t+1 0.24019 0.90170
Used uniform probabilities to start recursion
Std.Error based on numerical Hessian matrix
SQPF using numerical derivatives (eps1=0.0001; eps2=0.005):
Strong convergence
Used starting values:
0.10010 0.029604 -0.023450 -0.052037 -0.049589 1.5506
0.71075 0.50000 0.50000
*******
******
另一种方式是,你也可以由
Oxmetrics6.2执行OxGauss
得到相同的结果:
--------------- OxGauss at 10:28:40 on 19-Oct-2011 ---------------
Ox Professional version 6.21 (Windows/U/MT) (C) J.A. Doornik, 1994-2011
C:\Program Files\OxMetrics6\Ox\packages\hamilton_Markov1\MAXSEEK.oxgauss
Bayesian prior used
a= 0.00000000 b= 0.00000000 c= 0.00000000
Starting values
parameters
1.0000 0.00000 0.10000 0.00000 0.00000 0.00000
1.0000 1.5000 1.5000
gradients
7.6433 6.9143 18.239 12.665 -6.5189 -8.3912
-17.439 6.4844 -2.2637
Initial function =
-70.1040525341
Position after 1 BFGS iterations
parameters
1.0597 0.054018 0.24249 0.098944 -0.050929 -0.065556
0.86376 1.5507 1.4823
gradients
5.8327 3.2396 4.6567 3.2141 -7.4655 -4.4619
3.4274 3.9618 -2.3610
function value =
-64.723138832
steplen = 0.0078125
.....
.....
Position after 32 BFGS iterations
Status: Strong convergence
parameters
1.1635 -0.35881 0.013488 -0.057521 -0.24698 -0.21292
0.76900 3.0702 1.7539
gradients
-5.9376e-005 -6.3707e-006 -3.3991e-005 -1.2115e-005 9.7600e-006 -2.5202e-005
1.6503e-005 -2.3185e-006 2.6219e-006
function value =
-60.8824470816
Value of objective function: 60.882447
Strong convergence using numerical first derivatives
MLE as parameterized for numerical optimization
Coefficients:
1.1635168 -0.35881175 0.013487704 -0.057520648
-0.24698320 -0.21292092 0.76900491 3.0701564 1.7538983
Value of log likelihood: -60.882447
Gradient vector:
5.9236484e-005 8.1712415e-006 3.5171865e-005 1.3145041e-005 -1.1013412e-005
2.3092639e-005 -1.7763568e-005 9.2574142e-007 -1.4179269e-006
Vector is reparameterized to report final results as follows
Means for each state:
1.1635168 -0.35881175
Autoregressive coefficients:
0.013487704 -0.057520648 -0.24698320 -0.21292092
Variances:
0.59136855
Matrix of Markov transition probabilities:
0.90408465 0.24532898
0.095915347 0.75467102
Ergodic probs for full state vector:
0.48030797 0.050956408 0.013827337 0.042535093 0.013827337
0.0014669576 0.011542161 0.035505527 0.013827337 0.0014669576
0.00039806804 0.0012245207 0.011542161 0.0012245207 0.0096346448
0.029637703 0.050956408 0.0054060220 0.0014669576 0.0045125953
0.0014669576 0.00015563116 0.0012245207 0.0037668209 0.042535093
0.0045125953 0.0012245207 0.0037668209 0.035505527 0.0037668209
0.029637703 0.091170298
Ergodic probs for primitive states:
0.71892471 0.28107529
Log likelihood:
-60.882447
For vector of coefficients parameterized as follows,
1.1635168 -0.35881175 0.013487704 -0.057520648
-0.24698320 -0.21292092 0.59136855 0.90408465 0.75467102
the standard errors are
0.074518858 0.26454067 0.11999444 0.13766334
0.10691036 0.11053118 0.10264635 0.037736172 0.096518972
epoh 发表于 2011-10-12 16:06
哈哈!zhangtao兄对此模型也有兴趣我先说明一下:MSVAR for Ox,需要配合旧版的软件GiveWin2 & oxpro340且使用 ...
file\open\....\GNP82.xls
click PcGive
Category 选取 Models for time-series data
Model class 选取Regime Switching Models using PcGive
按Formulate 跳出新窗口:
Formulate-Regime Switching Models-gnp82.xls
选取右边DUSGNP,送往左边
在左边形成
Y DUSGNP
R Constant
按OK跳出新窗口:
Model Settings-Regime Switching Models
Model type 选取Markov-switching ARMA model
AR order 选取4
OK,again OK.
哈哈!17楼朋友
爱开玩笑.
我都看到你在gauss区块卖
msvar130ex.zip ,msvar130.zip
你应该比我齐全吧!
其实PcGive 有关
Panel Data Models估计的方法就不少:
epoh 发表于 2011-10-19 18:05
TSP/OxMetrics
TSP (Version 5.1), by TSP International is an econometric software package,
with co ...
TSP5.1必须另外购买.
不过我个人看法
Oxmetrics6.2的package PcGive
功能相当强大
几乎已经取代了TSP大部分功能
而且容易操作.
当然你有兴趣也可以下载
TSP 5.1 demo version来试试,
或先看一下TSP User's Guide.
epoh 发表于 2011-10-18 15:44
zhangtao兄今天看了下Oxmetrics6.2,New features in PcGive 13发现PcGive 13已经可以做 Regime Switching M ...
Gauss modules最常用的就是 Cml, Maxlik and Optmum
所以首先需要下载M@ximize 1.1 package.
Bridging the Gap Between Ox and Gauss when using OxGauss
解压后会产生二个文件夹oxgauss,include
文件夹oxgauss覆盖
C:\Program Files\OxMetrics6\Ox\oxgauss
而文件夹include内含之三个文件
cml.ext,maxlik.ext,optum.ext 是空的
所以使用的时候,就从gauss src文件夹copy 过来.
/*********/
你说对了!run菜单中的oxgauss怎么是灰色的,没有激活
因为他只认识File Name Extension 是.oxgauss
譬如MAXSEEK.oxgauss
所以开启的文件是MAXSEEK.oxgauss时,就激活了
同理你很容易就能执行MSVARlib-v2.0
/*******/
/*******/
zhangtao兄,这一步你忘记改了
Model Settings-Regime Switching Models
Model type 选取Markov-switching ARMA model
AR order 选取4
OK,again OK.
(…我学TSP目的主要是有些
…个人编写的程序是用TSP的)
ywh老兄够你学的.
前提是请你先装妥GiveWin2.3
(licensing code 在短信息)
TSP500 for GiveWin(include examples)
TSP 5.0 User's Guide
TSP 5.0 Reference Manual
http://www.nber.org/tsp/tsp50rm.pdf
***********
TSP Version 5.0
( 4/05/05) TSP/GiveWin 16MB
Copyright (C) 2005 TSP International
PROGRAM
COMMAND ***************************************************************
1 ? EM ALGORITHM FOR CALCULATING THE PARAMETERS OF A MIXTURE
1 ? DISTRIBUTION WITH TWO REGIMES; ALSO CALCULATES STANDARD ERRORS
1 ? See James Hamilton, "TIME SERIES ANALYSIS" pp 685-689
......
......
PI1 PI2 MU1 MU2
Value 0.28282 0.71718 -0.048773 1.00704
SIG1 SIG2
Value 0.99234 2.00675
DIFF = 0.0000100000
NULL = 0.00000
PI1 = 0.28282
MU1 = -0.048773
MU2 = 1.00704
SIG1 = 0.99234
SIG2 = 2.00675
VDET = 3.23900D+15
VCOVIN
1 2 3 4 5
1 7917.74383
2 -638.41100 770.96843
3 -2046.25721 480.74298 1557.38675
4 -1820.40267 -157.99003 -63.93776 1119.92719
5 -1946.42311 -555.52391 57.72691 441.20966 3178.95271
VCOV
1 2 3 4 5
1 0.00083164
2 0.00070120 0.0025296
3 0.00091505 0.00016514 0.0018411
4 0.0013335 0.0012313 0.0014777 0.0030918
5 0.00043003 0.00069750 0.00035061 0.00057573 0.00061349
*******************************************************************************
END OF OUTPUT.
MEMORY USAGE: ITEM: DATA ARRAY TOTAL MEMORY
UNITS: (4-BYTE WORDS) (MEGABYTES)
MEMORY ALLOCATED : 3500000 16.0
MEMORY ACTUALLY REQUIRED : 462903 4.0
CURRENT VARIABLE STORAGE : 362978