请教:如何用r语言做格兰杰因果关系检验

New宽客 2019-05-27 04:12:19
怎么就是找不到这个主题的文章呢
...全文
5073 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuliu663 2020-09-15
  • 打赏
  • 举报
回复 2
lmtest包即可。 > library(lmtest) > grangertest(GDP ~ consumption, order = 2, data =ts.data) Granger causality test Model 1: GDP ~ Lags(GDP, 1:2) + Lags(consumption, 1:2) Model 2: GDP ~ Lags(GDP, 1:2) Res.Df Df F Pr(>F) 1 18 2 20 -2 1.6437 0.221 > grangertest(consumption ~ GDP, order = 2, data =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(>F) 1 18 2 20 -2 13.411 0.0002717 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 检验结果表示,当原假设为“consumption不是引起GDP变化的Granger原因”,P值为0.221>0.05,我们无法拒绝原假设;而当原假设为“GDP不是引起consumption变化的Granger原因”时,P值为0.0002717<0.05,我们可以拒绝原假设。因此,可以证明:GDP是consumption的Granger原因。
exia1zZ 2021-09-03
  • 举报
回复
@liuliu663 是不是说反了,GDP~consumption 结果p为0.221&gt;0.05, 则GDP不是consumption的原因,~号前面的是预期的原因
ipchanwang 2022-02-18
  • 举报
回复
@exia1zZ a formula specification of a bivariate series like y ~ x. Currently, the methods for the generic function grangertest only perform tests for Granger causality in bivariate series. The test is simply a Wald test comparing the unrestricted model—in which y is explained by the lags (up to order order) of y and x—and the restricted model—in which y is only explained by the lags of y.
ipchanwang 2022-02-18
  • 举报
回复
@exia1zZ ## Which came first: the chicken or the egg? data(ChickEgg) ## chickens granger-cause eggs? grangertest(egg ~ chicken, order = 3, data = ChickEgg) ## eggs granger-cause chickens? grangertest(chicken ~ egg, order = 3, data = ChickEgg) 应该后面那个才是预期的格兰杰原因吧
唐更 2019-09-10
  • 打赏
  • 举报
回复
楼主直接下个vars程序包里面就都有了 ur.df(y, type = c("none", "drift", "trend"), lags = 1, selectlags = c("Fixed", "AIC", "BIC")) 单位根检验 ur.df(diff()) 差分后进行单位根检验 causality(x, cause = NULL, vcov.=NULL, boot=FALSE, boot.runs=100) 因果关系分析, 结果里有格兰杰因果检验 ——摘自经管之间
qq_43445388 2019-08-24
  • 打赏
  • 举报
回复
可以参考var(),使用其中的causality(x, cause = NULL, vcov.=NULL, boot=FALSE, boot.runs=100)
Cindy730 2019-07-30
  • 打赏
  • 举报
回复
vars包里用grangertest函数

3,424

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 其他开发语言
社区管理员
  • 其他开发语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