Pakiety potrzebne do rozwiązania zadania

library(readxl)
library(urca)
library(tseries)
library(lmtest)
library(dplyr)
library(dynlm)
library(vars)

Import danych z pliku xlsx i przygotowanie zmiennych

setwd("E:/")
U_S_macroeconomy = read_excel("U.S.macroeconomy.xlsx")
View(U_S_macroeconomy)
#
inf=U_S_macroeconomy$inflation
unrate=U_S_macroeconomy$unrate
ff=U_S_macroeconomy$fedfunds

Źródło danych: Becketti (2020)

Wykresy szeregów czasowych

t=1:209
par(mfrow = c(2, 2), mar = c(2.5, 2.5, 1.2, 1.2), cex = 0.6)
plot(inf,type="l", col="red", main="inflation")
abline(lm(inf~t))
plot(unrate, type="l", col="red", main="unemployment")
abline(lm(unrate~t))
plot(ff, type="l", col="red", main="fedfunds")
abline(lm(ff~t))

Oszacowanie pomocnicznych modeli trendu dla zmiennych

Aby upewnić się, jakie deterministyczne składniki występują w analizowanych szeregach czasowych szacujemy proste modele trendu dla każdej ze zmiennych. Brak istotności wyrazu wolnego i trendu będzie oznaczało, że w teście ADF ur.df type=“none”, w przypadku istotności jedynie wyrazu wolnego type=“drift”, istotny wyraz wolny i trend to t=“trend”.

summary(lm(inf~t))
## 
## Call:
## lm(formula = inf ~ t)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.0762 -1.3071 -0.4017  0.9697  7.7527 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  4.764531   0.313715  15.187  < 2e-16 ***
## t           -0.012094   0.002591  -4.668 5.45e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.26 on 207 degrees of freedom
## Multiple R-squared:  0.09525,    Adjusted R-squared:  0.09088 
## F-statistic: 21.79 on 1 and 207 DF,  p-value: 5.454e-06
summary(lm(unrate~t))
## 
## Call:
## lm(formula = unrate ~ t)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.4599 -1.0348 -0.2153  1.1066  4.6790 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 5.511922   0.219747   25.08  < 2e-16 ***
## t           0.005171   0.001815    2.85  0.00482 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.583 on 207 degrees of freedom
## Multiple R-squared:  0.03775,    Adjusted R-squared:  0.0331 
## F-statistic:  8.12 on 1 and 207 DF,  p-value: 0.00482
summary(lm(ff~t))
## 
## Call:
## lm(formula = ff ~ t)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.5681 -2.7634 -0.0509  1.6831 11.8412 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  7.367792   0.463644   15.89  < 2e-16 ***
## t           -0.016616   0.003829   -4.34 2.23e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.339 on 207 degrees of freedom
## Multiple R-squared:  0.0834, Adjusted R-squared:  0.07897 
## F-statistic: 18.83 on 1 and 207 DF,  p-value: 2.229e-05

We wszystkich trzech modelach zarówno wyraz wolny jak i trend są statystycznie istotne, oznacza to, że włączamy te elementy do regresji pomocnicznych w teście ADF.

Test ADF dla poziomów zmiennych.

