Home > other >  Ask: how to make a granger causality test using r language
Ask: how to make a granger causality test using r language

Time:09-16

How is can't find the theme of the article

CodePudding user response:

Vars bag with grangertest function

CodePudding user response:

Can refer to the var (), use the causality (x, cause=NULL, vcov.=NULL, the boot=FALSE, boot. Runs=100)

CodePudding user response:

The landlord directly next vars package inside have
Ur. Df (y, type=c (" none ", "drift", "trend"), lags=1, selectlags=c (" Fixed ", "AIC", "BIC")) unit root test
Ur. Df (diff ()) after the difference of unit root test
Causality (x, cause=NULL, vcov.=NULL, the boot=FALSE, boot. Runs=100) cause and effect analysis, the results of a granger causality test
From management

CodePudding user response:

Lmtest package can,

The library (lmtest)

Grangertest (GDP to consumption, the order=2, data=https://bbs.csdn.net/topics/ts.data)
Granger causality test

Model 1: ~ Lags GDP (GDP, 1:2) + Lags (consumption, 1:2)
Model 2: ~ Lags GDP (GDP, 1:2)
Res. Df Df F Pr (& gt; F)
1
1820-2 1.6437 0.221

Grangertest (consumption to GDP, the order=2, data=https://bbs.csdn.net/topics/ts.data)
Granger causality test

Model 1: consumption ~ Lags (consumption, 1:2) + Lags (GDP, 1:2)
Model 2: consumption ~ Lags (consumption, 1:2)
Res. Df Df F Pr (& gt; F)
1
1820-2 13.411 0.0002717 * * *
-- -- --
Signif. Codes: 0 '* * *' 0.001 '* *' 0.01 '*' 0.05 '. '0.1' '1

Inspection results, said when the null hypothesis is "consumption is not the Granger cause of change of GDP", P value is 0.221 & gt; 0.05 that we are unable to refuse to null hypothesis; And when the null hypothesis is "GDP is not the Granger cause of the change of the consumption, the P value is 0.0002717 & lt; 0.05, we can reject the null hypothesis, therefore, can prove that GDP is the Granger cause of consumption,
  • Related