楼主: jiezichen
6037 22

[问答] 在线等帮我翻译下以下代码啊 谢谢 看不懂什么意思 [推广有奖]

  • 2关注
  • 1粉丝

初中生

42%

还不是VIP/贵宾

-

威望
0
论坛币
2 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
106 点
帖子
14
精华
0
在线时间
13 小时
注册时间
2011-5-11
最后登录
2024-10-24

楼主
jiezichen 发表于 2011-11-2 00:12:04 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
# Load your own data into matrix "dat" #
# Here we load in the 3-month and 6-month T-Bill series #

dat <- read.table("zeroyld.dat")
dat <- 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)))
short <- 12
long <- 120
short_i <- which.max(rs==short)
long_i <- which.max(rs==long)
dat <- dat[,cbind(long_i,short_i)]   
二维码

扫码加我 拉你入群

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

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

关键词:看不懂 在线等 Series matrix month

沙发
amyherml 发表于 2011-11-2 00:27:29
请问是哪行不懂啊?

藤椅
jiezichen 发表于 2011-11-2 00:28:10
运行的现成的程序 输入自己的DAT 做出模型
但是不知道怎么输入啊 求救

板凳
jiezichen 发表于 2011-11-2 00:31:52
amyherml 发表于 2011-11-2 00:27
请问是哪行不懂啊?
dat <- 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)))

这两行 我大概明白这个是读取文档里的数据 然后这几句是定义的什么呢 和文档里的数据有关系么
我打算把文档里的数据改成自己的 但是不知道怎么该 求指教 谢谢

报纸
amyherml 发表于 2011-11-2 00:32:52
把你的数据保存成 以 "zeroyld.dat" 为文件名的文件,放在你的当前目录下,然后运行程序就可以了。

具体要看看原程序的说明,看看数据在zeroyld.dat中是什么样的格式,确保跟原来的无差别就可以了。

地板
jiezichen 发表于 2011-11-2 00:39:13
amyherml 发表于 2011-11-2 00:32
把你的数据保存成 以 "zeroyld.dat" 为文件名的文件,放在你的当前目录下,然后运行程序就可以了。

具体 ...
嗯 我明白你说的意思 但是我的数据很少 他那里面的数据很多 根本就弄不成和原来dat里一样

7
amyherml 发表于 2011-11-2 00:40:26
jiezichen 发表于 2011-11-2 00:31
dat
dat <- dat[1:nrow(dat),(7:62)]

这是说 dat 只保留原 dat的 7 到62 列

rs <- rbind(as.matrix(seq(0,18,1)),21,24,30,as.matrix(seq(36,(36+7*12),12)))

as.matrix(seq(0,18,1))
这里是把一个array 变成matrix

rbind是把那里面的串数字按行连起来,成为一个n×1的matrix,这行可以直接运行,你把它复制到R里面运行看看就知道了。

8
epoh 发表于 2011-11-2 11:56:01

这是作者的数据型态

由于比较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

9
epoh 发表于 2011-11-2 11:56:47
[1] "short_i"
[1] 4
[1] "long_i"
[1] 13
[1] "long_i"
    V19   V10
1 1.575 1.537
2 1.545 1.546
3 1.762 1.609
**********************************************************

Long Rate  (month):      12
Short Rate (month):      3
Number of VAR lags:      1

Linear VECM Estimates

Cointegrating Vector  1
Negative Log-Like     -938.1015
AIC                   -922.1015
BIC                   -916.6516

  Equation 1
  -0.16540    0.07704
   0.08008    0.04377
   0.26034    0.12098
  -0.11995    0.13434

  Equation 2
   0.04363    0.08725
  -0.01105    0.04488
   0.33610    0.13890
  -0.16112    0.17217



Threshold VECM Estimates

Threshold Estimate             0.059
Cointegrating Vector Estimate  1
Negative Log-Like              -962.395
AIC                            -930.395
BIC                            -919.4951

