TVECM.sim: Simulation and bootstrap of bivariate VECM/TVECM

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/TVECM.sim.R

Description

Estimate or bootstraps a multivariate Threshold VAR

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
VECM.sim(data, B, VECMobject, beta, n = 200, lag = 1, type = c("simul",
  "boot", "check"), include = c("const", "trend", "none", "both"),
  starting = NULL, innov = rmnorm(n, varcov = varcov), varcov = diag(1,
  k), show.parMat = FALSE, seed)

VECM.boot(VECMobject, show.parMat = FALSE, seed, check = TRUE)

TVECM.boot(TVECMobject, show.parMat = FALSE, seed, check = TRUE)

TVECM.sim(data, B, TVECMobject, nthresh = 1, Thresh, beta, n = 200,
  lag = 1, type = c("simul", "boot", "check"), include = c("const",
  "trend", "none", "both"), starting = NULL, innov = rmnorm(n, varcov =
  varcov), varcov = diag(1, k), show.parMat = FALSE, seed)

Arguments

data

matrix of parameter to simulate

B

Matrix of coefficients to simulate

beta

The cointegrating value

n

Number of observations to create when type="simul"

lag

Number of lags to include in each regime

type

Whether a bootstrap or simulation is to employ. See details

include

Type of deterministic regressors to include. NOT WORKING PROPERLY CURRENTLY if not const

starting

Starting values when a simulation with given parameter matrix is made

innov

Innovations used for simulation. Should be matrix of dim nxk. By default multivariate normal.

varcov

Variance-covariance matrix for the innovations. By default multivariate normal is used.

show.parMat

Logical. Should the parameter matrix be shown? Useful to understand how to give right input

seed

Optional. Seed for the random number generation.

check

When performing a bootstrap replication, check if taking original residuals (instead of resampled) leads to the original data.

TVECMobject,VECMobject

Object computed by function TVECM or linear VECM

nthresh

number of threshold (see details)

Thresh

The threshold value(s). Vector of length nthresh

Details

This function offers the possibility to generate series following a VECM/TVECM from two approaches: bootstrap or simulation. VECM.sim is just a wrapper for TVECM.sim.

When the argument matrix is given, on can only simulate a VECM (nthresh=0) or TVECM (nthresh=1 or 2). One can have a specification with constant ("const"), "trend", "both" or "none" (see argument include). Order for the parameters is ECT/include/lags for VECM and ECT1/include1/lags1/ECT2/include2/lags2 for TVECM. To be sure that once is using it correctly, setting show.parMat = TRUE will show the matrix of parameters together with their values and names.

The argument beta is the contegrating value on the right side of the long-run relationship, and hence the function use the vector (1,-beta). The innov argument specifies the innovations. It should be given as a matrix of dim nxk, (here n does not include the starting values!), by default it uses a multivariate normal distribution, with covariance matrix specified by varcov.

The starting values (of dim lags x k) can be given through argument starting. The user should take care for their choice, since it is not sure that the simulated values will cross the threshold even once. Notice that only one cointegrating value is allowed. User interested in simulating a VECM with more cointegrating values should do use the VAR representation and use TVAR.sim.

The second possibility is to bootstrap series. This is done on a object generated by TVECM (or VECM). A simple residual bootstrap is done, or one can simulate a series with the same parameter matrix and with normal distributed residuals (with variance pre-specified), corresponding to Monte-carlo simulations.

One can alternatively give only the series, and then the function will call internally TVECM.

Value

A matrix with the simulated/bootstraped series.

Author(s)

Matthieu Stigler

See Also

TVECM to estimate a TVECM, VAR.sim to simulate/bootstrap a VAR.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
###reproduce example in Enders (2004, 2 edition) p. 350,
# (similar example in Enders (2010, 3 edition) 301-302).

