Testes de estacionariedade

Resumo

Este tutorial apresenta uma análise prática de estacionariedade em séries temporais. Aplica-se os testes ADF, KPSS, Phillips-Perron e Zivot-Andrews, além de visualizações como gráficos de série e correlogramas. Cada teste é explicado e seus resultados são interpretados, oferecendo uma introdução e aplicação para análise de estacionariedade.

1 Testes de Estacionariedade em Séries Temporais

Uma série temporal é considerada estacionária quando suas propriedades estatísticas, como a média, variância e autocorrelação, permanecem constantes ao longo do tempo.

1.1 Definição Formal de Estacionariedade

Uma série temporal \({X_t}\) é considerada estritamente estacionária se a distribuição conjunta de \((X_{t_1}, X_{t_2}, \dots, X_{t_k})\) for a mesma que a de \((X_{t_1+h}, X_{t_2+h}, \dots, X_{t_k+h})\) para qualquer deslocamento \(h\) e qualquer conjunto de tempos \(t_1, t_2, \dots, t_k\). Em outras palavras, as propriedades estatísticas da série não dependem do tempo.

Na prática, utilizamos o conceito de estacionariedade fraca (ou estacionariedade de segunda ordem), que requer as seguintes condições:

1. Média constante: \(\mathbb{E}[X_t] = \mu\), para todo \(t\).

2. Variância constante e finita: \(\text{Var}(X_t) = \sigma^2\), para todo \(t\).

3. Autocovariância que depende apenas da defasagem (lag): \(\text{Cov}(X_t, X_{t+h}) = \gamma(h)\), onde \(\gamma(h)\) é uma função que depende apenas da defasagem \(h\), e não do tempo \(t\).

Essas condições garantem que as propriedades estatísticas da série, como a média, a variância e a covariância, não mudam ao longo do tempo.

Testes de estacionariedade são fundamentais para analisar a adequação de modelos temporais, como ARIMA.

Nesta aula, explora-se alguns dos principais testes de estacionariedade e como aplicá-los em R:

  • Testes ADF (Dickey-Fuller aumentado)
  • Testes KPSS
  • Testes PP (Phillips-Perron)
  • Teste com quebra estrutural: Zivot-Andrews

1.2 Visualização de Séries Temporais

Vamos primeiro visualizar as séries temporais que serão utilizadas nesta aula. Para isso, vamos usar a série AirPassengers, que é fornecida no R e a série de produção industrial do Brasil (com e sem ajuste sazonal)

# Carregar a série AirPassengers
data("AirPassengers")
plot(AirPassengers, main="Série AirPassengers", ylab="Passageiros", xlab="Ano")

# usando a série sazonalmente ajustada
library(seasonal)
passageiros_sa <- final(seas(AirPassengers))
# Visualizando a série temporal
plot(passageiros_sa, main="Passageiros Aéreos Sazonalmente Ajustada", ylab="Produção", xlab="Ano")

# Leitura dos dados da Produção Industrial
library(readxl)
dados <- read_excel("tabela8888.xlsx")
# Preparando a série temporal
pimpf <- ts(dados$pimpf, start=c(2002,1), frequency=12)
# Visualizando a série temporal
plot(pimpf, main="Produção Industrial Brasileira", ylab="Produção", xlab="Ano")

# usando a série sazonalmente ajustada
library(seasonal)
pimpf_sa <- final(seas(pimpf))
# Visualizando a série temporal
plot(pimpf_sa, main="Produção Industrial Brasileira Sazonalmente Ajustada", ylab="Produção", xlab="Ano")

Agora vamos examinar o Correlograma (ACF) que ajuda a identificar a estacionariedade observando os padrões de autocorrelação.

# Autocorrelação (ACF)
acf(AirPassengers, main="Correlograma - ACF")

acf(passageiros_sa, main="Correlograma - ACF")

acf(pimpf, main="Correlograma - ACF")

acf(pimpf_sa, main="Correlograma - ACF")

Observe os gráficos anteriores. Em séries não estacionárias, a função de autocorrelação tende a decair lentamente, indicando a presença de tendências ou sazonalidades. Na sequência é apresentado a função de autocorrelação para a primeira diferença.

# Autocorrelação (ACF)
acf(diff(AirPassengers), main="Correlograma - ACF")

acf(diff(passageiros_sa), main="Correlograma - ACF")

acf(diff(pimpf), main="Correlograma - ACF")