First Regime
Percentage of Obs 0.1083333

  Equation 1
  -0.7285    0.3855
  -0.1118    0.1345
   0.4446    0.3911
  -0.7451    0.4029

  Equation 2
  -0.3991    0.4041
  -0.1881    0.1501
   0.3496    0.3608
  -0.5427    0.4094

Second Regime
Percentage of Obs 0.8916667

  Equation 1
  -0.153545    0.06268
   0.092644    0.03197
   0.102052    0.10278
   0.123555    0.10576

  Equation 2
   0.040964    0.08534
   0.005291    0.03911
   0.255547    0.14005
  -0.012659    0.18259

Wald Test for Equality of Dynamic Coefs  15.42931   0.003888822
Wald Test for Equality of ECM Coef       3.0961   0.2126623


[1] "short_i"
[1] 4
[1] "long_i"
[1] 30
[1] "long_i"
    V36   V10
1 2.183 1.537
2 2.246 1.546
3 2.308 1.609
**********************************************************

Long Rate  (month):      120
Short Rate (month):      3
Number of VAR lags:      1

Linear VECM Estimates

Cointegrating Vector  1
Negative Log-Like     -950.1987
AIC                   -934.1987
BIC                   -928.7488

  Equation 1
  -0.033388    0.01846
   0.046029    0.02478
   0.057342    0.07897
  -0.005689    0.04493

  Equation 2
   0.065958    0.03928
  -0.062863    0.05867
   0.304977    0.14927
   0.053280    0.12817



Threshold VECM Estimates

Threshold Estimate             -0.073
Cointegrating Vector Estimate  1
Negative Log-Like              -978.6271
AIC                            -946.6271
BIC                            -935.7272

First Regime
Percentage of Obs 0.1208333

  Equation 1
  -0.009877    0.10914
   0.143262    0.08978
   0.295640    0.20713
  -0.219139    0.07932

  Equation 2
   0.490045    0.25502
   0.485884    0.20963
   1.000256    0.46021
  -0.273562    0.24542

Second Regime
Percentage of Obs 0.8791667

  Equation 1
  -0.02341    0.01914
   0.03057    0.02341
  -0.01969    0.07787
   0.06908    0.04250

  Equation 2
   0.06217    0.02540
  -0.06608    0.03970
   0.11334    0.11704
   0.19594    0.13293

Wald Test for Equality of Dynamic Coefs  11.36111   0.02279186
Wald Test for Equality of ECM Coef       8.475848   0.01443754


[1] "short_i"
[1] 13
[1] "long_i"
[1] 21
[1] "long_i"
    V27   V19
1 1.575 1.575
2 1.548 1.545
3 1.874 1.762
**********************************************************

Long Rate  (month):      24
Short Rate (month):      12
Number of VAR lags:      1

Linear VECM Estimates

Cointegrating Vector  1
Negative Log-Like     -1297.641
AIC                   -1281.641
BIC                   -1276.192

  Equation 1
   0.009341    0.11403
   0.007730    0.03654
   0.295526    0.30657
  -0.151536    0.27326

  Equation 2
   0.116076    0.12885
  -0.014877    0.04146
   0.562007    0.34765
  -0.317521    0.31697



Threshold VECM Estimates

Threshold Estimate             -0.369
Cointegrating Vector Estimate  1
Negative Log-Like              -1332.816
AIC                            -1300.816
BIC                            -1289.916

First Regime
Percentage of Obs 0.07291667

  Equation 1
   2.94382    1.1951
   1.70170    0.6453
  -0.09464    0.7522
   0.18135    0.6635

  Equation 2
   3.78830    1.2985
   2.05886    0.6945
  -0.05070    0.8482
   0.27430    0.7669

Second Regime
Percentage of Obs 0.9270833

  Equation 1
  -0.070962    0.08768
   0.029247    0.02692
   0.028792    0.21166
   0.090202    0.20237

  Equation 2
  -0.005601    0.09652
   0.018101    0.03066
   0.262262    0.24383
  -0.081174    0.23595

Wald Test for Equality of Dynamic Coefs  8.938421   0.06265724
Wald Test for Equality of ECM Coef       12.34644   0.002084512


