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)
目录
相关文章
|
3月前
|
机器学习/深度学习 数据可视化 数据挖掘
使用Python进行数据分析的入门指南
本文将引导读者了解如何使用Python进行数据分析,从安装必要的库到执行基础的数据操作和可视化。通过本文的学习,你将能够开始自己的数据分析之旅,并掌握如何利用Python来揭示数据背后的故事。
|
15天前
|
SQL 数据可视化 IDE
SQL做数据分析的困境,查询语言无法回答的真相
SQL 在简单数据分析任务中表现良好,但面对复杂需求时显得力不从心。例如,统计新用户第二天的留存率或连续活跃用户的计算,SQL 需要嵌套子查询和复杂关联,代码冗长难懂。Python 虽更灵活,但仍需变通思路,复杂度较高。相比之下,SPL(Structured Process Language)语法简洁、支持有序计算和分组子集保留,具备强大的交互性和调试功能,适合处理复杂的深度数据分析任务。SPL 已开源免费,是数据分析师的更好选择。
|
15天前
|
机器学习/深度学习 存储 数据可视化
这份Excel+Python飞速搞定数据分析手册,简直可以让Excel飞起来
本书介绍了如何将Python与Excel结合使用,以提升数据分析和处理效率。内容涵盖Python入门、pandas库的使用、通过Python包操作Excel文件以及使用xlwings对Excel进行编程。书中详细讲解了Anaconda、Visual Studio Code和Jupyter笔记本等开发工具,并探讨了NumPy、DataFrame和Series等数据结构的应用。此外,还介绍了多个Python包(如OpenPyXL、XlsxWriter等)用于在无需安装Excel的情况下读写Excel文件,帮助用户实现自动化任务和数据处理。
|
3月前
|
Unix 编译器 C语言
[oeasy]python052_[系统开发语言为什么默认是c语言
本文介绍了C语言为何成为系统开发的首选语言,从其诞生背景、发展历史及特点进行阐述。C语言源于贝尔实验室,与Unix操作系统相互促进,因其简洁、高效、跨平台等特性,逐渐成为主流。文章还提及了C语言的学习资料及其对编程文化的影响。
38 5
|
4月前
|
存储 数据可视化 数据挖掘
使用Python进行数据分析和可视化
本文将引导你理解如何使用Python进行数据分析和可视化。我们将从基础的数据结构开始,逐步深入到数据处理和分析的方法,最后通过实际的代码示例来展示如何创建直观的数据可视化。无论你是初学者还是有经验的开发者,这篇文章都将为你提供有价值的见解和技巧。让我们一起探索数据的世界,发现隐藏在数字背后的故事!
164 5
|
4月前
|
存储 数据可视化 数据挖掘
Python数据分析项目:抖音短视频达人粉丝增长趋势
Python数据分析项目:抖音短视频达人粉丝增长趋势
|
4月前
|
数据采集 存储 数据可视化
Python数据分析:揭秘"黑神话:悟空"Steam用户评论趋势
Python数据分析:揭秘"黑神话:悟空"Steam用户评论趋势
|
4月前
|
数据采集 数据可视化 数据挖掘
掌握Python数据分析,解锁数据驱动的决策能力
掌握Python数据分析,解锁数据驱动的决策能力
|
2天前
|
机器学习/深度学习 存储 设计模式
Python 高级编程与实战:深入理解性能优化与调试技巧
本文深入探讨了Python的性能优化与调试技巧,涵盖profiling、caching、Cython等优化工具,以及pdb、logging、assert等调试方法。通过实战项目,如优化斐波那契数列计算和调试Web应用,帮助读者掌握这些技术,提升编程效率。附有进一步学习资源,助力读者深入学习。
|
2天前
|
机器学习/深度学习 数据可视化 TensorFlow
Python 高级编程与实战:深入理解数据科学与机器学习
本文深入探讨了Python在数据科学与机器学习中的应用,介绍了pandas、numpy、matplotlib等数据科学工具,以及scikit-learn、tensorflow、keras等机器学习库。通过实战项目,如数据可视化和鸢尾花数据集分类,帮助读者掌握这些技术。最后提供了进一步学习资源,助力提升Python编程技能。