acf(diff(pimpf_sa), main="Correlograma - ACF")

1.3 Testes de Estacionariedade

Nesta seção, vamos introduzir os principais testes de estacionariedade e como interpretá-los.

1.3.1 Teste Dickey-Fuller Aumentado (ADF)

O Teste Dickey-Fuller Aumentado (ADF) é um dos testes mais comuns para verificar a estacionariedade de uma série temporal. A equação básica para o teste ADF é:

\(\Delta X_t = \alpha + \beta t + \gamma X_{t-1} + \sum_{i=1}^{p} \delta_i \Delta X_{t-i} + \epsilon_t\)

Onde: - \(\Delta X_t\) é a primeira diferença da série \(X_t\). - \(\alpha\) é uma constante (ou termo de drift). - \(\beta\) é o coeficiente do termo de tendência. - \(\gamma\) é o coeficiente que estamos interessados em testar. - \(\delta_i\) são os coeficientes das defasagens das primeiras diferenças para lidar com autocorrelação. - \(\epsilon_t\) é o erro branco.

O teste ADF verifica a presença de uma raiz unitária, ou seja, se a série é não estacionária.

  • Hipótese Nula (\(H_0\)): A série tem uma raiz unitária (não estacionária).\(H_0: \gamma = 0\)

  • Hipótese Alternativa (\(H_1\)): A série é estacionária.\(H_1: \gamma < 0\)

  • Se rejeitamos a hipótese nula \(H_0\), concluímos que a série é estacionária.

  • Se não rejeitamos \(H_0\), a série apresenta uma raiz unitária, ou seja, é não estacionária.

O teste ADF é uma extensão do teste Dickey-Fuller original, que inclui defasagens das diferenças para capturar possíveis autocorrelações na série residual e melhorar a robustez do teste.

# Instalar e carregar pacotes necessários
library(urca)

# Aplicar o teste ADF
adf_test_1a <- ur.df(passageiros_sa, type = "none")
adf_test_1b <- ur.df(passageiros_sa, type = "drift")
adf_test_1c <- ur.df(passageiros_sa, type = "trend")

summary(adf_test_1a)

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression none 


Call:
lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)

Residuals:
     Min       1Q   Median       3Q      Max 
-17.2858  -3.0838   0.3265   3.5808  18.1680 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
z.lag.1     0.010016   0.001708   5.865 3.08e-08 ***
z.diff.lag -0.172151   0.084423  -2.039   0.0433 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.475 on 140 degrees of freedom
Multiple R-squared:  0.1991,    Adjusted R-squared:  0.1877 
F-statistic:  17.4 on 2 and 140 DF,  p-value: 1.781e-07


Value of test-statistic is: 5.8655 

Critical values for test statistics: 
      1pct  5pct 10pct
tau1 -2.58 -1.95 -1.62
summary(adf_test_1b)

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression drift 


Call:
lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)

Residuals:
     Min       1Q   Median       3Q      Max 
-17.8816  -3.3550  -0.0715   3.6738  18.7181 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)  
(Intercept)  1.499921   1.261133   1.189    0.236  
z.lag.1      0.005396   0.004242   1.272    0.205  
z.diff.lag  -0.175820   0.084354  -2.084    0.039 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.467 on 139 degrees of freedom
Multiple R-squared:  0.03677,   Adjusted R-squared:  0.02291 
F-statistic: 2.653 on 2 and 139 DF,  p-value: 0.07401


Value of test-statistic is: 1.2722 17.9601 

Critical values for test statistics: 
      1pct  5pct 10pct
tau2 -3.46 -2.88 -2.57
phi1  6.52  4.63  3.81
summary(adf_test_1c)

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression trend 


Call:
lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)

Residuals:
     Min       1Q   Median       3Q      Max 
-16.7016  -3.5280   0.0256   3.1695  19.0653 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept)  9.02286    3.05782   2.951  0.00373 **
z.lag.1     -0.08378    0.03343  -2.507  0.01335 * 
tt           0.23896    0.08887   2.689  0.00805 **
z.diff.lag  -0.13901    0.08365  -1.662  0.09882 . 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.348 on 138 degrees of freedom
Multiple R-squared:  0.08472,   Adjusted R-squared:  0.06482 
F-statistic: 4.258 on 3 and 138 DF,  p-value: 0.006543


Value of test-statistic is: -2.5066 14.9199 4.4604 