adf_inf = ur.df(inf, type = c("trend"), lags = 12, selectlags ="BIC" )
summary(adf_inf)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.5761 -0.6129 -0.0500  0.5701  3.4003 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.775761   0.275733   2.813  0.00541 ** 
## z.lag.1     -0.113556   0.038490  -2.950  0.00357 ** 
## tt          -0.003244   0.001536  -2.112  0.03599 *  
## z.diff.lag1 -0.309007   0.072624  -4.255 3.27e-05 ***
## z.diff.lag2 -0.170329   0.070714  -2.409  0.01696 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.082 on 191 degrees of freedom
## Multiple R-squared:  0.1736, Adjusted R-squared:  0.1563 
## F-statistic: 10.03 on 4 and 191 DF,  p-value: 2.169e-07
## 
## 
## Value of test-statistic is: -2.9503 3.1518 4.7265 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.99 -3.43 -3.13
## phi2  6.22  4.75  4.07
## phi3  8.43  6.49  5.47
adf_unrate = ur.df(unrate, type = c("trend"), lags = 12, selectlags ="BIC" )
summary(adf_unrate)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.69143 -0.15928 -0.02856  0.12049  1.04319 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.1941232  0.0723227   2.684  0.00791 ** 
## z.lag.1     -0.0369297  0.0111774  -3.304  0.00114 ** 
## tt           0.0002817  0.0003222   0.874  0.38308    
## z.diff.lag   0.6788143  0.0537223  12.636  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2502 on 192 degrees of freedom
## Multiple R-squared:   0.46,  Adjusted R-squared:  0.4516 
## F-statistic: 54.52 on 3 and 192 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -3.304 3.6645 5.4896 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.99 -3.43 -3.13
## phi2  6.22  4.75  4.07
## phi3  8.43  6.49  5.47
adf_ff = ur.df(ff, type = c("trend"), lags = 12, selectlags ="BIC" )
summary(adf_ff)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.1311 -0.3240 -0.0094  0.3178  6.3889 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.625357   0.229183   2.729  0.00696 ** 
## z.lag.1     -0.062066   0.021253  -2.920  0.00392 ** 
## tt          -0.002475   0.001256  -1.970  0.05027 .  
## z.diff.lag1  0.328136   0.070642   4.645 6.34e-06 ***
## z.diff.lag2 -0.202779   0.072167  -2.810  0.00547 ** 
## z.diff.lag3  0.187090   0.070915   2.638  0.00902 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.907 on 190 degrees of freedom
## Multiple R-squared:  0.1526, Adjusted R-squared:  0.1303 
## F-statistic: 6.842 on 5 and 190 DF,  p-value: 6.817e-06
## 
## 
## Value of test-statistic is: -2.9203 3.1174 4.6609 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.99 -3.43 -3.13
## phi2  6.22  4.75  4.07
## phi3  8.43  6.49  5.47

W testach ADF dla każdej ze zmiennych wartość statystyki testowej jest odpowiednio równa -2.9503; -3.304 i -2.9203. Wartości te są większe od wartości krytycznych. Oznacza to brak podstaw do odrzucenia hipotezy zerowej, czyli świadczy o braku stacjonarności. W takim razie wyznaczamy pierwsze różnice zmiennych.

Pierwsze przyrosty zmiennych - dodanie zmiennych do tabeli

U_S_macroeconomy = U_S_macroeconomy%>%mutate(d.inf=c(NA,diff(inf)), d.unrate=c(NA,diff(unrate)),d.ff=c(NA,diff(ff)))

d.inf=U_S_macroeconomy$d.inf
d.unrate=U_S_macroeconomy$d.unrate
d.ff=U_S_macroeconomy$d.ff

Oszacowanie pomocnicznych modeli trendu dla pierwszych przyrostów zmiennych

summary(lm(d.inf~t))
## 
## Call:
## lm(formula = d.inf ~ t)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.8059 -0.5807  0.0283  0.5989  3.8037 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)
## (Intercept)  0.0547948  0.1620689   0.338    0.736
## t           -0.0005271  0.0013351  -0.395    0.693
## 
## Residual standard error: 1.156 on 206 degrees of freedom
##   (1 obserwacja została skasowana z uwagi na braki w niej zawarte)
## Multiple R-squared:  0.000756,   Adjusted R-squared:  -0.004095 
## F-statistic: 0.1559 on 1 and 206 DF,  p-value: 0.6934
summary(lm(d.unrate~t))
## 
## Call:
## lm(formula = d.unrate ~ t)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.8467 -0.1890 -0.0502  0.1109  1.6596 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.0039052  0.0477891  -0.082    0.935
## t            0.0001798  0.0003937   0.457    0.648
## 
## Residual standard error: 0.3409 on 206 degrees of freedom
##   (1 obserwacja została skasowana z uwagi na braki w niej zawarte)
## Multiple R-squared:  0.001012,   Adjusted R-squared:  -0.003838 
## F-statistic: 0.2086 on 1 and 206 DF,  p-value: 0.6484
summary(lm(d.ff~t))
## 
## Call:
## lm(formula = d.ff ~ t)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.9892 -0.3034  0.0733  0.4372  6.0135 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept)  0.087581   0.133016   0.658    0.511
## t           -0.001005   0.001096  -0.917    0.360
## 
## Residual standard error: 0.9489 on 206 degrees of freedom
##   (1 obserwacja została skasowana z uwagi na braki w niej zawarte)
## Multiple R-squared:  0.004064,   Adjusted R-squared:  -0.0007704 
## F-statistic: 0.8407 on 1 and 206 DF,  p-value: 0.3603

