r - 从 R 中的 urca 包中提取断点

标签 r breakpoints summary

我需要从函数 ur.za (即 Zivot & Andrews 单位根测试)或包 urca 中的 summary 中提取断点。

library(urca)
data(nporg)
gnp <- na.omit(nporg[, "gnp.r"])
za.gnp <- ur.za(gnp, model="both", lag=2)
summary(za.gnp)

总结如下。所以我需要提取摘要末尾给出的断点 21。

################################ 
# Zivot-Andrews Unit Root Test # 
################################ 


Call:
lm(formula = testmat)

Residuals:
    Min      1Q  Median      3Q     Max 
-39.753  -9.413   2.138   9.934  22.977 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept)  21.49068   10.25301   2.096  0.04096 *  
y.l1          0.77341    0.05896  13.118  < 2e-16 ***
trend         1.19804    0.66346   1.806  0.07675 .  
y.dl1         0.39699    0.12608   3.149  0.00272 ** 
y.dl2         0.10503    0.13401   0.784  0.43676    
du          -25.44710    9.20734  -2.764  0.00788 ** 
dt            2.11456    0.84179   2.512  0.01515 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 13.72 on 52 degrees of freedom
  (3 observations deleted due to missingness)
Multiple R-squared:  0.9948,    Adjusted R-squared:  0.9942 
F-statistic:  1651 on 6 and 52 DF,  p-value: < 2.2e-16


Teststatistic: -3.8431 
Critical values: 0.01= -5.57 0.05= -5.08 0.1= -4.82 

Potential break point at position: 21 

最佳答案

我希望我的简短“评论作为答案”类型的答案没有遗漏任何内容,但也许您只是在寻找:

za.gnp@bpoint
# [1] 21

为了让这个减少评论...

str 函数通常对于理解数据结构非常有帮助。以下是“za.gnp”上 str 的前几行和最后几行。

> str(za.gnp)
Formal class 'ur.za' [package "urca"] with 10 slots
  ..@ y        : num [1:62] 117 120 123 130 131 ...
  ..@ model    : chr "both"
  ..@ lag      : int 2
  ..@ teststat : num -3.84
  ..@ cval     : num [1:3] -5.57 -5.08 -4.82
  ..@ bpoint   : int 21
  ..@ tstats   : num [1:61] -1.29 -1.29 -1.29 -1.4 -1.41 ...
  ..@ res      : Named num [1:59] 7.056 0.116 -5.917 -0.341 7.981 ...
  .. ..- attr(*, "names")= chr [1:59] "4" "5" "6" "7" ...
  ..@ testreg  :List of 13

  <<SNIP>>

  .. .. .. .. .. ..- attr(*, "names")= chr [1:7] "y" "y.l1" "trend" "y.dl1" ...
  .. .. ..- attr(*, "na.action")=Class 'omit'  Named int [1:3] 1 2 3
  .. .. .. .. ..- attr(*, "names")= chr [1:3] "1" "2" "3"
  .. ..- attr(*, "class")= chr "lm"
  ..@ test.name: chr "Zivot-Andrews"

关于r - 从 R 中的 urca 包中提取断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19056935/

相关文章:

r - 如何将函数应用于 R 中向量的每个元素

java - 如何在第三方库的 Eclipse 中设置断点?

python - 如何在 pdb (ipdb) 中找到断点号?

r - s3 有没有办法将 prop.table 组合为字符变量?

mysql - 每日日志类型汇总

r - 应用 Design-by-Contract 时,存储输入值以检查后置条件是否成立

r - 循环遍历各个数据框并添加新列

r - 使用 Xaringan 时 custom.css 消失

visual-studio-2010 - 如何在 VS2010 中启用断点余量

R - 用一个矩阵总结另一个矩阵