Critical values for test statistics: 
      1pct  5pct 10pct
tau3 -3.99 -3.43 -3.13
phi2  6.22  4.75  4.07
phi3  8.43  6.49  5.47
adf_test_2a <- ur.df(pimpf_sa, type = "none")
adf_test_2b <- ur.df(pimpf_sa, type = "drift")
adf_test_2c <- ur.df(pimpf_sa, type = "trend")

summary(adf_test_2a)

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression none 


Call:
lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)

Residuals:
     Min       1Q   Median       3Q      Max 
-20.4050  -0.4450   0.1030   0.5846  10.9919 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)
z.lag.1    0.0001715  0.0012137   0.141    0.888
z.diff.lag 0.0310667  0.0613735   0.506    0.613

Residual standard error: 2.11 on 266 degrees of freedom
Multiple R-squared:  0.001053,  Adjusted R-squared:  -0.006458 
F-statistic: 0.1401 on 2 and 266 DF,  p-value: 0.8693


Value of test-statistic is: 0.1413 

Critical values for test statistics: 
      1pct  5pct 10pct
tau1 -2.58 -1.95 -1.62
summary(adf_test_2b)

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression drift 


Call:
lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)

Residuals:
     Min       1Q   Median       3Q      Max 
-20.6722  -0.4803   0.0800   0.5933  10.6867 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)  
(Intercept)  3.80375    1.57959   2.408   0.0167 *
z.lag.1     -0.03553    0.01487  -2.389   0.0176 *
z.diff.lag   0.04578    0.06113   0.749   0.4546  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.091 on 265 degrees of freedom
Multiple R-squared:  0.02201,   Adjusted R-squared:  0.01463 
F-statistic: 2.982 on 2 and 265 DF,  p-value: 0.05239


Value of test-statistic is: -2.3886 2.9095 

Critical values for test statistics: 
      1pct  5pct 10pct
tau2 -3.44 -2.87 -2.57
phi1  6.47  4.61  3.79
summary(adf_test_2c)

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression trend 


Call:
lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)

Residuals:
     Min       1Q   Median       3Q      Max 
-20.5434  -0.4582   0.0626   0.5826  10.7417 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)   
(Intercept)  4.235914   1.630949   2.597  0.00993 **
z.lag.1     -0.037352   0.014970  -2.495  0.01320 * 
tt          -0.001765   0.001664  -1.061  0.28988   
z.diff.lag   0.042923   0.061178   0.702  0.48355   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.09 on 264 degrees of freedom
Multiple R-squared:  0.02616,   Adjusted R-squared:  0.01509 
F-statistic: 2.364 on 3 and 264 DF,  p-value: 0.07154


Value of test-statistic is: -2.4952 2.3155 3.4165 

Critical values for test statistics: 
      1pct  5pct 10pct
tau3 -3.98 -3.42 -3.13
phi2  6.15  4.71  4.05
phi3  8.34  6.30  5.36

Qual foram as conclusões encontradas?

Vamos testar agora a estacionariedade da primeira diferença:

# Instalar e carregar pacotes necessários
library(urca)

# Aplicar o teste ADF
adf_test_diff_1a <- ur.df(diff(passageiros_sa), type = "none")
adf_test_diff_1b <- ur.df(diff(passageiros_sa), type = "drift")
adf_test_diff_1c <- ur.df(diff(passageiros_sa), type = "trend")

summary(adf_test_diff_1a)

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression none 


Call:
lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)

Residuals:
    Min      1Q  Median      3Q     Max 
-19.068  -1.323   1.944   5.421  24.290 

Coefficients:
           Estimate Std. Error t value Pr(>|t|)    
z.lag.1    -0.79216    0.11541  -6.864 2.04e-10 ***
z.diff.lag -0.16821    0.08362  -2.012   0.0462 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 6.045 on 139 degrees of freedom
Multiple R-squared:  0.4908,    Adjusted R-squared:  0.4834 
F-statistic: 66.98 on 2 and 139 DF,  p-value: < 2.2e-16


Value of test-statistic is: -6.8638 

Critical values for test statistics: 
      1pct  5pct 10pct
tau1 -2.58 -1.95 -1.62
summary(adf_test_diff_1b)

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression drift 


Call:
lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)

Residuals:
     Min       1Q   Median       3Q      Max 
