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)
目录
相关文章
|
监控 安全 数据可视化
R语言在员工上网行为监控中的数据分析
本文讲述了如何使用R语言分析员工上网行为以提升企业网络安全。通过收集网络流量和访问记录数据,利用R进行读取、分析和可视化,例如查看访问时长分布和热门网站。此外,文中还介绍了一个自动将监控数据提交到网站的R脚本,通过定时任务实现数据的持续更新和管理,及时发现并应对安全风险,增强网络安全性。
636 3
|
SQL 数据可视化 IDE
SQL做数据分析的困境,查询语言无法回答的真相
SQL 在简单数据分析任务中表现良好,但面对复杂需求时显得力不从心。例如,统计新用户第二天的留存率或连续活跃用户的计算,SQL 需要嵌套子查询和复杂关联,代码冗长难懂。Python 虽更灵活,但仍需变通思路,复杂度较高。相比之下,SPL(Structured Process Language)语法简洁、支持有序计算和分组子集保留,具备强大的交互性和调试功能,适合处理复杂的深度数据分析任务。SPL 已开源免费,是数据分析师的更好选择。
|
自然语言处理 算法 数据挖掘
基于python豆瓣电影评论的情感分析和聚类分析,聚类分析有手肘法进行检验,情感分析用snownlp
本文介绍了一个基于Python的情感分析和聚类分析项目,使用snownlp库对豆瓣电影评论进行情感分析,并采用手肘法辅助K-means算法进行聚类分析,以探索评论中的不同主题和情感集群。
764 5
基于python豆瓣电影评论的情感分析和聚类分析,聚类分析有手肘法进行检验,情感分析用snownlp
|
Python
SciPy 教程 之 Scipy 显著性检验 7
SciPy 教程之 Scipy 显著性检验第7部分,介绍显著性检验的基本概念及其在 SciPy 中的应用。显著性检验用于评估样本数据与假设之间的差异是否由随机因素引起。SciPy 的 `scipy.stats` 模块提供了执行显著性检验的功能,包括 KS 检验等方法,用于检测数据是否符合特定分布。示例代码展示了如何使用 KS 检验验证一组数据是否符合正态分布。
306 2
|
Python
SciPy 教程 之 Scipy 显著性检验 9
SciPy 教程之 Scipy 显著性检验第9部分,介绍了显著性检验的基本概念、作用及原理,通过样本信息判断假设是否成立。着重讲解了使用scipy.stats模块进行显著性检验的方法,包括正态性检验中的偏度和峰度计算,以及如何利用normaltest()函数评估数据是否符合正态分布。示例代码展示了如何计算一组随机数的偏度和峰度。
368 1
|
BI Python
SciPy 教程 之 Scipy 显著性检验 8
本教程介绍SciPy中显著性检验的应用,包括如何利用scipy.stats模块进行显著性检验,以判断样本与总体假设间的差异是否显著。通过示例代码展示了如何使用describe()函数获取数组的统计描述信息,如观测次数、最小最大值、均值、方差等。
348 1
|
Python
SciPy 教程 之 Scipy 显著性检验 3
本教程介绍Scipy显著性检验,包括其基本概念、原理及应用。显著性检验用于判断样本与总体假设间的差异是否显著,是统计学中的重要工具。Scipy通过`scipy.stats`模块提供了相关功能,支持双边检验等方法。
286 1
|
数据可视化 大数据 数据处理
大数据处理时的python和R语言
【5月更文挑战第5天】本文讨论了在语言Python 和R中数据处理时的框架,比如Python中的 OpenCV, Matplotlib, NumPy, Pandas, 和Seaborn。
454 1
大数据处理时的python和R语言
|
机器学习/深度学习 数据可视化 数据挖掘
为啥我敢说Python是数据分析界的扛把子语言?
为啥我敢说Python是数据分析界的扛把子语言?
389 1
|
Python
SciPy 教程 之 Scipy 显著性检验 1
本教程介绍Scipy显著性检验,包括统计假设、零假设和备择假设等概念,以及如何使用scipy.stats模块进行显著性检验,以判断样本与总体假设间是否存在显著差异。
334 0

推荐镜像

更多