楼主: liying0782
10317 26

[问答] 求助:关于MSVAR程序包 [推广有奖]

  • 0关注
  • 2粉丝

博士生

74%

还不是VIP/贵宾

-

威望
0
论坛币
3934 个
通用积分
2.7201
学术水平
4 点
热心指数
7 点
信用等级
2 点
经验
5132 点
帖子
190
精华
0
在线时间
397 小时
注册时间
2010-4-5
最后登录
2021-11-8

200论坛币
在MSVARLIB中的数据文件最后两列是什么?看起来是区制分类,但是至于数据是属于哪个区制不是软件迭代出来的吗?但如果把最后两列给改为0或者删除就无法运行了,求助高手,如果用自己的数据要怎样解决这个问题?

最佳答案

epoh 查看完整内容

/*请自行先把数据处理好*/ month year x y 1 1960 123 321 1 1961 234 456 ....... .......100 obs save as xyvar.txt /*************/ _ncol=4; /* _ncol=_K+2 : month and year + number of series */ Data_init_file="xyvar"; data_set = MSVAR_load(Data_init_file,_ncol); Nb_rows=rows(data_set); _K=2; _M=2; _M_V=1; /* _M_V=1 : no switch in variance or _ ...
关键词:MSVAR SVAR R程序包 VaR R程序 程序

回帖推荐

epoh 发表于4楼  查看完整内容

7 8 NBER Three_state 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 3 2 3 2 3 .... .... 就是MSVARlib_data,sheet ref_date NBER datations , REC4 Three state datation - recoded 1 Recessionary regime 2 intermediate 3 High growth 自己的数据,可以不用这两个columns Datation NBER,画图时可以比较模型的准确性 如MSVARlib-v2.0.pdf page 11/27,figure ...
沙发
epoh 发表于 2012-4-10 16:52:57 |只看作者 |坛友微信交流群
ferguson06 发表于 2012-4-11 16:15
我是两个变量,2个区制,滞后一阶想用截距均值模型做,年度数据
除了数据输入这边改,还需要在choosing  ...
/*请自行先把数据处理好*/
month year   x    y
1    1960  123  321
1    1961  234  456
.......
.......100 obs
save as xyvar.txt
/*************/
_ncol=4;     /* _ncol=_K+2  : month and year + number of series */
Data_init_file="xyvar";              

data_set =  MSVAR_load(Data_init_file,_ncol);
Nb_rows=rows(data_set);

_K=2;
_M=2;
_M_V=1;  /*  _M_V=1 : no switch in variance  or _MV_=_M : switch in variance  */
_Var_opt=1;
_typmod=3;
_p=1;          /*  degree of the MSVAR(p)  for p>=1 if under construction */

_n_x=1;        /* number of exogenous, switching variables (including intercept) _n_x=1 by default for the model 1 */
_n_z=1;        /* number of exogenous, non-switching variables (including intercept) _n_z=1 by default for the model 1 */

/*请自行先把数据处理好*/
F_option=0;
k_lag=0;
d_option=0;


/* ==========Start and ending index  =========== */
deb=1;
fin=100;

_apriori=0;
date_col=4;  
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Cherry92 + 1 + 1 + 1 观点有启发

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

使用道具

藤椅
liying0782 在职认证  发表于 2012-4-10 20:45:25 |只看作者 |坛友微信交流群
有没有人知道的啊?现在论文比较急,大家帮帮忙~~
我后来又看了看源程序,最后两列貌似不是区制,而是外生变量,但不懂为什么都是1/2/3这样的数字,如果用自己的数据又要怎么设置呢

使用道具