-18.6473  -3.3138  -0.1185   3.4084  19.4456 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  3.10562    0.57392   5.411 2.69e-07 ***
z.lag.1     -1.20643    0.13011  -9.272 3.33e-16 ***
z.diff.lag   0.03944    0.08534   0.462    0.645    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.51 on 138 degrees of freedom
Multiple R-squared:  0.5799,    Adjusted R-squared:  0.5738 
F-statistic: 95.24 on 2 and 138 DF,  p-value: < 2.2e-16


Value of test-statistic is: -9.2723 42.9893 

Critical values for test statistics: 
      1pct  5pct 10pct
tau2 -3.46 -2.88 -2.57
phi1  6.52  4.63  3.81
summary(adf_test_diff_1c)

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression trend 


Call:
lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)

Residuals:
     Min       1Q   Median       3Q      Max 
-17.5737  -3.1138   0.0527   3.7282  17.9902 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.85789    0.95427   1.947   0.0536 .  
z.lag.1     -1.24870    0.13191  -9.467   <2e-16 ***
tt           0.01885    0.01156   1.631   0.1052    
z.diff.lag   0.06099    0.08585   0.710   0.4786    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.477 on 137 degrees of freedom
Multiple R-squared:  0.5879,    Adjusted R-squared:  0.5789 
F-statistic: 65.15 on 3 and 137 DF,  p-value: < 2.2e-16


Value of test-statistic is: -9.4666 29.8912 44.8353 

Critical values for test statistics: 
      1pct  5pct 10pct
tau3 -3.99 -3.43 -3.13
phi2  6.22  4.75  4.07
phi3  8.43  6.49  5.47
adf_test_diff_2a <- ur.df(diff(pimpf_sa), type = "none")
adf_test_diff_2b <- ur.df(diff(pimpf_sa), type = "drift")
adf_test_diff_2c <- ur.df(diff(pimpf_sa), type = "trend")

summary(adf_test_diff_2a)

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression none 


Call:
lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)

Residuals:
     Min       1Q   Median       3Q      Max 
-20.3731  -0.4334   0.1249   0.6326  11.0360 

Coefficients:
           Estimate Std. Error t value Pr(>|t|)    
z.lag.1    -1.03223    0.08538 -12.089   <2e-16 ***
z.diff.lag  0.06535    0.06137   1.065    0.288    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.109 on 265 degrees of freedom
Multiple R-squared:  0.4861,    Adjusted R-squared:  0.4823 
F-statistic: 125.4 on 2 and 265 DF,  p-value: < 2.2e-16


Value of test-statistic is: -12.0893 

Critical values for test statistics: 
      1pct  5pct 10pct
tau1 -2.58 -1.95 -1.62
summary(adf_test_diff_2b)

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression drift 


Call:
lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)

Residuals:
     Min       1Q   Median       3Q      Max 
-20.4172  -0.4769   0.0812   0.5893  10.9886 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  0.04356    0.12932   0.337    0.737    
z.lag.1     -1.03299    0.08556 -12.074   <2e-16 ***
z.diff.lag   0.06575    0.06148   1.070    0.286    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.112 on 264 degrees of freedom
Multiple R-squared:  0.4864,    Adjusted R-squared:  0.4825 
F-statistic:   125 on 2 and 264 DF,  p-value: < 2.2e-16


Value of test-statistic is: -12.0737 72.8874 

Critical values for test statistics: 
      1pct  5pct 10pct
tau2 -3.44 -2.87 -2.57
phi1  6.47  4.61  3.79
summary(adf_test_diff_2c)

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression trend 


Call:
lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)

Residuals:
     Min       1Q   Median       3Q      Max 
-20.3090  -0.4160   0.0847   0.5210  11.0427 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept)  0.226406   0.261722   0.865    0.388    
z.lag.1     -1.038220   0.085861 -12.092   <2e-16 ***
tt          -0.001353   0.001683  -0.804    0.422    
z.diff.lag   0.068364   0.061607   1.110    0.268    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.114 on 263 degrees of freedom
Multiple R-squared:  0.4876,    Adjusted R-squared:  0.4818 
F-statistic: 83.43 on 3 and 263 DF,  p-value: < 2.2e-16


Value of test-statistic is: -12.0918 48.7418 73.1125 

Critical values for test statistics: 
      1pct  5pct 10pct
tau3 -3.98 -3.42 -3.13
phi2  6.15  4.71  4.05
phi3  8.34  6.30  5.36

1.3.2 Teste KPSS

