<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Unit Root Test on 格物堂</title><link>https://gewutang.cn/tags/unit-root-test/</link><description>Recent content in Unit Root Test on 格物堂</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><lastBuildDate>Sun, 08 May 2011 00:00:00 +0000</lastBuildDate><atom:link href="https://gewutang.cn/tags/unit-root-test/index.xml" rel="self" type="application/rss+xml"/><item><title>R与单位根检验</title><link>https://gewutang.cn/2011/05/08/use-r-to-do-unitroots-test/</link><pubDate>Sun, 08 May 2011 00:00:00 +0000</pubDate><guid>https://gewutang.cn/2011/05/08/use-r-to-do-unitroots-test/</guid><description>&lt;p&gt;R里面的fUnitRoots包可以轻松实现时间序列的单位根检验。两个主函数分别是adfTest和unitrootTest。对于以应用统计为主要目的的人而言，看懂单位根检验的结果可能比探讨单位根检验的原理更重要。&lt;/p&gt;&#10;&lt;p&gt;为了清晰地表明有单位根的序列的检验结果和无单位根的序列的检验结果之间的差别，在这里生成两个可对比的单位根序列来举例：&lt;/p&gt;&#10;&lt;p&gt;首先，载入fUnitRoots包：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;library(fUnitRoots);&#10;&#10;# 生成没有单位根的序列x和由单位根的序列y&#10;&#10;x &amp;lt;- rnorm(1000) &#10;y &amp;lt;- cumsum(c(0, x)) &#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;h1 id="对序列x进行adf检验"&gt;&lt;a href="#%e5%af%b9%e5%ba%8f%e5%88%97x%e8%bf%9b%e8%a1%8cadf%e6%a3%80%e9%aa%8c" class="header-anchor"&gt;&lt;/a&gt;对序列x进行adf检验：&#10;&lt;/h1&gt;&lt;pre&gt;&lt;code class="language-r"&gt;adfTest(x)&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## Warning in adfTest(x): p-value smaller than printed p-value&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## &#10;## Title:&#10;## Augmented Dickey-Fuller Test&#10;## &#10;## Test Results:&#10;## PARAMETER:&#10;## Lag Order: 1&#10;## STATISTIC:&#10;## Dickey-Fuller: -21.1357&#10;## P VALUE:&#10;## 0.01 &#10;## &#10;## Description:&#10;## Mon May 5 17:44:36 2025 by user:&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;注意上述结果中的P值。&lt;/p&gt;&#10;&lt;p&gt;对序列y进行adf检验：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;adfTest(y) &#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## &#10;## Title:&#10;## Augmented Dickey-Fuller Test&#10;## &#10;## Test Results:&#10;## PARAMETER:&#10;## Lag Order: 1&#10;## STATISTIC:&#10;## Dickey-Fuller: 0.8508&#10;## P VALUE:&#10;## 0.8875 &#10;## &#10;## Description:&#10;## Mon May 5 17:44:36 2025 by user:&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;注意上述结果的p值，跟x序列的结果有什么区别？&lt;/p&gt;&#10;&lt;p&gt;对序列x和序列y进行单位根检验，观察下两者的区别。&lt;/p&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;unitrootTest(x)&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## &#10;## Title:&#10;## Augmented Dickey-Fuller Test&#10;## &#10;## Test Results:&#10;## PARAMETER:&#10;## Lag Order: 1&#10;## STATISTIC:&#10;## DF: -21.1357&#10;## P VALUE:&#10;## t: &amp;lt; 2.2e-16 &#10;## n: 0.001252 &#10;## &#10;## Description:&#10;## Mon May 5 17:44:36 2025 by user:&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;unitrootTest(y)&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## &#10;## Title:&#10;## Augmented Dickey-Fuller Test&#10;## &#10;## Test Results:&#10;## PARAMETER:&#10;## Lag Order: 1&#10;## STATISTIC:&#10;## DF: 0.8508&#10;## P VALUE:&#10;## t: 0.8938 &#10;## n: 0.8854 &#10;## &#10;## Description:&#10;## Mon May 5 17:44:36 2025 by user:&#10;&lt;/code&gt;&lt;/pre&gt;&#10;</description></item></channel></rss>