板凳
ferguson06 发表于 2012-4-11 13:32:05 |只看作者 |坛友微信交流群
1        1960        0.19        41        30.13        .        2        2
2        1960        0.21        41        29.86        .        2        2
3        1960        0.19        39        29.59        .        2        2
4        1960        0.19        38        29.36        .        1        1
5        1960        0.2        38        29.32        .        1        1
6        1960        0.19        37        28.95        .        1        1
7        1960        0.18        36        28.85        .        1        1
8        1960        0.18        35        28.82        .        1        1
9        1960        0.18        34        28.52        .        1        1
10        1960        0.16        32        28.48        .        1        1
11        1960        0.16        32        28.08        .        1        1
12        1960        0.15        30        27.55        .        1        1
1        1961        0.15        30        27.58        .        1        1
2        1961        0.14        30        27.55        .        1        1
3        1961        0.14        30        27.71        .        2        2
4        1961        0.14        30        28.28        .        2        2
5        1961        0.14        32        28.72        .        2        3
6        1961        0.14        32        29.12        .        2        3
7        1961        0.14        33        29.46        .        2        3
这是楼主所问的问题,为何最后两列是1/2/3 同问。

使用道具

报纸
epoh 发表于 2012-4-11 15:19:44 |只看作者 |坛友微信交流群
liying0782 发表于 2012-4-10 20:45
有没有人知道的啊?现在论文比较急,大家帮帮忙~~
我后来又看了看源程序,最后两列貌似不是区制,而是外生 ...
7            8
NBER        Three_state
2        2
2        2
2        2
1        1
1        1
1        1
1        1
1        1
1        1
1        1
1        1
1        1
1        1
1        1
2        2
2        2
2        3
2        3
2        3
....
....
就是MSVARlib_data,sheet ref_date
NBER datations ,
REC4 Three state datation - recoded
  1        Recessionary regime
  2        intermediate
  3        High growth

自己的数据,可以不用这两个columns
Datation NBER,画图时可以比较模型的准确性
如MSVARlib-v2.0.pdf page 11/27,figure 3

使用道具

地板
ferguson06 发表于 2012-4-11 16:10:49 |只看作者 |坛友微信交流群
epoh 发表于 2012-4-11 15:19
7            8
NBER        Three_state
2        2
epoh老师你好
  你意思就是说如果是我用自己的数据运行MSVAR,数据只要按如下格式写就好了?
1960 123 321
1961 234 456
......
那么在主程序里面的
/*=======================================================================================================*/
/*                                   Loading  Data  of input file
*
* Caution : the file should include the series following this order  :
* month /year / y series  / X series / z series / refdate (optional ) , see MSVARlibdata.xls, for template examples.       
*
* Do not include intercept or lagged series in your input file this is fixed in MSVAR_setsample
* No missing value are allowed
*
*/
/*=======================================================================================================*/


/*=============================================================*/

_ncol=5;                                 /* _ncol=_K+2  : month and year + number of series */Data_init_file="MSVARUN";              /* ch鬽age and help wanted */

/*=========== Data_init_file = y_mat (.,_K)~x_mat(.,_n_x)~z_mat(.,_n_z) ===================*/

data_set =  MSVAR_load(Data_init_file,_ncol);
Nb_rows=rows(data_set);
有什么是需要改的吗?我红字注释的地方是不是全了?

使用道具

7
ferguson06 发表于 2012-4-11 16:15:08 |只看作者 |坛友微信交流群
epoh 发表于 2012-4-11 15:19
7            8
NBER        Three_state
2        2
我是两个变量,2个区制,滞后一阶想用截距均值模型做,年度数据
除了数据输入这边改,还需要在choosing your model里改写什么呢?
/*===============================================Choosing your model ======================================================*/

_K=1;_M=2;
_M_V=_M;  /*  _M_V=1 : no switch in variance  or _MV_=_M : switch in variance  */
_Var_opt=2;
_typmod=1;_p=1;          /*  degree of the MSVAR(p)  for p>=1 if under construction */

_n_x=1;        /* number of exogenous, switching variables (including intercept) _n_x=1 by default for the model 1 */
_n_z=1;        /* number of exogenous, non-switching variables (including intercept) _n_z=1 by default for the model 1 */

/*========================================================================================================*/
/* k_lag  degree of transformation of data : 100.(F(x(t))-F(x(t-k_lag)))                                  */
/* F_option : transformation mode =(0,1,2) : 0  id, 1 dlog(.), 2 d(.)        (notice that if k==0 f_option is set to 0)*/
/* d_option : second transformation of data =(0,1,2) : 0  id, 1 demeaned series (x-E(X)), 2 standardized series (X-D(X)./Sigma(X)*/     
/*=======================================================================================================*/

