spss、R语言、Python数据分析系列(6):R语言adf单位根检验

16 篇文章 2 订阅
8 篇文章 0 订阅
data<-read.table('C:/Users/HXWD/Desktop/数据/rb.csv',header=TRUE,sep=',')
data=data[,5]
head(data)
data=log(data)
head(data)
adf.test(data,k = 1)

#读取数据,取对数,并进行单位根检验

Augmented Dickey-Fuller Test


data:  data
Dickey-Fuller = -1.8302, Lag order = 1, p-value = 0.6502
alternative hypothesis: stationary

#以上计算的价格的对数的单位根检验,检验结果不显著,存在单位根。但是计算每天对数收益率的时候,这个是不存在单位根的。

################################################adf.test的说明

adf.test {tseries}	R Documentation
Augmented Dickey–Fuller Test

Description

Computes the Augmented Dickey-Fuller test for the null that x has a unit root.

Usage

adf.test(x, alternative = c("stationary", "explosive"),
         k = trunc((length(x)-1)^(1/3)))
Arguments

x	
a numeric vector or time series.
alternative	
indicates the alternative hypothesis and must be one of "stationary" (default) or "explosive". You can specify just the initial letter.
k	
the lag order to calculate the test statistic.
Details

The general regression equation which incorporates a constant and a linear trend is used and the t-statistic for a first order autoregressive coefficient equals one is computed. The number of lags used in the regression is k. The default value of trunc((length(x)-1)^(1/3)) corresponds to the suggested upper bound on the rate at which the number of lags, k, should be made to grow with the sample size for the general ARMA(p,q) setup. Note that for k equals zero the standard Dickey-Fuller test is computed. The p-values are interpolated from Table 4.2, p. 103 of Banerjee et al. (1993). If the computed statistic is outside the table of critical values, then a warning message is generated.

Missing values are not allowed.

Value

A list with class "htest" containing the following components:

statistic	
the value of the test statistic.
parameter	
the lag order.
p.value	
the p-value of the test.
method	
a character string indicating what type of test was performed.
data.name	
a character string giving the name of the data.
alternative	
a character string describing the alternative hypothesis.
Author(s)

A. Trapletti

References

A. Banerjee, J. J. Dolado, J. W. Galbraith, and D. F. Hendry (1993): Cointegration, Error Correction, and the Econometric Analysis of Non-Stationary Data, Oxford University Press, Oxford.

S. E. Said and D. A. Dickey (1984): Testing for Unit Roots in Autoregressive-Moving Average Models of Unknown Order. Biometrika 71, 599–607.

See Also

pp.test

Examples

x <- rnorm(1000)  # no unit-root
adf.test(x)

y <- diffinv(x)   # contains a unit-root
adf.test(y)


评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

云金杞

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值