Zgodnie z powyższymi wynikami, w przypadku każdej ze zmiennych ani stała, ani trend nie są statystycznie istotne. W związku z tym w teście ADF dla przyrostów każdej ze zmiennych, regresja pomocnicza nie będzie uwzględniała ani wyrazu wolnego, ani trendu.

Test ADF dla pierwszych przyrostów zmiennych

sub.inf <- subset(U_S_macroeconomy$d.inf, U_S_macroeconomy$d.inf!="NA")
sub.unrate <- subset(U_S_macroeconomy$d.unrate, U_S_macroeconomy$d.unrate!="NA")
sub.ff <- subset(U_S_macroeconomy$d.ff, U_S_macroeconomy$d.ff!="NA")

adf_d.inf = ur.df(sub.inf, type = c("none"), lags = 12, selectlags ="BIC" )
summary(adf_d.inf)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression none 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.1972 -0.5433 -0.0002  0.5729  3.3090 
## 
## Coefficients:
##            Estimate Std. Error t value Pr(>|t|)    
## z.lag.1    -1.57618    0.11415 -13.808   <2e-16 ***
## z.diff.lag  0.20518    0.07082   2.897   0.0042 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.102 on 193 degrees of freedom
## Multiple R-squared:  0.6683, Adjusted R-squared:  0.6649 
## F-statistic: 194.4 on 2 and 193 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -13.8075 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau1 -2.58 -1.95 -1.62
adf_d.unrate = ur.df(sub.unrate, type = c("none"), lags = 12, selectlags ="BIC" )
summary(adf_d.unrate)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression none 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.80685 -0.14807 -0.01476  0.11572  1.02233 
## 
## Coefficients:
##            Estimate Std. Error t value Pr(>|t|)    
## z.lag.1    -0.35220    0.05997  -5.873 1.84e-08 ***
## z.diff.lag  0.03401    0.07208   0.472    0.638    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2561 on 193 degrees of freedom
## Multiple R-squared:  0.1691, Adjusted R-squared:  0.1604 
## F-statistic: 19.63 on 2 and 193 DF,  p-value: 1.732e-08
## 
## 
## Value of test-statistic is: -5.8733 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau1 -2.58 -1.95 -1.62
adf_d.ff = ur.df(sub.ff, type = c("none"), lags = 12, selectlags ="BIC" )
summary(adf_d.ff)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression none 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.7096 -0.2599  0.0077  0.3752  6.3721 
## 
## Coefficients:
##            Estimate Std. Error t value Pr(>|t|)    
## z.lag.1    -0.90710    0.08752 -10.364   <2e-16 ***
## z.diff.lag  0.18506    0.07074   2.616   0.0096 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.934 on 193 degrees of freedom
## Multiple R-squared:  0.4039, Adjusted R-squared:  0.3977 
## F-statistic: 65.38 on 2 and 193 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -10.364 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau1 -2.58 -1.95 -1.62

Wybór zmiennych do modelu VAR

I eliminacja wierszy z brakami obserwacji (“NA”). Tabela ze zmiennymi zawiera oprócz przyrostów zmiennych które są stacjonarne, również zmienne w poziomach które są I(1). Model VAR będzie zawierał jedynie zmienne stacjonarne.