F_option=1;
k_lag=2;
d_option=2;


/* ==========Start and ending index : some  common available values for US events  (see readme for templates of dates) =========== */
deb=86;
fin=530;
/*
Some date : 1960-1 : 1, 1964-1 :49, 1967-2 :86, 1979-1 : 229 ,1984-1 : 289, 1985-1 : 301 1989-1: 349,  1989-12: 360,   1995-1 : 421, 1999-12 : 480,  2000-12 : 492,  
Last available date : 2003-1 517
Estimating Date :     1985-1 : 301 , 1989-1: 349 , 1999-12 : 480, 2000-12 :492, 2003-1 : 517, 2004-2: 529
Starting Date :         1967-2 :86, 1979-1 : 229
*/

/*========== =======================================Datation reference options ========================================*/
/*     if _apriori==0, no reference datation is needed, else you need to provide an apriori datation, si ref_date.xls for an example                         */
/*     date_col may be optional (put in @ @) if you want to skip it                                                                                                                                 */
/*========== =====================================================================================================*/
_apriori=0;
date_col=5;   /*  column number of the selected datation, for MSVARrec4 "Recessions NBER" (date_col=7),  "3_state Anas" (date_col=8) */

/*==============================================================*/
/* ESTIMATION or FILTERING with initial parameters ?                                              */
/* Estim : 1 if estimation, 0 if filtering                                                                        */
/* if estim = 0, a parameter matrix should be imported                                              */
/*==============================================================*/

estim=1;

使用道具

8
liying0782 在职认证  发表于 2012-4-11 16:31:26 |只看作者 |坛友微信交流群
epoh 发表于 2012-4-11 15:19
7            8
NBER        Three_state
2        2
那删掉的话date_col是不是就放到注释里面去了,这样ref_date,base这些都可以删掉?

使用道具

9
liying0782 在职认证  发表于 2012-4-11 16:39:48 |只看作者 |坛友微信交流群
epoh 发表于 2012-4-11 15:19
7            8
NBER        Three_state
2        2
如果要用这两列的话,数据又是怎样确定的呢?在运行之前,区制是不可观察的啊,怎么能知道是第几区制呢?

使用道具

10
ferguson06 发表于 2012-4-15 19:05:15 |只看作者 |坛友微信交流群
epoh 发表于 2012-4-11 18:45
/*请自行先把数据处理好*/
month year   x    y
1    1960  123  321
epoh老师,我按照您所说的一些步骤和自己的改动,用自己的数据做了一遍但是发现做MSVAR的时候,还是有问题,我的结果就雷同MSVARLIB2.0里面的例子,就感觉改动了程序之后,貌似GAUSS认为我没改,还是运行自己的程序。。。
我自己的改动如下:
1、我的数据是年度的,写成了如下格式,保存为xyvar.txt,放在GAUSS\MSVAR\data里面
1960  123  321
1961  234  456
.......
.......100 obs
2、在数据读取那栏/*************/
_ncol=3;     /* _ncol=_K+2  :  year + number of series */
Data_init_file="xyvar";              

data_set =  MSVAR_load(Data_init_file,_ncol);
Nb_rows=rows(data_set);
3、在模型选择上
_K=2;
_M=2;
_M_V=_M;  /*  _M_V=1 : no switch in variance  or _MV_=_M : switch in variance  */
_Var_opt=1;
_typmod=3;
_p=1;          /*  degree of the MSVAR(p)  for p>=1 if under construction */

_n_x=1;        /* number of exogenous, switching variables (including intercept) _n_x=1 by default for the model 1 */
_n_z=1;        /* number of exogenous, non-switching variables (including intercept) _n_z=1 by default for the model 1 */

F_option=0;
k_lag=0;
d_option=0;


/* ==========Start and ending index  =========== */
deb=1;
fin=100;

_apriori=0;
date_col=3;

使用道具

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

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-5 16:31