Carga de Dados

## [1] 21  2
## 
## Call:
## lm(formula = y ~ x)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -28.432 -13.759  -6.723  12.350  37.423 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 9136.5498  1336.7907   6.835 1.60e-06 ***
## x             -4.4818     0.6651  -6.739 1.94e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 18.45 on 19 degrees of freedom
## Multiple R-squared:  0.705,  Adjusted R-squared:  0.6895 
## F-statistic: 45.41 on 1 and 19 DF,  p-value: 1.938e-06
## 
## Call:
## lm(formula = y ~ x)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -28.432 -13.759  -6.723  12.350  37.423 
## 
## Coefficients:
##              Estimate Std. Error t value   Pr(>|t|)    
## (Intercept) 9136.5498  1336.7907   6.835 0.00000160 ***
## x             -4.4818     0.6651  -6.739 0.00000194 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 18.45 on 19 degrees of freedom
## Multiple R-squared:  0.705,  Adjusted R-squared:  0.6895 
## F-statistic: 45.41 on 1 and 19 DF,  p-value: 0.000001938
##         1         2         3         4         5         6         7         8 
## 172.91342 168.43160 163.94978 159.46797 154.98615 150.50433 146.02251 141.54069 
##         9        10        11        12        13        14        15        16 
## 137.05887 132.57706 128.09524 123.61342 119.13160 114.64978 110.16797 105.68615 
##        17        18        19        20        21 
## 101.20433  96.72251  92.24069  87.75887  83.27706
##        1        2        3        4        5        6        7        8 
## 78.79524 74.31342 69.83160 65.34978 60.86797 56.38615 51.90433 47.42251 
##        9       10 
## 42.94069 38.45887
##  [1] 78 74 69 65 60 56 51 47 42 38
##         fit        lwr       upr
## 1  78.79524 36.3981942 121.19228
## 2  74.31342 31.3940108 117.23283
## 3  69.83160 26.3515217 113.31168
## 4  65.34978 21.2721886 109.42738
## 5  60.86797 16.1574886 105.57844
## 6  56.38615 11.0089016 101.76339
## 7  51.90433  5.8278986  97.98076
## 8  47.42251  0.6159323  94.22909
## 9  42.94069 -4.6255714  90.50696
## 10 38.45887 -9.8952205  86.81297
##         fit       lwr      upr
## 1  78.79524 61.316521 96.27395
## 2  74.31342 55.603212 93.02363
## 3  69.83160 49.868797 89.79441
## 4  65.34978 44.117012 86.58256
## 5  60.86797 38.350796 83.38514
## 6  56.38615 32.572483 80.19981
## 7  51.90433 26.783946 77.02471
## 8  47.42251 20.986702 73.85832
## 9  42.94069 15.181988 70.69940
## 10 38.45887  9.370824 67.54693
## Warning: package 'ggplot2' was built under R version 3.6.3
## `geom_smooth()` using formula 'y ~ x'

## `geom_smooth()` using formula 'y ~ x'

Verificando a serie com 10 anos futuros

## `geom_smooth()` using formula 'y ~ x'

## `geom_smooth()` using formula 'y ~ x'

Plotando dados

Fatais de 2000 a 2020

Predição

Predict para 10 anos:

## Warning: package 'forecast' was built under R version 3.6.3
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
##    Point Forecast      Lo 80      Hi 80      Lo 95     Hi 95
## 22      50.594582  42.418782  58.770381  38.090775 63.098388
## 23      40.835005  33.282482  48.387528  29.284418 52.385592
## 24      31.075428  23.486780  38.664077  19.469592 42.681265
## 25      21.315852  13.020582  29.611121   8.629332 34.002372
## 26      11.556275   2.025165  21.087385  -3.020300 26.132850
## 27       1.796699  -9.330831  12.924228 -15.221389 18.814786
## 28      -7.962878 -20.928870   5.003113 -27.792651 11.866895
## 29     -17.722455 -32.706697  -2.738212 -40.638876  5.193967
## 30     -27.482031 -44.643061 -10.321002 -53.727561 -1.236501
## 31     -37.241608 -56.744064 -17.739152 -67.068040 -7.415176

Auto Arima

