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)
目录
打赏
0
0
0
0
5
分享
相关文章
SQL做数据分析的困境,查询语言无法回答的真相
SQL 在简单数据分析任务中表现良好,但面对复杂需求时显得力不从心。例如,统计新用户第二天的留存率或连续活跃用户的计算,SQL 需要嵌套子查询和复杂关联,代码冗长难懂。Python 虽更灵活,但仍需变通思路,复杂度较高。相比之下,SPL(Structured Process Language)语法简洁、支持有序计算和分组子集保留,具备强大的交互性和调试功能,适合处理复杂的深度数据分析任务。SPL 已开源免费,是数据分析师的更好选择。
数据分析大神养成记:Python+Pandas+Matplotlib助你飞跃!
在数字化时代,数据分析至关重要,而Python凭借其强大的数据处理能力和丰富的库支持,已成为该领域的首选工具。Python作为基石,提供简洁语法和全面功能,适用于从数据预处理到高级分析的各种任务。Pandas库则像是神兵利器,其DataFrame结构让表格型数据的处理变得简单高效,支持数据的增删改查及复杂变换。配合Matplotlib这一数据可视化的魔法棒,能以直观图表展现数据分析结果。掌握这三大神器,你也能成为数据分析领域的高手!
118 2
基于爬虫和机器学习的招聘数据分析与可视化系统,python django框架,前端bootstrap,机器学习有八种带有可视化大屏和后台
本文介绍了一个基于Python Django框架和Bootstrap前端技术,集成了机器学习算法和数据可视化的招聘数据分析与可视化系统,该系统通过爬虫技术获取职位信息,并使用多种机器学习模型进行薪资预测、职位匹配和趋势分析,提供了一个直观的可视化大屏和后台管理系统,以优化招聘策略并提升决策质量。
333 4
2023 年第二届钉钉杯大学生大数据挑战赛初赛 初赛 A:智能手机用户监测数据分析 问题二分类与回归问题Python代码分析
本文介绍了2023年第二届钉钉杯大学生大数据挑战赛初赛A题的Python代码分析,涉及智能手机用户监测数据分析中的聚类分析和APP使用情况的分类与回归问题。
130 0
2023 年第二届钉钉杯大学生大数据挑战赛初赛 初赛 A:智能手机用户监测数据分析 问题二分类与回归问题Python代码分析
[oeasy]python052_[系统开发语言为什么默认是c语言
本文介绍了C语言为何成为系统开发的首选语言,从其诞生背景、发展历史及特点进行阐述。C语言源于贝尔实验室,与Unix操作系统相互促进,因其简洁、高效、跨平台等特性,逐渐成为主流。文章还提及了C语言的学习资料及其对编程文化的影响。
38 5
数据分析编程:SQL,Python or SPL?
数据分析编程用什么,SQL、python or SPL?话不多说,直接上代码,对比明显,明眼人一看就明了:本案例涵盖五个数据分析任务:1) 计算用户会话次数;2) 球员连续得分分析;3) 连续三天活跃用户数统计;4) 新用户次日留存率计算;5) 股价涨跌幅分析。每个任务基于相应数据表进行处理和计算。
|
5月前
|
Python与Go语言中的哈希算法实现及对比分析
Python与Go语言中的哈希算法实现及对比分析
79 0
【2023年第十一届泰迪杯数据挖掘挑战赛】B题:产品订单的数据分析与需求预测 建模及python代码详解 问题一
本文详细介绍了第十一届泰迪杯数据挖掘挑战赛B题的解决方案,涵盖了对产品订单数据的深入分析、多种因素对需求量影响的探讨,并建立了数学模型进行未来需求量的预测,同时提供了Python代码实现和结果可视化的方法。
206 3
【2023年第十一届泰迪杯数据挖掘挑战赛】B题:产品订单的数据分析与需求预测 建模及python代码详解 问题一