[R] Testing Restrictions on Beta (long-run coefficients), reproducible example
The code given below estimates a VEC model with 4 cointegrating vectors. It is a reproducible code, so just copy and paste into your R console (or script editor). nobs = 200 e = rmvnorm(n=nobs,sigma=diag(c(.5,.5,.5,.5,.5))) e1.ar1 = arima.sim(model=list(ar=.75),nobs,innov=e[,1]) e2.ar1 = arima.sim(model=list(ar=.75),nobs,innov=e[,2]) e3.ar1 = arima.sim(model=list(ar=.75),nobs,innov=e[,3]) e4.ar1 = arima.sim(model=list(ar=.75),nobs,innov=e[,4]) y5 = cumsum(e[,5]) y1 = y5 + e1.ar1 y2 = y5 + e2.ar1 y3 = y5 + e3.ar1 y4 = y5 + e4.ar1 data = cbind(y1,y2,y3,y4,y5) jcointt = ca.jo(data,ecdet="const",type="trace",K=2,spec="transitory") summary(jcointt) # estimate VECM with 4 cointegrating vectors vecm <- cajorls(jcointt,r=4) summary(vecm$rlm) print(vecm) I want to re-estimate the model with the following restrictions put on the coinegrating vectors: ect1 ect2 ect3 ect4 y1.l1 1 0 0 0 y2.l1b1.1 1 0 0 y3.l1b2.1 0 1 0 y4.l1b3.1 0 0 1 y5.l1b4.1b4.2 b4.3 b4.4 constantc1 c2 c3c4 here, b1.1 through to b4.1 are the coefficients (β1,β2,β3,β4) of the first cointegrating vector. Similarly, b4.4 and c4 are coefficients of the fourth cointegrating equation. Then, in order to test the restrictions on Coinegrating Vectors, I run the following code: test <- blrtest(jcointt,H=H1,r=4) However, I do not know how I should specify the H1 matrix in this instance. I was wondering if someone could demonstrate how I should go ahead with testing the restrictions on long run equations and then re-estimate the model using the above restrictions: vecm2 <- cajorls(test,r=4) summary(vecm2$rlm) print(vecm2) How should I specify the H1 matrix above in order to re-estimate the re-parameterised cointegrating equations? I want to use the coefficients of the first cointegrating equation (ect1) for inference. -- View this message in context: http://r.789695.n4.nabble.com/Testing-Restrictions-on-Beta-long-run-coefficients-reproducible-example-tp4713512.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Cumulative vs. non-cumulative IRFs in R
I am using irf function from vars package. I am trying to derive cumulative IRFs. The following code describes the case of deriving cumulative IRFs: irf(vecm.l, impulse = c(g,p,h,l,s), response = g, cumulative = TRUE,n.ahead = 20, ortho=TRUE) I got the output and plotted it, it looked like cumulative values of estimated MA coefficients. But then I ran the code with cumulative switched to FALSE as below: irf(vecm.l, impulse = c(g,p,h,l,s), response = g, cumulative = FALSE,n.ahead = 20, ortho=TRUE) Output from these two codes is identical. Including cumulative = TRUEin the irf function does not produce the cumulative responses?? Please note that I converted a vecm model to var using vec2var, hence the input model is called vecm.l here. Though, I doubt it plays any significance in deriving cumulative IRFs. I would appreciate your comment, am I specifying the function incorrectly? Thanks, -- View this message in context: http://r.789695.n4.nabble.com/Cumulative-vs-non-cumulative-IRFs-in-R-tp4711138.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] TVP-ECM modelling in R
Hello, I want to estimate a TVP-ECM model in R. Is there a specific package in R that can handle TVP-ECM models? Thank you -- View this message in context: http://r.789695.n4.nabble.com/TVP-ECM-modelling-in-R-tp4710874.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] cointegration and VECM, urca package and Eviews
Hello, I estimated a VECM in Eviews and R using urca package's ca.jo(), cajorl() and vec2var() functions. Specifications are 'no trend' in Eviews and 'none' in R (no theory, just testing, feel free to make changes). Results are different, ecm and cointegrating vectors are completely different. R code is: *johcoint=ca.jo(Ydata,type=trace,ecdet=c(none),K=2,spec=transitory) summary(johcoint) vecm.r1=cajorls(johcoint,r=1) vecm.r1 vecm.l=vec2var(johcoint,r=1) ll=irf(vecm.l, impulse = B,response = A, boot = FALSE) plot(ll$irf[[1]])* Data: AB C D 1 8.6469243.9251552.2977372.764267 2 8.6438104.0482152.1407312.769231 3 8.6347324.1171142.0637242.747604 4 8.6033373.9760021.9392902.741640 5 8.6043443.9246971.9282552.732419 6 8.6288873.9215171.8786742.718437 7 8.6531673.9060761.9432362.693620 8 8.6618543.9404682.1077182.670370 9 8.6098393.8727822.0030642.689212 10 8.6140913.9058391.9737192.679186 11 8.6136923.8907971.9393112.659350 12 8.6514884.0524231.9610382.640751 13 8.6544694.1375342.1308732.622611 14 8.6931214.0747532.1084272.595760 15 8.6994353.8724122.0918162.622049 16 8.8087243.8513732.3457402.646252 17 8.8144373.8060482.0571042.728953 18 8.8365293.7430461.8258272.748266 19 8.8268983.6938971.8238803.027604 20 8.8091173.6731262.0200162.820051 21 8.6549723.6529031.5232492.538225 22 8.5159173.6595921.6177342.523293 23 8.5899193.6558221.8276452.371598 24 8.5951933.6459371.8256032.251557 25 8.6153323.6292011.6619462.254364 26 8.6712223.6094641.7330732.145093 27 8.6118823.6121101.7949371.819291 28 8.6884143.5792051.5058881.654666 29 8.6901253.5549581.4265891.731257 30 8.7259323.5332881.5223111.788969 31 8.7432793.5275911.6012611.760313 32 8.6948053.5316111.6340851.732271 33 8.6879833.5273271.6019851.836593 34 8.7169763.5146451.5890351.745653 35 8.7754643.4924271.4715621.699377 36 8.8088983.4710361.4601621.686131 37 8.8428473.4511301.5795471.670513 38 8.8717863.4280021.5972161.618989 39 8.9074253.4238871.6262081.652055 40 8.9247213.4036571.5785761.509779 41 8.9411223.3576451.5212361.607082 42 9.0091123.3140891.5067581.544039 43 9.0298943.2677951.4839681.518783 44 9.0553593.2403971.5173481.517085 45 9.0402783.2354101.5904361.509334 46 8.9937963.2523741.6511061.431041 47 8.9674643.2362651.6720981.338936 48 8.9528593.2359161.6624501.287055 49 9.1214303.2175991.7112921.263948 50 9.1478713.2051941.6766411.211038 Will anyone please help why this might happen? Perhaps I am estimating the models incorrectly? Thank you -- View this message in context: http://r.789695.n4.nabble.com/cointegration-and-VECM-urca-package-and-Eviews-tp4709708.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ca.jo function, urca package, singular matrix problem
Hi, I am trying to run a cointegration test with a dummy variable using `*ca.jo*` function in `*urca*` package. *johcoint=ca.jo(Ydata[10:60,1:5],type=trace,ecdet=c(const),K=2,spec=transitory,dumvar=dumvar) * `*dumvar*` is the binary variable that take 1 and 0 only. the first two observations are 1 and the rest are 0s. when I run the code, I get / Error in solve.default(M11) : Lapack routine dgesv: system is exactly singular: U[1,1] = 0/ I think this is something to do with the invertability of the input matrix, and this occurs only when I use `*dumvar*` only. The error message disappears if I add a 1 to the 3rd observation of `dumvar`. Below is the sample data just for info: A BC D E dumvar 1 2.255446 1.688807 1.506579 1.880152 9.575868 1 2 2.230118 1.578281 1.546805 1.905426 9.545534 1 3 2.255446 1.688807 1.506579 1.880152 9.575868 0 4 2.230118 1.578281 1.546805 1.905426 9.545534 0 5 2.255446 1.688807 1.506579 1.880152 9.575868 0 6 2.230118 1.578281 1.546805 1.905426 9.545534 0 7 2.255446 1.688807 1.506579 1.880152 9.575868 0 8 2.230118 1.578281 1.546805 1.905426 9.545534 0 9 2.255446 1.688807 1.506579 1.880152 9.575868 0 10 2.230118 1.578281 1.546805 1.905426 9.545534 0 11 2.255446 1.688807 1.506579 1.880152 9.575868 0 12 2.230118 1.578281 1.546805 1.905426 9.545534 0 13 2.255446 1.688807 1.506579 1.880152 9.575868 0 14 2.230118 1.578281 1.546805 1.905426 9.545534 0 15 2.255446 1.688807 1.506579 1.880152 9.575868 0 16 2.230118 1.578281 1.546805 1.905426 9.545534 0 17 2.255446 1.688807 1.506579 1.880152 9.575868 0 18 2.230118 1.578281 1.546805 1.905426 9.545534 0 19 2.255446 1.688807 1.506579 1.880152 9.575868 0 20 2.230118 1.578281 1.546805 1.905426 9.545534 0 21 2.255446 1.688807 1.506579 1.880152 9.575868 0 22 2.230118 1.578281 1.546805 1.905426 9.545534 0 23 2.255446 1.688807 1.506579 1.880152 9.575868 0 24 2.230118 1.578281 1.546805 1.905426 9.545534 0 25 2.255446 1.688807 1.506579 1.880152 9.575868 0 26 2.230118 1.578281 1.546805 1.905426 9.545534 0 27 2.255446 1.688807 1.506579 1.880152 9.575868 0 28 2.230118 1.578281 1.546805 1.905426 9.545534 0 29 2.255446 1.688807 1.506579 1.880152 9.575868 0 30 2.230118 1.578281 1.546805 1.905426 9.545534 0 31 2.255446 1.688807 1.506579 1.880152 9.575868 0 32 2.230118 1.578281 1.546805 1.905426 9.545534 0 33 2.255446 1.688807 1.506579 1.880152 9.575868 0 34 2.230118 1.578281 1.546805 1.905426 9.545534 0 35 2.255446 1.688807 1.506579 1.880152 9.575868 0 36 2.230118 1.578281 1.546805 1.905426 9.545534 0 37 2.255446 1.688807 1.506579 1.880152 9.575868 0 38 2.230118 1.578281 1.546805 1.905426 9.545534 0 39 2.255446 1.688807 1.506579 1.880152 9.575868 0 40 2.230118 1.578281 1.546805 1.905426 9.545534 0 41 2.255446 1.688807 1.506579 1.880152 9.575868 0 42 2.230118 1.578281 1.546805 1.905426 9.545534 0 43 2.255446 1.688807 1.506579 1.880152 9.575868 0 44 2.230118 1.578281 1.546805 1.905426 9.545534 0 45 2.255446 1.688807 1.506579 1.880152 9.575868 0 46 2.230118 1.578281 1.546805 1.905426 9.545534 0 47 2.255446 1.688807 1.506579 1.880152 9.575868 0 48 2.230118 1.578281 1.546805 1.905426 9.545534 0 49 2.255446 1.688807 1.506579 1.880152 9.575868 0 50 2.230118 1.578281 1.546805 1.905426 9.545534 0 Thank you! -- View this message in context: http://r.789695.n4.nabble.com/ca-jo-function-urca-package-singular-matrix-problem-tp4709635.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.