【问题标题】:Apply Durbin Watson test on Prais Winsten Model在 Prais Winsten 模型上应用 Durbin Watson 检验
【发布时间】:2015-10-07 07:37:12
【问题描述】:

我在生成的 prais winsten 模型上运行 Durbin Watson 测试时遇到问题。

value3<-prais.winsten(value1$model)
dwtest(value3)

我收到此错误:

Error in terms.default(formula) : no terms component nor attribute

【问题讨论】:

  • 执行此操作时出现错误
  • 您能否添加一个可重现的示例代码,错误消息也可能有用。
  • @drmariod "terms.default(formula) 中的错误:没有术语组件或属性"
  • 尝试?formula 获取有关公式的帮助...

标签: r statistics regression linear-regression


【解决方案1】:

如果没有任何合理的可重现示例,很难确定问题出在哪里,这是一种默认方式:

# Calculate Durbin-Watson                                                                         
ols <- lm(y ~ x1 + x2)  

dwtest(y ~ x1 + x2)

prais.winsten.lm(ols)

# Calcuate Autocorrelation and Partial Autocorrelation Coefficients                 
acf(resid(ols),lag.max = 5,plot = FALSE)
pacf(resid(ols),lag.max = 5,plot = FALSE)

【讨论】:

    【解决方案2】:

    您需要在 prais.winsten 返回的列表中使用 lm 函数调用 dtest

    从您的示例中可以:

    dwtest(lm(value3[[1]]))

    当您显示 value3 时,您应该在顶部看到类似这样的内容

    [[1]]

    调用: lm(公式 = fo)

    这就是我所指的。

    【讨论】:

      猜你喜欢
      • 2018-02-04
      • 1970-01-01
      • 2018-08-27
      • 2019-09-26
      • 2014-05-06
      • 2016-02-13
      • 2017-06-08
      • 1970-01-01
      • 2021-02-25
      相关资源
      最近更新 更多