Diferente do ADF, o teste KPSS tem como hipótese nula que a série é estacionária. Isso complementa os resultados do ADF.

# Teste KPSS
library(urca)

kpss_test_1a <- ur.kpss(passageiros_sa,type="mu")
kpss_test_1b <- ur.kpss(passageiros_sa,type="tau")

summary(kpss_test_1a)

####################### 
# KPSS Unit Root Test # 
####################### 

Test is of type: mu with 4 lags. 

Value of test-statistic is: 2.9471 

Critical value for a significance level of: 
                10pct  5pct 2.5pct  1pct
critical values 0.347 0.463  0.574 0.739
summary(kpss_test_1b)

####################### 
# KPSS Unit Root Test # 
####################### 

Test is of type: tau with 4 lags. 

Value of test-statistic is: 0.4692 

Critical value for a significance level of: 
                10pct  5pct 2.5pct  1pct
critical values 0.119 0.146  0.176 0.216
kpss_test_2a <- ur.kpss(pimpf_sa,type="mu")
kpss_test_2b <- ur.kpss(pimpf_sa,type="tau")

summary(kpss_test_2a)

####################### 
# KPSS Unit Root Test # 
####################### 

Test is of type: mu with 5 lags. 

Value of test-statistic is: 0.9226 

Critical value for a significance level of: 
                10pct  5pct 2.5pct  1pct
critical values 0.347 0.463  0.574 0.739
summary(kpss_test_2b)

####################### 
# KPSS Unit Root Test # 
####################### 

Test is of type: tau with 5 lags. 

Value of test-statistic is: 0.8245 

Critical value for a significance level of: 
                10pct  5pct 2.5pct  1pct
critical values 0.119 0.146  0.176 0.216

No teste KPSS, se o valor-p for menor que 0,05, rejeitamos a hipótese nula de estacionariedade. Assim, uma série não estacionária será identificada com valores baixos de p.

1.3.3 Teste Phillips-Perron (PP)

O teste PP é uma variação do teste Dickey-Fuller e corrige para heterocedasticidade na série. Ele é útil em séries com variância não constante.

# Teste Phillips-Perron
pp_test_1a <- ur.pp(passageiros_sa, model = "constant")
pp_test_1b <- ur.pp(passageiros_sa, model = "trend")
summary(pp_test_1a)

################################## 
# Phillips-Perron Unit Root Test # 
################################## 

Test regression with intercept 


Call:
lm(formula = y ~ y.l1)

Residuals:
    Min      1Q  Median      3Q     Max 
-20.529  -3.194  -0.116   3.714  20.291 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 1.408422   1.257980    1.12    0.265    
y.l1        1.004102   0.004201  238.99   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.512 on 141 degrees of freedom
Multiple R-squared:  0.9975,    Adjusted R-squared:  0.9975 
F-statistic: 5.712e+04 on 1 and 141 DF,  p-value: < 2.2e-16


Value of test-statistic, type: Z-alpha  is: 0.665 

         aux. Z statistics
Z-tau-mu            1.3381
summary(pp_test_1b)

################################## 
# Phillips-Perron Unit Root Test # 
################################## 

Test regression with intercept and trend 


Call:
lm(formula = y ~ y.l1 + trend)

Residuals:
     Min       1Q   Median       3Q      Max 
-18.7575  -3.2299   0.2098   3.2261  20.3375 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 27.41522    8.99673   3.047  0.00276 ** 
y.l1         0.91030    0.03241  28.090  < 2e-16 ***
trend        0.25130    0.08612   2.918  0.00411 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.371 on 140 degrees of freedom
Multiple R-squared:  0.9977,    Adjusted R-squared:  0.9976 
F-statistic: 3.008e+04 on 2 and 140 DF,  p-value: < 2.2e-16


Value of test-statistic, type: Z-alpha  is: -9.5524 

           aux. Z statistics
Z-tau-mu              4.4969
Z-tau-beta            2.6323
pp_test_2a <- ur.pp(pimpf_sa, model = "constant")
pp_test_2b <- ur.pp(pimpf_sa, model = "trend")
summary(pp_test_2a)

################################## 
# Phillips-Perron Unit Root Test # 
################################## 

Test regression with intercept 


Call:
lm(formula = y ~ y.l1)

Residuals:
     Min       1Q   Median       3Q      Max 