## Series: ts(FATAIS, frequency = 1, start = c(2000)) 
## ARIMA(0,1,1) with drift 
## 
## Coefficients:
##           ma1    drift
##       -0.4691  -4.5780
## s.e.   0.1751   2.0038
## 
## sigma^2 estimated as 288:  log likelihood=-84.08
## AIC=174.16   AICc=175.66   BIC=177.15

Projeção h=10

Impressão de gráfico com série temporal e projeção com intervalos de confiança de 80 e 95%

Incluir no gráfico os valores do modelo para dados observados em azul

Verificando os dados

## [1] "forecast"
##      Point Forecast       Lo 80    Hi 80      Lo 95    Hi 95
## 2021       62.47874  40.7289693 84.22851  29.215336 95.74215
## 2022       57.90071  33.2763053 82.52511  20.240935 95.56048
## 2023       53.32267  26.1258025 80.51954  11.728650 94.91669
## 2024       48.74463  19.1984313 78.29084   3.557616 93.93165
## 2025       44.16660  12.4445776 75.88862  -4.348046 92.68124
## 2026       39.58856   5.8306732 73.34645 -12.039675 91.21680
## 2027       35.01053  -0.6672476 70.68830 -19.553921 89.57498
## 2028       30.43249  -7.0670034 67.93199 -26.918038 87.78302
## 2029       25.85446 -13.3822695 65.09118 -34.152938 85.86185
## 2030       21.27642 -19.6238135 62.17666 -41.275090 83.82793

Verificando os dados residuais

## Warning: package 'pander' was built under R version 3.6.3

R version 3.6.2 (2019-12-12)

Platform: x86_64-w64-mingw32/x64 (64-bit)

locale: LC_COLLATE=Portuguese_Brazil.1252, LC_CTYPE=Portuguese_Brazil.1252, LC_MONETARY=Portuguese_Brazil.1252, LC_NUMERIC=C and LC_TIME=Portuguese_Brazil.1252

attached base packages:

  • stats
  • graphics
  • grDevices
  • utils
  • datasets
  • methods
  • base

other attached packages:

  • pander(v.0.6.3)
  • forecast(v.8.12)
  • ggplot2(v.3.3.2)

loaded via a namespace (and not attached):

  • Rcpp(v.1.0.4.6)
  • urca(v.1.3-0)
  • pillar(v.1.4.3)
  • compiler(v.3.6.2)
  • xts(v.0.12.1)
  • tseries(v.0.10-47)
  • tools(v.3.6.2)
  • digest(v.0.6.27)
  • jsonlite(v.1.6.1)
  • evaluate(v.0.14)
  • lifecycle(v.0.2.0)
  • tibble(v.3.0.4)
  • gtable(v.0.3.0)
  • nlme(v.3.1-142)
  • lattice(v.0.20-38)
  • mgcv(v.1.8-31)
  • pkgconfig(v.2.0.3)
  • rlang(v.0.4.10)
  • Matrix(v.1.2-18)
  • curl(v.4.3)
  • parallel(v.3.6.2)
  • yaml(v.2.2.0)
  • xfun(v.0.19)
  • withr(v.2.3.0)
  • stringr(v.1.4.0)
  • dplyr(v.0.8.5)
  • knitr(v.1.30)
  • vctrs(v.0.3.6)
  • nnet(v.7.3-12)
  • lmtest(v.0.9-37)
  • grid(v.3.6.2)
  • tidyselect(v.0.2.5)
  • glue(v.1.4.2)
  • R6(v.2.4.1)
  • rmarkdown(v.2.2.2)
  • TTR(v.0.23-6)
  • farver(v.2.0.1)
  • purrr(v.0.3.3)
  • magrittr(v.1.5)
  • scales(v.1.1.1)
  • ellipsis(v.0.3.0)
  • htmltools(v.0.4.0)
  • splines(v.3.6.2)
  • quantmod(v.0.4.17)
  • assertthat(v.0.2.1)
  • timeDate(v.3043.102)
  • colorspace(v.1.4-1)
  • fracdiff(v.1.5-1)
  • quadprog(v.1.5-8)
  • labeling(v.0.3)
  • stringi(v.1.4.4)
  • munsell(v.0.5.0)
  • crayon(v.1.3.4)
  • zoo(v.1.8-6)