[1] "short_i"
[1] 13
[1] "long_i"
[1] 30
[1] "long_i"
    V36   V19
1 2.183 1.575
2 2.246 1.545
3 2.308 1.762
**********************************************************

Long Rate  (month):      120
Short Rate (month):      12
Number of VAR lags:      1

Linear VECM Estimates

Cointegrating Vector  1
Negative Log-Like     -1086.787
AIC                   -1070.787
BIC                   -1065.337

  Equation 1
  -0.01376    0.02385
   0.01972    0.02158
   0.04835    0.09872
   0.01074    0.05421

  Equation 2
   0.08820    0.05107
  -0.04750    0.04771
   0.32452    0.19178
   0.04988    0.12270



Threshold VECM Estimates

Threshold Estimate             -0.99
Cointegrating Vector Estimate  1
Negative Log-Like              -1126.207
AIC                            -1094.207
BIC                            -1083.307

First Regime
Percentage of Obs 0.06041667

  Equation 1
   0.27041    0.2411
   0.52408    0.3006
   0.16291    0.2415
  -0.15349    0.1194

  Equation 2
   1.36243    0.4388
   1.70800    0.5750
   0.46239    0.5833
   0.06482    0.2717

Second Regime
Percentage of Obs 0.9395833

  Equation 1
  -0.016989    0.02271
   0.021693    0.01964
  -0.001802    0.10336
   0.069806    0.05617

  Equation 2
   0.037612    0.03752
  -0.003784    0.03815
   0.207725    0.18092
   0.158085    0.12681

Wald Test for Equality of Dynamic Coefs  4.868932   0.3010122
Wald Test for Equality of ECM Coef       24.08407   5.891304e-06


[1] "short_i"
[1] 21
[1] "long_i"
[1] 30
[1] "long_i"
    V36   V27
1 2.183 1.575
2 2.246 1.548
3 2.308 1.874
**********************************************************

Long Rate  (month):      120
Short Rate (month):      24
Number of VAR lags:      1

Linear VECM Estimates

Cointegrating Vector  1
Negative Log-Like     -1224.432
AIC                   -1208.432
BIC                   -1202.982

  Equation 1
  -0.003543    0.03504
   0.013003    0.02200
   0.001885    0.11950
   0.050618    0.07498

  Equation 2
   0.117996    0.06565
  -0.041000    0.04156
   0.247643    0.20171
   0.039889    0.13062



Threshold VECM Estimates

Threshold Estimate             -0.615
Cointegrating Vector Estimate  1
Negative Log-Like              -1264.154
AIC                            -1232.154
BIC                            -1221.255

First Regime
Percentage of Obs 0.05625

  Equation 1
   0.3570    0.3883
   0.3705    0.3219
  -0.2282    0.4202
   0.1135    0.2850

  Equation 2
   1.5866    0.5893
   1.2287    0.4865
  -0.4015    0.7431
   0.6050    0.4874

Second Regime
Percentage of Obs 0.94375

  Equation 1
  -0.024202    0.03181
   0.025431    0.01952
   0.005635    0.12250
   0.077979    0.07537

  Equation 2
   0.045166    0.04708
   0.001201    0.03288
   0.261874    0.20024
   0.056460    0.13149

Wald Test for Equality of Dynamic Coefs  13.52153   0.008989617
Wald Test for Equality of ECM Coef       72.71585   1.110223e-16

10
jiezichen 发表于 2011-11-2 12:07:31
epoh 发表于 2011-11-2 11:56
[1] "short_i"
[1] 4
[1] "long_i"
是的 我就比较两组数据 30行 2列 一共才这么点数据,我把zeroyld里的数据删了,放进去自己的,然后把tar_ci里面的
dat <- 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)))
short <- 12
long <- 120
short_i <- which.max(rs==short)
long_i <- which.max(rs==long)
dat <- dat[,cbind(long_i,short_i)]  

这一块给删了
结果只得到Linear VECM Estimates
但是 Threshold VECM Estimates 之后就没了


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

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