-20.7417  -0.4638   0.0917   0.5916  10.2023 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  3.68430    1.55865   2.364   0.0188 *  
y.l1         0.96562    0.01468  65.772   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.085 on 267 degrees of freedom
Multiple R-squared:  0.9419,    Adjusted R-squared:  0.9416 
F-statistic:  4326 on 1 and 267 DF,  p-value: < 2.2e-16


Value of test-statistic, type: Z-alpha  is: -8.5195 

         aux. Z statistics
Z-tau-mu            2.2893
summary(pp_test_2b)

################################## 
# Phillips-Perron Unit Root Test # 
################################## 

Test regression with intercept and trend 


Call:
lm(formula = y ~ y.l1 + trend)

Residuals:
     Min       1Q   Median       3Q      Max 
-20.6043  -0.4249   0.0752   0.5878  10.2920 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept)  3.868141   1.567270   2.468   0.0142 *  
y.l1         0.963887   0.014762  65.294   <2e-16 ***
trend       -0.001790   0.001646  -1.087   0.2780    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.084 on 266 degrees of freedom
Multiple R-squared:  0.9421,    Adjusted R-squared:  0.9417 
F-statistic:  2165 on 2 and 266 DF,  p-value: < 2.2e-16


Value of test-statistic, type: Z-alpha  is: -8.8466 

           aux. Z statistics
Z-tau-mu              2.8467
Z-tau-beta           -1.1426

1.4 Testes de Estacionariedade com Quebra Estrutural (Zivot-Andrews)

Quando há mudanças estruturais em uma série, como crises econômicas ou mudanças de regime, os testes tradicionais de estacionariedade podem não ser adequados. O teste de Zivot-Andrews lida com essas quebras estruturais.

O teste de Zivot-Andrews permite uma quebra estrutural no processo da série temporal, o que pode melhorar a identificação de estacionariedade em séries com eventos marcantes.

O Teste Zivot-Andrews testa a hipótese nula de que a série tem uma raiz unitária com uma possível quebra estrutural em algum ponto do tempo. Ele é útil quando há eventos que podem causar mudanças abruptas no comportamento da série (como crises econômicas, mudanças políticas, etc.).

Hipóteses: Hipótese Nula (\(H_0\)): A série tem uma raiz unitária com uma quebra estrutural. Hipótese Alternativa (\(H_1\)): A série é estacionária com uma quebra estrutural.

# Teste de Zivot-Andrews

za_test_1a <- ur.za(passageiros_sa, model = "intercept")
za_test_1b <- ur.za(passageiros_sa, model = "trend")
za_test_1c <- ur.za(passageiros_sa, model = "both")
summary(za_test_1a) 

################################ 
# Zivot-Andrews Unit Root Test # 
################################ 


Call:
lm(formula = testmat)

Residuals:
     Min       1Q   Median       3Q      Max 
-19.1081  -2.7904   0.4833   2.8499  19.1576 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 13.34275    3.21420   4.151 5.74e-05 ***
y.l1         0.85844    0.03649  23.526  < 2e-16 ***
trend        0.43985    0.10699   4.111 6.70e-05 ***
du          -5.38306    1.89114  -2.846  0.00509 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.239 on 139 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:  0.9978,    Adjusted R-squared:  0.9978 
F-statistic: 2.108e+04 on 3 and 139 DF,  p-value: < 2.2e-16


Teststatistic: -3.8796 
Critical values: 0.01= -5.34 0.05= -4.8 0.1= -4.58 

Potential break point at position: 52 
summary(za_test_1b) 

################################ 
# Zivot-Andrews Unit Root Test # 
################################ 


Call:
lm(formula = testmat)

Residuals:
     Min       1Q   Median       3Q      Max 
-17.3688  -2.8397   0.2805   2.9601  18.4119 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 23.04645    5.53154   4.166 5.41e-05 ***
y.l1         0.79936    0.04934  16.201  < 2e-16 ***
trend        0.41739    0.10129   4.121 6.46e-05 ***
dt           0.20232    0.06916   2.926  0.00402 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.231 on 139 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:  0.9978,    Adjusted R-squared:  0.9978 
F-statistic: 2.114e+04 on 3 and 139 DF,  p-value: < 2.2e-16


Teststatistic: -4.0665 
Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11 

Potential break point at position: 61 
summary(za_test_1c) 

################################ 
# Zivot-Andrews Unit Root Test # 
################################ 


Call:
lm(formula = testmat)

