Reputation: 501
I am trying to identify the granger causality from one data A to data B.
data A and data B are the left and right hand sides within the cbind, respectively.
So I decided to use 'VAR.Wald' from 'VAR.etp' R package to do this work.
Case 1) If I get errors due to missing values for some data points, I understand this cannot be granger causing the relationship, so I am willing to denote them as zero granger cause.
Case 2) But I am not sure whether I should regard as zero granger cause even if the message says singularity error message. If this also means zero granger cause as well, then I could simply ignore the message regarding as zero granger cause.
To understand these, I would like to confirm whether my understanding is correct for each case 1 and 2.
For case 1, I have run the following code with such data input and got the corresponding error message.
> library(VAR.etp)
> restrict = rbind(c(1,1,2),c(2,1,2))
> p1<-VAR.select(cbind(data[1:36,1],data[1:36,2]), type = "const", ic = "aic", 8)$p
> VAR.Wald(cbind(data[1:36,1],data[1:36,2]), p = p1,restrict,type="const")
Error in solve.default(mat2) :
Lapack routine dgesv: system is exactly singular: U[2,2] = 0
> cbind(data[1:36,1],data[1:36,2])
[,1] [,2]
[1,] 0.000981476 0.000558361
[2,] 0.011151409 -0.003257835
[3,] 0.004557608 -0.006943921
[4,] 0.006205915 -0.013679118
[5,] -0.001042010 -0.008169046
[6,] -0.000386637 -0.010975501
[7,] 0.000265246 -0.010123251
[8,] 0.001653729 -0.011535562
[9,] -0.000907953 -0.007163644
[10,] 0.003093070 -0.009980498
[11,] -0.000466416 -0.012855000
[12,] 0.000109385 -0.015136829
[13,] -0.007933718 -0.007598663
[14,] 0.001733839 -0.008174362
[15,] 0.005250601 -0.008150644
[16,] 0.000433372 -0.006254862
[17,] 0.003808044 -0.007596417
[18,] -0.001854051 -0.008345769
[19,] -0.003392373 -0.015398453
[20,] 0.007375488 -0.018780131
[21,] 0.005362482 -0.017121529
[22,] 0.003666440 -0.017543625
[23,] 0.001129405 -0.014864303
[24,] 0.003299308 -0.016879411
[25,] 0.003666255 -0.019606721
[26,] -0.000924321 -0.013269746
[27,] 0.003038604 -0.009391309
[28,] 0.002231664 -0.012697503
[29,] -0.002151253 -0.010437314
[30,] 0.002374940 -0.008493108
[31,] -0.001372043 -0.006795869
[32,] 0.001088183 -0.006081438
[33,] -0.004639136 -0.001357142
[34,] 0.005875748 -0.003310532
[35,] 0.002968681 -0.007861249
[36,] 0.003829430 -0.005731017
Likewise, for case 2, I have run the following code with such data input and got the corresponding error message.
> library(VAR.etp)
> restrict = rbind(c(1,1,2),c(2,1,2))
> p1<-VAR.select(cbind(data[11:46,1],data[11:46,4]), type = "const", ic = "aic", 8)$p
> VAR.Wald(cbind(data[11:46,1],data[11:46,4]), p = p1,restrict,type="const")
Error in matrix(0, nrow = p * (k^2) + add * k) :
invalid 'nrow' value (too large or NA)
> cbind(data[11:46,1],data[11:46,4])
[,1] [,2]
[1,] -0.0004664160 NA
[2,] 0.0001093850 NA
[3,] -0.0079337180 NA
[4,] 0.0017338390 NA
[5,] 0.0052506010 NA
[6,] 0.0004333720 NA
[7,] 0.0038080440 NA
[8,] -0.0018540510 NA
[9,] -0.0033923730 NA
[10,] 0.0073754880 NA
[11,] 0.0053624820 NA
[12,] 0.0036664400 NA
[13,] 0.0011294050 NA
[14,] 0.0032993080 NA
[15,] 0.0036662550 NA
[16,] -0.0009243210 NA
[17,] 0.0030386040 NA
[18,] 0.0022316640 NA
[19,] -0.0021512530 NA
[20,] 0.0023749400 NA
[21,] -0.0013720430 NA
[22,] 0.0010881830 NA
[23,] -0.0046391360 NA
[24,] 0.0058757480 NA
[25,] 0.0029686810 NA
[26,] 0.0038294300 0.0015363910
[27,] 0.0000677289 0.0064068430
[28,] -0.0027870820 -0.0000226565
[29,] 0.0030883610 0.0187701850
[30,] 0.0061435630 -0.0031117120
[31,] 0.0001360900 0.0096137050
[32,] -0.0024424050 -0.0140845140
[33,] -0.0052592710 0.0042199480
[34,] -0.0018727950 0.0047308980
[35,] -0.0103380180 -0.0396535230
[36,] 0.0093877890 0.0377174650
Could you please confirm whether the codes' running are correct and whether my understanding & approach are correct?
Upvotes: 0
Views: 20