File: t_DickeyFullerTest_std.py

package info (click to toggle)
openturns 1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 38,588 kB
  • ctags: 26,495
  • sloc: cpp: 144,032; python: 26,855; ansic: 7,868; sh: 419; makefile: 263; yacc: 123; lex: 44
file content (31 lines) | stat: -rwxr-xr-x 1,164 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! /usr/bin/env python

from __future__ import print_function
import openturns as ot

size = 100

# ARMA parameters
arcoefficients = ot.ARMACoefficients([0.3])
macoefficients = ot.ARMACoefficients(0)
timeGrid = ot.RegularGrid(0.0, 0.1, size)

# White noise ==> gaussian
whiteNoise = ot.WhiteNoise(ot.Normal(), timeGrid)
myARMA = ot.ARMA(arcoefficients, macoefficients, whiteNoise)

# A realization of the ARMA process
# The realization is supposed to be of a stationnary process
realization = ot.TimeSeries(myARMA.getRealization())

# In the strategy of tests, one has to detect a trend tendency
# We check if the time series writes as x_t = a +b * t + c * x_{t-1}
# H0 = c is equal to one and thus
# p-value threshold : probability of the H0 reject zone : 1-0.95
# p-value : probability (test variable decision > test variable decision (statistic) evaluated on data)
# Test = True <=> p-value > p-value threshold
test = ot.DickeyFullerTest(realization)
print("Drift and linear trend model=",
      test.testUnitRootInDriftAndLinearTrendModel(0.95))
print("Drift model=", test.testUnitRootInDriftModel(0.95))
print("AR1 model=", test.testUnitRootInAR1Model(0.95))