subset_for_VAR = subset(U_S_macroeconomy, select=d.inf:d.ff, t>1)

Testowanie długość opóźnień w modelu VAR

subset_for_VAR = ts(subset_for_VAR)
VARselect(subset_for_VAR, lag.max = 12, type = "const")
## $selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      8      2      1      8 
## 
## $criteria
##                  1           2           3           4          5           6
## AIC(n) -2.79339596 -2.90479002 -2.95756112 -3.00783885 -3.0423682 -3.01622270
## HQ(n)  -2.71214262 -2.76259668 -2.75442777 -2.74376549 -2.7173548 -2.63026932
## SC(n)  -2.59269507 -2.55356345 -2.45580888 -2.35556094 -2.2395646 -2.06289344
## FPE(n)  0.06121402  0.05476528  0.05195927  0.04942723  0.0477739  0.04907574
##                  7           8          9         10          11          12
## AIC(n) -3.03727343 -3.11232975 -3.0930165 -3.0661504 -3.05173370 -3.03161362
## HQ(n)  -2.59038005 -2.60449636 -2.5242431 -2.4364370 -2.36108030 -2.28002021
## SC(n)  -1.93341849 -1.85794914 -1.6881102 -1.5107185 -1.34577608 -1.17513032
## FPE(n)  0.04810238  0.04468406  0.0456335  0.0469761  0.04778225  0.04890557

Kryteria informacyjne dostępne w R (Akaike (AIC), Hannan-Quinn (HQ), bayesowskie kryterium Schwarza (SC) i FPE - final prediction error) wskazują na rózne wartości opóźnień które powinny być uwzględnione w estymacji modelu VAR, odpowiednio: 8, 2, 1, 8. Literatura przedmiotu (Lutkepohl (2005)) wskazuje, że zgodne oceny rzeczywistej długości opóźnień dostarczają kryteria Hannana-Quinna (HQ), bayesowskie kryterium Schwarza (SC), natomiast AIC i FPE przeszacowują tę długość opóżnień. W związku z tym, w szacowanym modelu VAR weźmiemy p=2.

Estymacja modelu VAR

