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

简介: spss、R语言、Python数据分析系列(6):R语言adf单位根检验
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)
目录
相关文章
|
26天前
|
数据采集 算法 搜索推荐
R语言营销数据分析:使用R进行客户分群的实践探索
【9月更文挑战第1天】R语言以其强大的数据处理和统计分析能力,在金融数据分析、营销数据分析等多个领域发挥着重要作用。通过R语言进行客户分群,企业可以更好地理解客户需求,制定精准的营销策略,提升市场竞争力和客户满意度。未来,随着大数据和人工智能技术的不断发展,R语言在营销数据分析中的应用将更加广泛和深入。
|
30天前
|
JSON 数据格式 Python
python中有哪些常用语言成分?
Python作为一种广泛使用的编程语言,其语言成分丰富多样,涵盖了多个方面。
38 9
|
1月前
|
自然语言处理 算法 数据挖掘
基于python豆瓣电影评论的情感分析和聚类分析,聚类分析有手肘法进行检验,情感分析用snownlp
本文介绍了一个基于Python的情感分析和聚类分析项目,使用snownlp库对豆瓣电影评论进行情感分析,并采用手肘法辅助K-means算法进行聚类分析,以探索评论中的不同主题和情感集群。
基于python豆瓣电影评论的情感分析和聚类分析,聚类分析有手肘法进行检验,情感分析用snownlp
|
30天前
|
机器学习/深度学习 人工智能 文字识别
轻松识别文字,这款Python OCR库支持超过80种语言
轻松识别文字,这款Python OCR库支持超过80种语言
|
29天前
|
机器学习/深度学习 数据可视化 数据挖掘
为啥我敢说Python是数据分析界的扛把子语言?
为啥我敢说Python是数据分析界的扛把子语言?
|
1月前
|
数据挖掘 Python
【Python数据分析】假设检验的基本思想、原理和步骤
文章详细介绍了假设检验的基本思想、原理、可能犯的错误类型、基本步骤以及在不同总体情况下的检验方法,阐述了如何在Python中应用假设检验,并通过P值来判断假设的可靠性。
29 1
|
1月前
|
Rust JavaScript Java
简单对比Java、Python、Go、Rust等常见语言计算斐波拉契数的性能
简单对比Java、Python、Go、Rust等常见语言计算斐波拉契数的性能
|
1月前
|
算法 数据可视化 搜索推荐
基于python的k-means聚类分析算法,对文本、数据等进行聚类,有轮廓系数和手肘法检验
本文详细介绍了基于Python实现的k-means聚类分析算法,包括数据准备、预处理、标准化、聚类数目确定、聚类分析、降维可视化以及结果输出的完整流程,并应用该算法对文本数据进行聚类分析,展示了轮廓系数法和手肘法检验确定最佳聚类数目的方法。
|
2月前
|
机器学习/深度学习 存储 自然语言处理
使用Python实现深度学习模型:语言翻译与多语种处理
【7月更文挑战第21天】 使用Python实现深度学习模型:语言翻译与多语种处理
81 0
|
3月前
|
数据挖掘 数据处理
最近在读《谁说菜鸟不会数据分析 SPSS篇》pdf分享
《谁说菜鸟不会数据分析(SPSS篇)》面向职场新人,以轻松方式讲解SPSS在数据分析中的应用,涵盖统计描述、推断和探索性分析,避开复杂术语,适合产品运营、市场、金融等领域从业者提升效率。[PDF下载](https://zhangfeidezhu.com/?p=339)
43 0
最近在读《谁说菜鸟不会数据分析 SPSS篇》pdf分享