我正在研究单元根测试将如何对二进制变量执行。但是我得到了一些意想不到的结果:
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。这意味着我们可以拒绝单位根存在。现在,我的问题:
答案 0 :(得分:0)
我运行了您的代码,结果是:
Cam_NewFrame
也许你可以重试它。