【问题标题】:Unit root Test on binary Variables二进制变量的单位根检验
【发布时间】:2018-04-09 14:18:42
【问题描述】:

我正在研究如何对二进制变量执行单位根测试。但我得到了一些意想不到的结果:

library(quantmod)
library(tseries)
library (urca)
library (forecast)

getSymbols("MSFT")


 names(MSFT)<-c("Open", "High", "Low", "Close", "Volume", "Adjusted.Close")
 p<-data.frame(MSFT)

 n=length(p$Adjusted.Close)
# d; third column indicates direction of market.
 d<-cbind(tdy=p$Adjusted.Close[1:n-1],twm=p$Adjusted.Close[2:n],
      direct=sign( p$Adjusted.Close[2:n]-p$Adjusted.Close[1:n-1]))

plot(d[1:100,3],type="l",col = "blue")


table (d[,3])

d<-ts(d)
Ar.model <- auto.arima(d[,3], stationary = TRUE, seasonal = FALSE, ic="aic")

print(Ar.model)

    Series: d[, 3] 
    ARIMA(2,0,2) with zero mean     

    Coefficients:
     ar1      ar2      ma1     ma2
    0.0213  -0.8571  -0.0489  0.8692
     s.e.     NaN      NaN      NaN     NaN

 sigma^2 estimated as 0.9859:  log likelihood=-3843.91
   AIC=7697.82   AICc=7697.84   BIC=7727.37
   Warning message:
   In sqrt(diag(x$var.coef)) : NaNs produced

如您所见,S.E.是 NaN。我想知道我可能正面临一个单位根进程。所以我运行 ADF 测试:

  ho_adf <- ur.df(d[,3])
  summary(ho_adf)

############################################### 
# 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 
-1.0376 -0.9786  0.9624  1.0081  1.0376 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
z.lag.1    -1.021448   0.027505 -37.136   <2e-16 ***
z.diff.lag -0.008069   0.019173  -0.421    0.674    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.9938 on 2720 degrees of freedom
Multiple R-squared:  0.5149,    Adjusted R-squared:  0.5146 
F-statistic:  1444 on 2 and 2720 DF,  p-value: < 2.2e-16


Value of test-statistic is: -37.1364 

Critical values for test statistics: 
      1pct  5pct 10pct
tau1 -2.58 -1.95 -1.62

我们知道 ADF-test 的 H0 在数据中声明了单位根。上面的 p 值和检验统计量拒绝 H0。这意味着我们可以拒绝单位根的存在。现在,我的问题:

  1. 为什么在没有数据单位根的情况下得到 NaN 是 S.E?
  2. 如何解决 S.E. 的问题? (我不想使用 R 的其他 ADF.test 功能,我已经知道 KPSS 和 PP 测试; 除非它仅与二进制时间序列数据有关。意思是 您推荐的二进制时间序列的特定单位根测试。 像巴玛。在这种情况下,问题就出现了,为什么 ADF 测试会失败?)

【问题讨论】:

    标签: r statistics time-series


    【解决方案1】:

    我运行了你的代码,结果是:

    > print(Ar.model)
    Series: d[, 3] 
    ARIMA(2,0,2) with non-zero mean 
    
    Coefficients:
              ar1      ar2     ma1     ma2    mean
          -0.0566  -0.8144  0.0208  0.8187  0.0262
    s.e.   0.1570   0.1050  0.1506  0.1122  0.0183
    
    sigma^2 estimated as 0.9852:  log likelihood=-3997.69
    AIC=8007.39   AICc=8007.42   BIC=8043.08
    

    也许你可以重试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-06-25
      • 1970-01-01
      • 2013-04-15
      • 1970-01-01
      • 1970-01-01
      • 2017-06-26
      • 2019-07-13
      相关资源
      最近更新 更多