if(require(mnormt)){
#see that the full "VAR" coefficient matrix is:
 A <- matrix(c(-0.2, 0.2, 0.2, -0.2), byrow=TRUE, ncol=2)

# but this is not the input of VECM.sim. You should decompose into the a and b matrix:
 a<-matrix(c(-0.2, 0.2), ncol=1)
 b<-matrix(c(1,-1), nrow=1)

# so that:
 a%*%b

# The a matrix is the input under argument B, while the b matrix is under argument beta:
# (the other zeros in B are for the not-specified lags)
 innov<-rmnorm(100, varcov=diag(2))
 startVal <- matrix(0, nrow=2, ncol=1)
 Bvecm <- rbind(c(-0.2, 0,0), c(0.2, 0,0))
 vecm1 <- VECM.sim(B=Bvecm, beta=1,n=100, lag=1,include="none", innov=innov, starting=startVal)
 ECT <- vecm1[,1]-vecm1[,2]

#add an intercept as in panel B
 Bvecm2 <- rbind(c(-0.2, 0.1,0,0), c(0.2,0.4, 0,0))
 vecm2 <- VECM.sim(B=Bvecm2,  n=100,beta=1, lag=1,include="const", innov=innov, starting=startVal)

 par(mfrow=c(2,1))
 plot(vecm1[,1], type="l", main="Panel a: no drift or intercept", ylab="", xlab="")
 lines(vecm1[,2], lty=2)
 plot(vecm2[,1], type="l", main="Panel b: drift terms (0.1)", ylab="", xlab="")
 lines(vecm2[,2], lty=2)
}
##Bootstrap a TVAR with 1 threshold (two regimes)
data(zeroyld)
dat<-zeroyld
TVECMobject<-TVECM(dat, nthresh=1, lag=1, ngridBeta=20, ngridTh=20, plot=FALSE)
TVECM.sim(TVECMobject=TVECMobject,type="boot")

##Check the bootstrap
TVECM.sim.check <- TVECM.sim(TVECMobject=TVECMobject,type="check")
all(TVECM.sim.check==dat)

Example output

Loading required package: mnormt
29 (7.2%) points of the grid lead to regimes with percentage of observations < trim and were not computed
         [,1]   [,2]
  [1,]  2.183  1.575
  [2,]  2.246  1.545
  [3,]  2.376  1.858
  [4,]  2.305  1.736
  [5,]  2.142  0.966
  [6,]  2.045  0.462
  [7,]  2.161  0.742
  [8,]  2.455  1.067
  [9,]  2.477  1.309
 [10,]  2.696  1.259
 [11,]  2.914  1.266
 [12,]  3.704  2.486
 [13,]  3.811  2.922
 [14,]  2.678  0.954
 [15,]  2.596  0.168
 [16,]  2.172  0.198
 [17,]  3.237  2.295
 [18,]  3.400  2.849
 [19,]  3.662  3.390
 [20,]  4.433  4.165
 [21,]  3.778  3.994
 [22,]  3.879  4.373
 [23,]  4.043  4.491
 [24,]  4.096  4.548
 [25,]  4.305  5.097
 [26,]  4.354  5.030
 [27,]  4.449  4.889
 [28,]  4.543  5.117
 [29,]  3.848  4.697
 [30,]  4.026  4.537
 [31,]  4.086  4.651
 [32,]  4.141  4.721
 [33,]  4.073  4.371
 [34,]  3.841  3.896
 [35,]  3.275  3.628
 [36,]  3.142  2.981
 [37,]  2.605  2.067
 [38,]  2.709  1.925
 [39,]  3.004  2.349
 [40,]  2.170  0.754
 [41,]  2.299  1.421
 [42,]  2.616  2.719
 [43,]  2.525  3.152
 [44,]  2.948  4.404
 [45,]  3.351  4.896
 [46,]  3.312  4.898
 [47,]  3.321  4.489
 [48,]  3.494  4.829
 [49,]  3.585  4.996
 [50,]  3.572  4.971
 [51,]  3.792  5.231
 [52,]  4.152  5.939
 [53,]  4.766  6.227
 [54,]  4.773  6.391
 [55,]  5.006  6.076
 [56,]  5.368  6.551
 [57,]  5.534  6.957
 [58,]  5.785  7.058
 [59,]  5.969  6.819
 [60,]  6.416  7.421
 [61,]  6.078  7.147
 [62,]  6.285  7.176
 [63,]  6.107  7.165
 [64,]  6.395  7.318
 [65,]  6.632  8.119
 [66,]  6.573  7.788
 [67,]  7.149  7.994
 [68,]  7.495  8.736
 [69,]  7.707  8.930
 [70,]  7.919  8.889
 [71,]  8.837  9.968
 [72,]  8.824 10.452
 [73,]  8.669  9.922
 [74,]  8.722  9.737
 [75,]  8.460  8.309
 [76,]  8.808  8.030
 [77,]  8.883  7.941
 [78,]  8.832  8.098
 [79,]  8.804  8.108
 [80,]  8.606  7.895
 [81,]  8.831  7.848
 [82,]  8.632  7.660
 [83,]  9.161  8.286
 [84,]  9.312  9.109
 [85,]  9.646 10.135
 [86,]  9.656 10.951
 [87,]  9.801 10.804
 [88,]  9.846 10.891
 [89,]  9.296  9.735
 [90,]  9.479  9.723
 [91,]  9.912  9.695
 [92,] 10.073  9.973
 [93,] 10.189  9.889
 [94,] 10.203  9.466
 [95,] 10.120  9.287
 [96,] 10.463  9.879
 [97,] 10.111  9.686
 [98,] 10.055 10.423
 [99,] 10.108 10.412