var.p2 <- VAR(subset_for_VAR, p = 2, type = "const")
summary(var.p2)
## 
## VAR Estimation Results:
## ========================= 
## Endogenous variables: d.inf, d.unrate, d.ff 
## Deterministic variables: const 
## Sample size: 206 
## Log Likelihood: -549.799 
## Roots of the characteristic polynomial:
## 0.6398 0.5416 0.5416 0.3981 0.3981 0.2033
## Call:
## VAR(y = subset_for_VAR, p = 2, type = "const")
## 
## 
## Estimation results for equation d.inf: 
## ====================================== 
## d.inf = d.inf.l1 + d.unrate.l1 + d.ff.l1 + d.inf.l2 + d.unrate.l2 + d.ff.l2 + const 
## 
##             Estimate Std. Error t value Pr(>|t|)    
## d.inf.l1    -0.41659    0.06866  -6.068 6.44e-09 ***
## d.unrate.l1 -0.84167    0.30786  -2.734  0.00682 ** 
## d.ff.l1      0.09304    0.08843   1.052  0.29401    
## d.inf.l2    -0.22934    0.06882  -3.333  0.00103 ** 
## d.unrate.l2  0.40434    0.31909   1.267  0.20659    
## d.ff.l2      0.11177    0.08892   1.257  0.21028    
## const        0.01046    0.07341   0.143  0.88679    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 1.052 on 199 degrees of freedom
## Multiple R-Squared: 0.2007,  Adjusted R-squared: 0.1766 
## F-statistic: 8.327 on 6 and 199 DF,  p-value: 4.649e-08 
## 
## 
## Estimation results for equation d.unrate: 
## ========================================= 
## d.unrate = d.inf.l1 + d.unrate.l1 + d.ff.l1 + d.inf.l2 + d.unrate.l2 + d.ff.l2 + const 
## 
##             Estimate Std. Error t value Pr(>|t|)    
## d.inf.l1    0.010329   0.016622   0.621   0.5350    
## d.unrate.l1 0.712079   0.074534   9.554   <2e-16 ***
## d.ff.l1     0.015790   0.021410   0.738   0.4617    
## d.inf.l2    0.001214   0.016661   0.073   0.9420    
## d.unrate.l2 0.021707   0.077254   0.281   0.7790    
## d.ff.l2     0.055136   0.021529   2.561   0.0112 *  
## const       0.002194   0.017772   0.123   0.9019    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.2546 on 199 degrees of freedom
## Multiple R-Squared: 0.4598,  Adjusted R-squared: 0.4435 
## F-statistic: 28.23 on 6 and 199 DF,  p-value: < 2.2e-16 
## 
## 
## Estimation results for equation d.ff: 
## ===================================== 
## d.ff = d.inf.l1 + d.unrate.l1 + d.ff.l1 + d.inf.l2 + d.unrate.l2 + d.ff.l2 + const 
## 
##              Estimate Std. Error t value Pr(>|t|)    
## d.inf.l1     0.042699   0.056179   0.760 0.448122    
## d.unrate.l1 -0.971798   0.251909  -3.858 0.000155 ***
## d.ff.l1      0.134996   0.072360   1.866 0.063566 .  
## d.inf.l2     0.163443   0.056309   2.903 0.004118 ** 
## d.unrate.l2  0.111455   0.261101   0.427 0.669938    
## d.ff.l2     -0.251217   0.072763  -3.453 0.000678 ***
## const       -0.002434   0.060066  -0.041 0.967721    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.8605 on 199 degrees of freedom
## Multiple R-Squared: 0.2063,  Adjusted R-squared: 0.1823 
## F-statistic:  8.62 on 6 and 199 DF,  p-value: 2.436e-08 
## 
## 
## 
## Covariance matrix of residuals:
##             d.inf d.unrate     d.ff
## d.inf     1.10588 -0.00948  0.11749
## d.unrate -0.00948  0.06482 -0.07337
## d.ff      0.11749 -0.07337  0.74043
## 
## Correlation matrix of residuals:
##             d.inf d.unrate    d.ff
## d.inf     1.00000 -0.03541  0.1298
## d.unrate -0.03541  1.00000 -0.3349
## d.ff      0.12984 -0.33489  1.0000

Testowanie hipotez statystycznych dla oszacowanego modelu VAR

Badanie stabilności modelu

par(mar = c(2.5, 2.5, 1.2, 1.2), cex = 0.6)
varp2.stab = stability(var.p2, type = "OLS-CUSUM")
plot(varp2.stab)

Badnie normalności rozkładu reszt

Interpretacje poniższych testów, również testu badającego autokorelację zostawiam dla Was

varp2.norm = normality.test(var.p2, multivariate.only = TRUE)
varp2.norm
## $JB
## 
##  JB-Test (multivariate)
## 
## data:  Residuals of VAR object var.p2
## Chi-squared = 1049.3, df = 6, p-value < 2.2e-16
## 
## 
## $Skewness
## 
##  Skewness only (multivariate)
## 
## data:  Residuals of VAR object var.p2
## Chi-squared = 97.758, df = 3, p-value < 2.2e-16
## 
## 
## $Kurtosis
## 
##  Kurtosis only (multivariate)
## 
## data:  Residuals of VAR object var.p2
## Chi-squared = 951.51, df = 3, p-value < 2.2e-16

Badanie autokorelacji szeregów czasowych - test Breuscha-Godfrey’a

varp2.BG <- serial.test(var.p2, lags.pt = 4, type = "BG")
varp2.BG
## 
##  Breusch-Godfrey LM test
## 
## data:  Residuals of VAR object var.p2
## Chi-squared = 95.324, df = 45, p-value = 1.79e-05

Becketti, S. (2020). Introduction to Time Series Using Stata, rev. ed. College Station: Stata Press.

Lütkepohl, H. (2005). New introduction to multiple time series analysis. Springer Science & Business Media.