这是作者的数据型态
由于比较9组数据,所以才建立rates_i
你应该不用建立rates_i
V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18
1 0.798 1.209 1.445 1.537 1.575 1.590 1.596 1.596 1.593 1.589 1.584 1.580
2 0.779 1.210 1.455 1.546 1.579 1.589 1.589 1.584 1.577 1.568 1.560 1.552
3 1.239 1.439 1.555 1.609 1.641 1.665 1.683 1.699 1.714 1.727 1.739 1.751
.....
482 5.220 5.677 5.997 6.178 6.225 6.206 6.186 6.188 6.208 6.244 6.294 6.358
V19 V20 V21 V22 V23 V24 V25 V26 V27 V28 V29 V30
1 1.575 1.571 1.568 1.565 1.563 1.562 1.562 1.567 1.575 1.599 1.630 1.699
2 1.545 1.538 1.534 1.530 1.528 1.528 1.528 1.536 1.548 1.582 1.623 1.714
3 1.762 1.773 1.783 1.793 1.803 1.813 1.822 1.849 1.874 1.919 1.960 2.026
.....
482 6.431 6.508 6.583 6.653 6.714 6.765 6.806 6.892 6.954 7.066 7.189 7.430
V31 V32 V33 V34 V35 V36 V37 V38 V39 V40 V41 V42
1 1.774 1.852 1.933 2.015 2.098 2.183 2.264 2.336 2.393 2.430 2.442 2.426
2 1.808 1.902 1.993 2.082 2.166 2.246 2.318 2.379 2.424 2.452 2.458 2.441
3 2.083 2.134 2.181 2.225 2.267 2.308 2.346 2.383 2.418 2.450 2.481 2.508
.....
482 7.623 7.765 7.863 7.936 8.001 8.069 8.142 8.216 8.287 8.352 8.407 8.450
V43 V44 V45 V46 V47 V48 V49 V50 V51
1 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888
2 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888
3 2.532 2.553 2.569 2.580 2.586 -88.888 -88.888 -88.888 -88.888
.....
482 8.479 8.495 8.498 8.486 8.460 8.420 8.366 8.301 8.224
V52 V53 V54 V55 V56 V57 V58 V59 V60
1 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888
2 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888
3 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888 -88.888
.....
482 8.140 8.049 7.956 7.863 -88.888 -88.888 -88.888 -88.888 -88.888
V61 V62
1 -88.888 -88.888
2 -88.888 -88.888
3 -88.888 -88.888
.....
482 -88.888 -88.888
######rates_i
[,1] [,2]
[1,] 1 2
[2,] 1 3
[3,] 1 6
[4,] 3 6
[5,] 3 12
[6,] 3 120
[7,] 12 24
[8,] 12 120
[9,] 24 120
########## procedure
Number of Bootstrap Replications 50
Number of Gridpoints for threshold 50
Cointegrating Vector fixed at 1
[1] "short_i"
[1] 2
[1] "long_i"
[1] 3
[1] "long_i"
V9 V8
1 1.445 1.209
2 1.455 1.210
3 1.555 1.439
**********************************************************
Long Rate (month): 2
Short Rate (month): 1
Number of VAR lags: 1
Linear VECM Estimates
Cointegrating Vector 1
Negative Log-Like -1049.493
AIC -1033.493
BIC -1028.043
Equation 1
0.081899 0.23554
-0.007664 0.04248
0.389354 0.27974
-0.288518 0.23198
Equation 2
0.662612 0.24171
-0.122494 0.04331
0.578937 0.27125
-0.437543 0.23857
Threshold VECM Estimates
Threshold Estimate 0.032
Cointegrating Vector Estimate 1
Negative Log-Like -1089.685
AIC -1057.685
BIC -1046.785
First Regime
Percentage of Obs 0.11875
Equation 1
0.37513 1.4089
-0.12081 0.1003
-0.45586 0.5128
-0.02404 0.4642
Equation 2
2.59156 1.6239
-0.24869 0.1091
-0.31520 0.5308
0.02136 0.4931
Second Regime
Percentage of Obs 0.88125
Equation 1
0.029670 0.23206
0.002812 0.04294
0.530674 0.27155
-0.275981 0.23837
Equation 2
0.577925 0.24437
-0.097514 0.04442
0.668365 0.27426
-0.412041 0.25164
Wald Test for Equality of Dynamic Coefs 31.72677 2.175522e-06
Wald Test for Equality of ECM Coef 9.400499 0.00909301
[1] "short_i"
[1] 2
[1] "long_i"
[1] 4
[1] "long_i"
V10 V8
1 1.537 1.209
2 1.546 1.210
3 1.609 1.439
**********************************************************
Long Rate (month): 3
Short Rate (month): 1
Number of VAR lags: 1
Linear VECM Estimates
Cointegrating Vector 1
Negative Log-Like -904.2217
AIC -888.2217
BIC -882.7718
Equation 1
-0.02517 0.14805
0.01674 0.04786
0.19173 0.18921
-0.08442 0.14309
Equation 2
0.47959 0.15831
-0.14789 0.04939
0.45294 0.19111
-0.27795 0.15604
Threshold VECM Estimates
Threshold Estimate 0.274
Cointegrating Vector Estimate 1
Negative Log-Like -936.4757
AIC -904.4757
BIC -893.5759
First Regime
Percentage of Obs 0.5208333
Equation 1
-0.3084 0.46640
0.1015 0.08105
0.3077 0.34505
-0.5977 0.24998
Equation 2
0.5914 0.47204
-0.1130 0.08155
0.5378 0.32542
-0.6664 0.24371
Second Regime
Percentage of Obs 0.4791667
Equation 1
0.07982 0.18649
-0.03220 0.08463
0.14056 0.19340
0.16402 0.16219
Equation 2
0.60136 0.20782
-0.21944 0.09218
0.38507 0.21583
-0.05859 0.19230
Wald Test for Equality of Dynamic Coefs 23.36054 0.0001072635
Wald Test for Equality of ECM Coef 3.098015 0.2124588
[1] "short_i"
[1] 2
[1] "long_i"
[1] 7
[1] "long_i"
V13 V8
1 1.596 1.209
2 1.589 1.210
3 1.683 1.439
**********************************************************
Long Rate (month): 6
Short Rate (month): 1
Number of VAR lags: 1
Linear VECM Estimates
Cointegrating Vector 1
Negative Log-Like -795.4003
AIC -779.4003
BIC -773.9504
Equation 1
-0.13294 0.08350
0.08305 0.04445
0.19526 0.14076
-0.04162 0.10434
Equation 2
0.20725 0.10128
-0.10957 0.04974
0.46079 0.14960
-0.26193 0.11403
Threshold VECM Estimates
Threshold Estimate 0.473
Cointegrating Vector Estimate 1
Negative Log-Like -806.7996
AIC -774.7996
BIC -763.8998
First Regime
Percentage of Obs 0.49375
Equation 1
-0.4148 0.20286
0.1357 0.06638
0.2095 0.20968
-0.2070 0.11459
Equation 2
0.2620 0.21262
-0.1157 0.06641
0.3242 0.16680
-0.3578 0.11344
Second Regime
Percentage of Obs 0.50625
Equation 1
-0.18094 0.1182
0.16329 0.1003
0.15140 0.1692
0.04167 0.1421
Equation 2
0.25213 0.1651
-0.14865 0.1328
0.43653 0.1892
-0.17888 0.1577
Wald Test for Equality of Dynamic Coefs 5.809176 0.2138595
Wald Test for Equality of ECM Coef 2.820796 0.2440462
[1] "short_i"
[1] 4
[1] "long_i"
[1] 7
[1] "long_i"
V13 V10
1 1.596 1.537
2 1.589 1.546
3 1.683 1.609
**********************************************************
Long Rate (month): 6
Short Rate (month): 3
Number of VAR lags: 1
Linear VECM Estimates
Cointegrating Vector 1
Negative Log-Like -1170.032
AIC -1154.032
BIC -1148.582
Equation 1
-0.30727 0.17024
0.08190 0.04084
0.25739 0.22642
-0.11409 0.19439
Equation 2
-0.05042 0.19133
0.02050 0.04294
0.36426 0.23633
-0.23648 0.21885
Threshold VECM Estimates
Threshold Estimate 0.403
Cointegrating Vector Estimate 1
Negative Log-Like -1190.58
AIC -1158.58
BIC -1147.681
First Regime
Percentage of Obs 0.825
Equation 1
0.15182 0.22731
0.02732 0.04995
0.44419 0.23197
-0.21550 0.21538
Equation 2
0.28331 0.23367
-0.01553 0.05057
0.50553 0.22033
-0.25491 0.20429
Second Regime
Percentage of Obs 0.175
Equation 1
-0.58737 0.3815
0.17697 0.2284
0.01184 0.4424
-0.02465 0.3454
Equation 2
-0.18176 0.4833
0.02249 0.2687
0.17419 0.4876
-0.23662 0.4317
Wald Test for Equality of Dynamic Coefs 3.162593 0.530994
Wald Test for Equality of ECM Coef 4.968195 0.08340078
package "tsDyn"
自带的data zeroyld就是2 variables.
跟你的相同
所以我就依此,修改程序,供你参考
仅改四行.
# Data loaded into matrix "dat" #
#dat <- read.table("zeroyld.dat")
#datstore <- dat[1:nrow(dat),(7:62)]
#rs <- rbind(as.matrix(seq(0,18,1)),21,24,30,as.matrix(seq(36,(36+7*12),12)))
data(zeroyld)
datstore<-zeroyld
rs=c(1,2)
rates_i <- matrix(c(1,2),1,2)
rates_i
# [,1] [,2]
#[1,] 1 2
先改一个tar_rate.R
供你参考.
jiezi.txt
tar_rate.R
请自行参照更改tar_ci.R,ur_rate.R
不过你的数据有问题
是否需经处理,或数据不合适
请自行斟酌.
*************************
Number of Bootstrap Replications 50
Number of Gridpoints for threshold 30
Cointegrating Vector fixed at 1
V2 V1
1 41024 7.60
2 42361 7.91
3 43752 5.26
**********************************************************
Long Rate (month): 2
Short Rate (month): 1
Number of VAR lags: 1
Linear VECM Estimates
Cointegrating Vector 1
Negative Log-Like 233.6749
AIC 249.6749
BIC 245.3741
Equation 1
-5.056e-02 1.926e-02
4.562e+03 1.474e+03
-7.860e-02 4.837e-02
-2.956e+02 2.060e+02
Equation 2
1.235e-05 4.758e-05
-1.486e+00 3.387e+00
5.732e-04 1.000e-04
1.286e-01 1.740e-01
Threshold VECM Estimates
Threshold Estimate 54322.73
Cointegrating Vector Estimate 1
Negative Log-Like 215.1869
AIC 247.1869
BIC 238.5852
First Regime
Percentage of Obs 0.3103448
Equation 1
-7.861e-03 2.143e-02
2.325e+03 9.345e+02
-3.437e-01 4.255e-01
9.098e+00 2.091e+01
Equation 2
-2.559e-04 3.294e-04
2.715e+01 1.588e+01
-1.031e-02 2.823e-03
4.183e-02 2.810e-01
Second Regime
Percentage of Obs 0.6896552
Equation 1
-2.213e-01 6.572e-02
1.694e+04 4.810e+03
-2.023e-01 6.630e-02
-3.508e+02 1.030e+02
Equation 2
-5.581e-05 8.362e-05
3.503e+00 6.025e+00
5.955e-04 7.335e-05
2.891e-01 1.862e-01
Wald Test for Equality of Dynamic Coefs 30.75156 3.440211e-06
Wald Test for Equality of ECM Coef 11.80651 0.002730549
***************************
错误在solve.default(v)
此外: Warning message:
In sqrt(hp) : 产生了 NaNs
zhangtao兄
library(tsDyn)
data(zeroyld)
data<-zeroyld
#Fit a VECM with Johansen MLE estimator:
vecm.jo<-VECM(zeroyld, lag=2, r=1,include = "both",estim="ML")
vecm.jo
ECT Intercept Trend
Equation short.run -0.02173938 0.039680380 -4.899791e-05
Equation long.run 0.07724847 -0.008724736 -1.692648e-04
short.run -1 long.run -1 short.run -2 long.run -2
Equation short.run 0.03615135 0.02135291 -0.04326987 -0.02589591
Equation long.run 0.30255266 0.06757760 -0.03446417 -0.07055439
epoh 发表于 2011-11-2 16:33
先改一个tar_rate.R供你参考.jiezi.txt tar_rate.R 请自行参照更改tar_ci.R,ur_rate.R不过你的数据有问题 ...
通常每个package都有自带的data,
供使用者演练熟悉,方便进一步套用自己的数据
function data()
Loads specified data sets, or list the available data sets.
若你想知道package tsDyn自带多少data sets,
可以用底下语法:
try(data(package = "tsDyn") ) # list the data sets in the tsDyn package
#Data sets in package `tsDyn'
IIPUs US monthly industrial production from Hansen (1999)
UsUnemp US unemployment series used in Caner and Hansen (2001)
barry Time series of PPI used as example in Bierens and Martins (2010)
zeroyld zeroyld time series
#####
data(zeroyld) #load data
data<-zeroyld #new data name
所以底下两者都能执行出结果
vecm.jo<-VECM(data, lag=2, r=1,include = "both",estim="ML")
vecm.jo
vecm.jo1<-VECM(zeroyld, lag=2, r=1,include = "both",estim="ML")
vecm.jo1
1.查看数据集:
library(tsDyn)
data(zeroyld) #load data
zeroyld #or print(zeroyld)
short.run long.run
1 2.183 1.575
2 2.246 1.545
3 2.308 1.762
.....
.....
480 8.103 6.842
481 8.069 6.531
482 8.069 6.431
2.在R中对数据集zeroyld直接进行修改
可以,但不方便.
3.要看一下数据内容很简单
譬如:zeroyld.dat(13 楼)
可用用WordPad开启,也可以用NotePad开启
4.要修改数据也很简单
我建议把数据存成zeroyld.csv
然后直接修改,这是大家最熟悉的了.
write.csv( zeroyld ,"zeroyld.csv",row.names = F,col.names = T)
改完之后,依你习惯,可存成任意格式
xxx.xls, xxx.csv, xxx.txt, xxx.dat,.....
5.####in R
data=read.csv("zeroyld.csv")
vecm.jo<-VECM(data, lag=2, r=1,include = "both",estim="ML")
vecm.jo
####in Matlab
file\Import Data\....\zeroyld.csv
####in gauss
z= "c:\\zeroyld.csv";
range = "a2:b483";
data=xlsreadm(z, range, 1, "");
short=data[.,1];
long=data[.,2];
print(short);
print(long);
扫码加好友,拉您进群



收藏