[100,] 10.164 10.837
[101,] 10.307 10.983
[102,] 10.520 11.492
[103,] 10.547 11.583
[104,] 11.151 13.317
[105,] 11.100 12.583
[106,] 11.063 12.128
[107,] 10.532 10.848
[108,] 10.820 11.149
[109,] 10.941 11.351
[110,] 11.029 11.461
[111,] 11.144 11.458
[112,] 11.134 11.343
[113,] 11.155 11.512
[114,] 11.068 11.150
[115,] 10.955 11.099
[116,] 10.931 11.259
[117,] 10.904 11.209
[118,] 11.008 11.311
[119,] 10.691 10.893
[120,] 10.526 10.516
[121,] 10.368 10.400
[122,] 10.031  9.780
[123,] 10.051  9.692
[124,] 10.032  9.757
[125,] 10.154  9.302
[126,]  9.492  8.238
[127,]  9.545  8.190
[128,]  9.934  9.494
[129,]  9.782  9.687
[130,]  9.866  9.297
[131,]  9.775  8.913
[132,]  9.831  8.975
[133,]  9.522  8.947
[134,]  9.475  9.398
[135,]  9.279  9.418
[136,]  9.274  9.285
[137,]  9.410  9.511
[138,]  9.997  9.962
[139,] 10.331 10.742
[140,] 11.134 11.499
[141,] 11.291 11.687
[142,] 11.558 12.142
[143,] 12.066 12.870
[144,] 12.149 13.342
[145,] 11.588 12.668
[146,] 11.600 11.876
[147,] 11.979 12.152
[148,] 12.158 12.555
[149,] 12.261 12.942
[150,] 12.715 13.421
[151,] 13.224 14.126
[152,] 13.361 14.467
[153,] 13.450 14.196
[154,] 13.354 13.706
[155,] 12.886 13.243
[156,] 12.364 12.470
[157,] 12.405 12.589
[158,] 12.479 12.725
[159,] 12.509 12.735
[160,] 12.464 12.779
[161,] 12.135 12.177
[162,] 12.025 12.029
[163,] 12.184 12.321
[164,] 12.434 12.673
[165,] 12.380 12.389
[166,] 12.434 12.336
[167,] 12.507 12.244
[168,] 12.402 12.006
[169,] 12.424 12.164
[170,] 12.567 12.602
[171,] 12.613 13.037
[172,] 12.579 12.372
[173,] 12.358 11.749
[174,] 12.878 12.963
[175,] 13.842 14.090
[176,] 14.045 13.858
[177,] 14.089 13.771
[178,] 14.257 13.800
[179,] 14.384 14.032
[180,] 14.679 14.783
[181,] 14.588 14.998
[182,] 14.854 15.345
[183,] 15.281 16.231
[184,] 15.525 16.566
[185,] 14.895 15.789
[186,] 14.981 14.792
[187,] 14.849 15.157
[188,] 14.850 15.138
[189,] 15.096 15.372
[190,] 15.155 15.434
[191,] 15.094 15.488
[192,] 15.355 15.800
[193,] 15.736 16.620
[194,] 15.837 16.941
[195,] 15.261 15.616
[196,] 15.261 15.435
[197,] 14.553 14.146
[198,] 14.835 14.433
[199,] 14.804 14.590
[200,] 14.767 14.218
[201,] 14.923 14.198
[202,] 15.024 13.704
[203,] 15.248 13.651
[204,] 15.513 14.860
[205,] 15.548 15.046
[206,] 15.694 15.199
[207,] 15.936 14.996
[208,] 15.844 14.587
[209,] 15.808 14.436
[210,] 15.823 14.407
[211,] 15.881 14.911
[212,] 15.947 14.956
[213,] 16.387 15.219
[214,] 16.195 15.122
[215,] 16.247 15.080
[216,] 16.214 14.955
[217,] 16.110 14.624
[218,] 16.326 14.930
[219,] 15.987 14.881
[220,] 16.675 15.498
[221,] 16.448 15.026
[222,] 16.506 15.016
[223,] 16.535 15.084
[224,] 16.755 16.086
[225,] 16.745 16.169
[226,] 16.741 16.095
[227,] 16.760 16.102
[228,] 16.420 15.632
[229,] 16.813 15.389
[230,] 17.627 16.194
[231,] 17.764 16.594
[232,] 17.705 16.722
[233,] 17.848 17.169
[234,] 17.739 16.852
[235,] 17.511 16.395
[236,] 17.317 16.003
[237,] 16.736 15.446
[238,] 16.336 15.042
[239,] 15.734 14.700
[240,] 15.578 14.440
[241,] 15.644 14.507
[242,] 15.593 14.415
[243,] 15.382 13.440
[244,] 15.404 13.318
[245,] 15.219 13.181
[246,] 15.676 13.412
[247,] 16.094 13.861
[248,] 16.508 15.329
[249,] 16.599 15.457
[250,] 16.397 15.118
[251,] 16.328 14.993
[252,] 16.342 14.977
[253,] 16.375 14.962
[254,] 16.061 14.932
[255,] 16.000 14.968
[256,] 15.969 14.822
[257,] 16.167 15.387
[258,] 16.228 15.592
[259,] 16.230 16.743
[260,] 16.203 16.632
[261,] 16.879 18.618
[262,] 16.923 18.310
[263,] 16.958 17.154
[264,] 16.795 16.955
[265,] 16.885 16.955
[266,] 16.935 16.899
[267,] 17.164 16.617
[268,] 17.246 16.078
[269,] 17.197 16.316
[270,] 17.007 15.366
[271,] 16.980 15.363
[272,] 17.057 15.556
[273,] 17.052 15.604
[274,] 17.248 15.722
[275,] 16.924 15.318
[276,] 16.828 15.028
[277,] 16.737 14.806
[278,] 16.757 14.889
[279,] 16.459 14.560
[280,] 16.534 14.550
[281,] 16.709 14.772
[282,] 16.724 14.750
[283,] 16.868 15.093
[284,] 16.696 15.007
[285,] 16.619 15.166
[286,] 16.324 14.541
[287,] 16.268 14.592
[288,] 16.341 13.955
[289,] 15.942 13.252
[290,] 15.809 12.876
[291,] 15.944 13.132
[292,] 15.864 12.982
[293,] 15.865 13.198
[294,] 15.913 13.408
[295,] 15.900 13.480
[296,] 15.960 13.614
[297,] 16.403 14.182
[298,] 16.540 14.596
[299,] 15.440 12.623
[300,] 15.466 12.345
[301,] 15.581 12.514
[302,] 15.457 12.696
[303,] 14.427 11.873
[304,] 14.595 12.054
[305,] 14.674 12.381
[306,] 14.921 12.435
[307,] 15.157 12.359
[308,] 15.091 12.302
[309,] 16.142 14.451
[310,] 16.550 15.049
[311,] 16.714 15.511
[312,] 16.666 15.729
[313,] 16.466 15.518
[314,] 16.124 14.918
[315,] 16.015 14.575
[316,] 16.067 14.384
[317,] 16.061 14.385
[318,] 15.628 13.805
[319,] 15.607 13.682
[320,] 15.430 13.936
[321,] 15.157 13.637
[322,] 15.241 13.497
[323,] 14.919 13.481
[324,] 15.067 13.556
[325,] 15.462 14.740
[326,] 15.620 15.059
[327,] 15.377 14.603
[328,] 15.430 14.616
[329,] 14.700 13.933
[330,] 14.800 13.934
[331,] 14.852 14.249
[332,] 14.225 13.449
[333,] 14.292 13.509
[334,] 14.301 13.528
[335,] 13.660 11.753
[336,] 13.506 12.291
[337,] 13.645 12.910
[338,] 13.816 13.295
[339,] 13.832 14.369
[340,] 13.970 14.813
[341,] 14.085 14.540
[342,] 14.188 15.210
[343,] 14.518 15.244
[344,] 14.849 15.480
[345,] 15.131 15.785
[346,] 16.170 16.893
[347,] 16.474 17.872
[348,] 16.533 17.410
[349,] 16.674 17.031
[350,] 17.370 18.254
[351,] 16.854 16.862
[352,] 16.811 16.662
[353,] 16.301 15.781
[354,] 16.125 15.064
[355,] 16.115 14.843
[356,] 16.258 14.821
[357,] 16.318 14.909
[358,] 16.430 15.240
[359,] 17.007 16.670
[360,] 17.305 17.340
[361,] 17.406 17.601
[362,] 17.206 17.506
[363,] 17.405 17.508
[364,] 17.374 17.177
[365,] 17.144 16.988
[366,] 16.927 16.495
[367,] 16.950 16.387
[368,] 17.060 16.378
[369,] 16.361 15.179
[370,] 15.882 14.191
[371,] 15.755 13.598
[372,] 15.744 13.538
[373,] 15.722 13.385
[374,] 15.768 13.746
[375,] 16.092 13.899
[376,] 16.149 14.085
[377,] 16.120 14.115
[378,] 16.213 14.421
[379,] 15.876 13.918
[380,] 15.846 13.675
[381,] 16.012 13.845
[382,] 15.894 13.865
[383,] 15.849 14.106
[384,] 15.739 13.447
[385,] 15.972 14.555
[386,] 15.945 14.589
[387,] 16.025 15.525
[388,] 16.080 15.197
[389,] 16.249 15.238
[390,] 16.274 15.189
[391,] 16.489 15.143
[392,] 16.438 14.914
[393,] 16.254 15.119
[394,] 16.262 14.751
[395,] 16.165 14.420
[396,] 16.070 14.515
[397,] 16.068 14.455
[398,] 16.022 14.623
[399,] 15.825 14.285
[400,] 15.550 13.753
[401,] 15.819 13.821
[402,] 15.904 14.007
[403,] 15.904 14.012
[404,] 16.177 14.186
[405,] 16.157 14.343
[406,] 16.386 14.612
[407,] 16.144 15.210
[408,] 16.243 15.093
[409,] 15.858 14.511
[410,] 15.773 14.335
[411,] 15.961 14.689
[412,] 15.915 14.872
[413,] 16.178 15.207
[414,] 15.974 14.959
[415,] 15.866 14.688
[416,] 15.996 14.757
[417,] 15.771 14.800
[418,] 16.014 14.550
[419,] 15.835 13.821
[420,] 15.780 13.657
[421,] 15.563 13.315
[422,] 15.553 13.442
[423,] 15.629 13.676
[424,] 15.681 14.019
[425,] 15.705 13.956
[426,] 15.651 14.191
[427,] 15.814 14.533
[428,] 15.569 14.054
[429,] 15.719 14.129
[430,] 15.743 14.075
[431,] 15.466 13.963
[432,] 15.624 14.449
[433,] 15.733 14.679
[434,] 15.832 14.792
[435,] 15.794 14.792
[436,] 16.176 15.063
[437,] 16.929 15.565
[438,] 16.769 15.297
[439,] 16.481 14.519
[440,] 16.362 14.206
[441,] 16.426 14.504
[442,] 16.246 14.398
[443,] 16.297 14.188
[444,] 16.254 14.173
[445,] 16.205 13.808
[446,] 16.235 13.911
[447,] 16.011 13.662
[448,] 15.272 12.990
[449,] 15.086 12.451
[450,] 15.080 12.490
[451,] 14.629 11.039
[452,] 14.715 11.281
[453,] 15.269 12.148
[454,] 15.126 12.259
[455,] 15.269 12.599
[456,] 14.791 12.223
[457,] 14.868 12.437
[458,] 15.643 13.232
[459,] 15.835 13.774
[460,] 15.662 12.985
[461,] 15.591 12.686
[462,] 15.700 12.843
[463,] 15.698 13.094
[464,] 15.961 13.643
[465,] 16.209 14.260
[466,] 16.931 15.168
[467,] 16.568 14.101
[468,] 16.405 14.038
[469,] 16.364 14.050
[470,] 16.442 13.981
[471,] 16.347 13.963
[472,] 16.086 13.860
[473,] 16.069 13.246
[474,] 16.298 13.326
[475,] 16.295 13.504
[476,] 16.427 13.203
[477,] 16.631 13.723
[478,] 16.592 13.637
[479,] 16.276 13.544
[480,] 16.453 13.826
[481,] 16.511 14.071
[482,] 16.172 13.593
[1] TRUE

tsDyn documentation built on May 29, 2017, 10:48 a.m.

Search within the tsDyn package
Search all R packages, documentation and source code