Residuals:
     Min       1Q   Median       3Q      Max 
-17.8053  -2.8958   0.5532   2.8325  18.0546 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 23.23639    5.32722   4.362 2.51e-05 ***
y.l1         0.78590    0.04835  16.255  < 2e-16 ***
trend        0.50736    0.11297   4.491 1.48e-05 ***
du          -4.57457    1.91270  -2.392   0.0181 *  
dt           0.16514    0.06886   2.398   0.0178 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.184 on 138 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:  0.9979,    Adjusted R-squared:  0.9978 
F-statistic: 1.615e+04 on 4 and 138 DF,  p-value: < 2.2e-16


Teststatistic: -4.4281 
Critical values: 0.01= -5.57 0.05= -5.08 0.1= -4.82 

Potential break point at position: 53 
za_test_2a <- ur.za(pimpf_sa, model = "intercept")
za_test_2b <- ur.za(pimpf_sa, model = "trend")
za_test_2c <- ur.za(pimpf_sa, model = "both")
summary(za_test_2a) 

################################ 
# Zivot-Andrews Unit Root Test # 
################################ 


Call:
lm(formula = testmat)

Residuals:
     Min       1Q   Median       3Q      Max 
-20.6559  -0.4236   0.0713   0.5759  10.2646 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept)  8.488694   2.111782   4.020  7.6e-05 ***
y.l1         0.916657   0.020955  43.743  < 2e-16 ***
trend        0.009718   0.004021   2.417  0.01633 *  
du          -2.211884   0.707404  -3.127  0.00196 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.051 on 265 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:  0.9442,    Adjusted R-squared:  0.9436 
F-statistic:  1494 on 3 and 265 DF,  p-value: < 2.2e-16


Teststatistic: -3.9772 
Critical values: 0.01= -5.34 0.05= -4.8 0.1= -4.58 

Potential break point at position: 155 
summary(za_test_2b) 

################################ 
# Zivot-Andrews Unit Root Test # 
################################ 


Call:
lm(formula = testmat)

Residuals:
     Min       1Q   Median       3Q      Max 
-20.7282  -0.3928   0.0851   0.5972   9.7563 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  7.89629    2.13825   3.693 0.000269 ***
y.l1         0.91257    0.02428  37.593  < 2e-16 ***
trend        0.03515    0.01406   2.501 0.013006 *  
dt          -0.04435    0.01676  -2.646 0.008641 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.061 on 265 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:  0.9436,    Adjusted R-squared:  0.943 
F-statistic:  1478 on 3 and 265 DF,  p-value: < 2.2e-16


Teststatistic: -3.6014 
Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11 

Potential break point at position: 68 
summary(za_test_2c) 

################################ 
# Zivot-Andrews Unit Root Test # 
################################ 


Call:
lm(formula = testmat)

Residuals:
     Min       1Q   Median       3Q      Max 
-20.7446  -0.4404   0.0682   0.6156   9.7599 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) 11.159091   2.624501   4.252 2.94e-05 ***
y.l1         0.884506   0.027812  31.803  < 2e-16 ***
trend        0.021625   0.007035   3.074 0.002334 ** 
du          -2.494599   0.679851  -3.669 0.000294 ***
dt          -0.023726   0.010282  -2.307 0.021806 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.039 on 264 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:  0.945, Adjusted R-squared:  0.9442 
F-statistic:  1135 on 4 and 264 DF,  p-value: < 2.2e-16


Teststatistic: -4.1526 
Critical values: 0.01= -5.57 0.05= -5.08 0.1= -4.82 

Potential break point at position: 146 

O teste Zivot-Andrews considera uma quebra estrutural na série. Se o valor-p for menor que 0,05, rejeitamos a hipótese nula de raiz unitária com quebra, indicando que a série é estacionária, possivelmente com uma quebra.

1.5 Considerações finais

Nesta aula, aprendemos sobre os principais testes de estacionariedade aplicados em séries temporais. Vimos que:

- O teste ADF busca raízes unitárias diretamente.

- O teste KPSS avalia a estacionariedade diretamente, com uma hipótese nula oposta ao ADF.

- O teste PP é uma versão robusta do ADF em relação à heterocedasticidade.

- O teste Zivot-Andrews é utilizado quando há suspeitas de quebra estrutural.

Cada teste tem suas peculiaridades, e é importante avaliar os diferentes resultados para fazer um diagnóstico robusto da série temporal.