Sacrificio mensual de ganado vacuno en Colombia, 2013-2021. Fuente DANE
sacrificio<-c(347461,315716,311618,354910,364939,341679,349918,344071,335659,361205,347599,359745,354888,314295,326528,309083,347737,317963,349251,331098,326818,339998,315589,349263,332991,300608,321570,308444,330537,325857,352289,338805,342363,352714,325462,355041,328622,306620,301043,316902,311450,300562,277933,303123,291356,294254,290419,310458,287860,267527,291917,252593,297169,292339,278611,282363,282983,284876,286731,302544,290646,269768,275528,276703,297216,290496,291147,293102,279752,284412,277632,308304,289841,263713,275868,257043,298153,273353,296628,292923,278292,296346,283783,301807,290251,274555,265945,208972,243155,251607,273967,267051,281053,300092,282588,317797,283933,273494,293286,256678,221587,271400,280583,279373,284835,279203,281111,296600)
x=ts(sacrificio,frequency=12,start=c(2013,01))
plot.ts(x)
suave<-SMA(x,n=12);suave
## Jan Feb Mar Apr May Jun Jul Aug
## 2013 NA NA NA NA NA NA NA NA
## 2014 345162.2 345043.8 346286.3 342467.4 341033.9 339057.6 339002.0 337920.9
## 2015 330051.2 328910.6 328497.4 328444.2 327010.8 327668.7 327921.8 328564.1
## 2016 331859.3 332360.3 330649.8 331354.6 329764.0 327656.1 321459.8 318486.2
## 2017 299331.7 296073.9 295313.4 289954.3 288764.2 288079.0 288135.5 286405.5
## 2018 284191.6 284378.3 283012.6 285021.8 285025.7 284872.1 285916.8 286811.7
## 2019 286158.4 285653.8 285682.2 284043.8 284121.9 282693.3 283150.1 283135.2
## 2020 284013.3 284916.8 284089.9 280084.0 275500.8 273688.7 271800.2 269644.2
## 2021 270892.9 270804.5 273082.9 277058.4 275261.1 276910.5 277461.8 278488.7
## Sep Oct Nov Dec
## 2013 NA NA NA 344543.3
## 2014 337184.2 335416.9 332749.4 331875.9
## 2015 329859.5 330919.2 331741.9 332223.4
## 2016 314235.7 309364.0 306443.8 302728.5
## 2017 285707.8 284926.2 284618.9 283959.4
## 2018 286542.4 286503.8 285745.5 286225.5
## 2019 283013.5 284008.0 284520.6 283979.2
## 2020 269874.3 270186.5 270086.9 271419.4
## 2021 278803.8 277063.1 276940.0 275173.6
plot(suave,lwd=2)
lines(suave,col="red",lwd=2)
suave2<-EMA(x,n=12);suave2
## Jan Feb Mar Apr May Jun Jul Aug
## 2013 NA NA NA NA NA NA NA NA
## 2014 346134.8 341236.4 338973.6 334375.0 336430.7 333589.5 335999.0 335245.0
## 2015 334336.3 329147.4 327981.6 324975.8 325831.4 325835.3 329905.1 331274.3
## 2016 336192.7 331643.1 326935.4 325391.8 323246.9 319756.9 313322.5 311753.3
## 2017 302319.2 296966.5 296189.7 289482.5 290665.0 290922.6 289028.5 288003.0
## 2018 289475.1 286443.2 284764.0 283523.8 285630.3 286378.9 287112.4 288033.9
## 2019 288814.1 284952.4 283554.8 279476.1 282349.4 280965.4 283375.0 284843.9
## 2020 288322.5 286204.4 283087.6 271685.2 267295.9 264882.2 266279.9 266398.5
## 2021 281866.4 280578.4 282533.4 278555.6 269791.2 270038.7 271660.9 272847.4
## Sep Oct Nov Dec
## 2013 NA NA NA 344543.3
## 2014 333948.5 334879.2 331911.5 334580.9
## 2015 332980.3 336016.2 334392.5 337569.2
## 2016 308615.3 306405.8 303946.3 304948.1
## 2017 287230.7 286868.4 286847.3 289262.2
## 2018 286759.8 286398.6 285049.9 288627.4
## 2019 283835.9 285760.6 285456.3 287971.8
## 2020 268653.1 273489.8 274889.5 281490.7
## 2021 274691.6 275385.7 276266.5 279394.7
plot(suave2)
lines(suave2)
autoplot(stl(x, s.window = "periodic"), ts.colour = "blue")
autoplot(acf(x, plot =FALSE))
acf(x)
acf2<-acf(x,plot=FALSE)
acf2
##
## Autocorrelations of series 'x', by lag
##
## 0.0000 0.0833 0.1667 0.2500 0.3333 0.4167 0.5000 0.5833 0.6667 0.7500 0.8333
## 1.000 0.755 0.724 0.672 0.592 0.598 0.531 0.549 0.461 0.487 0.475
## 0.9167 1.0000 1.0833 1.1667 1.2500 1.3333 1.4167 1.5000 1.5833 1.6667
## 0.480 0.588 0.491 0.474 0.396 0.342 0.372 0.310 0.331 0.268
pacf(x)
pacf2<-pacf(x,plot=FALSE)
pacf2
##
## Partial autocorrelations of series 'x', by lag
##
## 0.0833 0.1667 0.2500 0.3333 0.4167 0.5000 0.5833 0.6667 0.7500 0.8333 0.9167
## 0.755 0.360 0.134 -0.040 0.142 -0.028 0.134 -0.146 0.150 0.042 0.131
## 1.0000 1.0833 1.1667 1.2500 1.3333 1.4167 1.5000 1.5833 1.6667
## 0.295 -0.169 -0.158 -0.182 -0.090 0.164 -0.011 0.029 -0.017
spectrum(x)
spectrum(x,spans=c(2,2))
desc<-decompose(x,type = "multiplicative")
desc
## $x
## Jan Feb Mar Apr May Jun Jul Aug Sep Oct
## 2013 347461 315716 311618 354910 364939 341679 349918 344071 335659 361205
## 2014 354888 314295 326528 309083 347737 317963 349251 331098 326818 339998
## 2015 332991 300608 321570 308444 330537 325857 352289 338805 342363 352714
## 2016 328622 306620 301043 316902 311450 300562 277933 303123 291356 294254
## 2017 287860 267527 291917 252593 297169 292339 278611 282363 282983 284876
## 2018 290646 269768 275528 276703 297216 290496 291147 293102 279752 284412
## 2019 289841 263713 275868 257043 298153 273353 296628 292923 278292 296346
## 2020 290251 274555 265945 208972 243155 251607 273967 267051 281053 300092
## 2021 283933 273494 293286 256678 221587 271400 280583 279373 284835 279203
## Nov Dec
## 2013 347599 359745
## 2014 315589 349263
## 2015 325462 355041
## 2016 290419 310458
## 2017 286731 302544
## 2018 277632 308304
## 2019 283783 301807
## 2020 282588 317797
## 2021 281111 296600
##
## $seasonal
## Jan Feb Mar Apr May Jun Jul
## 2013 1.0270038 0.9518760 0.9875256 0.9166669 0.9863949 0.9816528 1.0146687
## 2014 1.0270038 0.9518760 0.9875256 0.9166669 0.9863949 0.9816528 1.0146687
## 2015 1.0270038 0.9518760 0.9875256 0.9166669 0.9863949 0.9816528 1.0146687
## 2016 1.0270038 0.9518760 0.9875256 0.9166669 0.9863949 0.9816528 1.0146687
## 2017 1.0270038 0.9518760 0.9875256 0.9166669 0.9863949 0.9816528 1.0146687
## 2018 1.0270038 0.9518760 0.9875256 0.9166669 0.9863949 0.9816528 1.0146687
## 2019 1.0270038 0.9518760 0.9875256 0.9166669 0.9863949 0.9816528 1.0146687
## 2020 1.0270038 0.9518760 0.9875256 0.9166669 0.9863949 0.9816528 1.0146687
## 2021 1.0270038 0.9518760 0.9875256 0.9166669 0.9863949 0.9816528 1.0146687
## Aug Sep Oct Nov Dec
## 2013 1.0105742 0.9977380 1.0385644 1.0008167 1.0865180
## 2014 1.0105742 0.9977380 1.0385644 1.0008167 1.0865180
## 2015 1.0105742 0.9977380 1.0385644 1.0008167 1.0865180
## 2016 1.0105742 0.9977380 1.0385644 1.0008167 1.0865180
## 2017 1.0105742 0.9977380 1.0385644 1.0008167 1.0865180
## 2018 1.0105742 0.9977380 1.0385644 1.0008167 1.0865180
## 2019 1.0105742 0.9977380 1.0385644 1.0008167 1.0865180
## 2020 1.0105742 0.9977380 1.0385644 1.0008167 1.0865180
## 2021 1.0105742 0.9977380 1.0385644 1.0008167 1.0865180
##
## $trend
## Jan Feb Mar Apr May Jun Jul Aug
## 2013 NA NA NA NA NA NA 344852.8 345103.0
## 2014 339029.8 338461.5 337552.5 336300.5 334083.2 332312.7 330963.5 329480.9
## 2015 327795.2 328243.0 329211.8 330389.3 331330.5 331982.7 332041.4 332109.8
## 2016 324557.9 319973.0 316361.0 311799.8 307903.9 304586.1 301030.1 297702.8
## 2017 288107.2 287270.5 286056.6 285317.0 284772.6 284289.2 284075.5 284285.0
## 2018 285394.4 286364.2 286677.0 286523.1 286124.6 285985.5 286192.0 285906.1
## 2019 282921.7 283142.6 283074.3 283510.8 284264.3 284249.9 283996.2 284465.1
## 2020 272744.5 270722.2 269759.3 270030.4 270136.7 270753.2 271156.2 270848.7
## 2021 277186.2 277975.2 278646.2 277933.5 277001.5 276056.8 NA NA
## Sep Oct Nov Dec
## 2013 345665.1 344376.9 341750.7 340045.7
## 2014 328704.0 328470.8 327727.5 327339.7
## 2015 331505.0 331002.2 330559.3 328710.0
## 2016 295693.7 292633.9 289359.3 288421.6
## 2017 283695.5 284017.2 285023.7 284948.9
## 2018 285668.0 284863.0 284082.9 283407.6
## 2019 284503.4 282087.0 277792.4 274594.7
## 2020 271943.7 275070.7 276159.7 276085.8
## 2021 NA NA NA NA
##
## $random
## Jan Feb Mar Apr May Jun Jul
## 2013 NA NA NA NA NA NA 1.0000190
## 2014 1.0192516 0.9755463 0.9795592 1.0026192 1.0552261 0.9747018 1.0399997
## 2015 0.9891400 0.9621100 0.9891264 1.0184478 1.0113647 0.9998934 1.0456410
## 2016 0.9858989 1.0067155 0.9636011 1.1087600 1.0254686 1.0052314 0.9099257
## 2017 0.9728706 0.9783544 1.0333776 0.9657887 1.0579241 1.0475349 0.9665853
## 2018 0.9916235 0.9896721 0.9732502 1.0535198 1.0530916 1.0347566 1.0026067
## 2019 0.9975197 0.9784664 0.9868531 0.9890647 1.0633251 0.9796380 1.0293789
## 2020 1.0362051 1.0654303 0.9983138 0.8442360 0.9125335 0.9466539 0.9957596
## 2021 0.9974066 1.0336209 1.0658345 1.0074796 0.8109821 1.0015058 NA
## Aug Sep Oct Nov Dec
## 2013 0.9865772 0.9732541 1.0099186 1.0162829 0.9736895
## 2014 0.9943932 0.9965164 0.9966581 0.9621758 0.9820122
## 2015 1.0094850 1.0350949 1.0260262 0.9837764 0.9940966
## 2016 1.0075527 0.9875644 0.9681984 1.0028433 0.9906907
## 2017 0.9828465 0.9997501 0.9657792 1.0051691 0.9772027
## 2018 1.0144417 0.9815108 0.9613432 0.9764948 1.0012227
## 2019 1.0189580 0.9803853 1.0115390 1.0207314 1.0115798
## 2020 0.9756616 1.0358400 1.0504532 1.0224423 1.0594216
## 2021 NA NA NA NA NA
##
## $figure
## [1] 1.0270038 0.9518760 0.9875256 0.9166669 0.9863949 0.9816528 1.0146687
## [8] 1.0105742 0.9977380 1.0385644 1.0008167 1.0865180
##
## $type
## [1] "multiplicative"
##
## attr(,"class")
## [1] "decomposed.ts"
plot(desc)
Tende<-decompose(x)$trend
plot(Tende)
dif1 <- diff(x, differences=1,lag=12);dif1
## Jan Feb Mar Apr May Jun Jul Aug Sep Oct
## 2014 7427 -1421 14910 -45827 -17202 -23716 -667 -12973 -8841 -21207
## 2015 -21897 -13687 -4958 -639 -17200 7894 3038 7707 15545 12716
## 2016 -4369 6012 -20527 8458 -19087 -25295 -74356 -35682 -51007 -58460
## 2017 -40762 -39093 -9126 -64309 -14281 -8223 678 -20760 -8373 -9378
## 2018 2786 2241 -16389 24110 47 -1843 12536 10739 -3231 -464
## 2019 -805 -6055 340 -19660 937 -17143 5481 -179 -1460 11934
## 2020 410 10842 -9923 -48071 -54998 -21746 -22661 -25872 2761 3746
## 2021 -6318 -1061 27341 47706 -21568 19793 6616 12322 3782 -20889
## Nov Dec
## 2014 -32010 -10482
## 2015 9873 5778
## 2016 -35043 -44583
## 2017 -3688 -7914
## 2018 -9099 5760
## 2019 6151 -6497
## 2020 -1195 15990
## 2021 -1477 -21197
plot.ts(dif1)
dif2<- diff(x, differences=2);dif2
## Jan Feb Mar Apr May Jun Jul Aug Sep Oct
## 2013 27647 47390 -33263 -33289 31499 -14086 -2565 33958
## 2014 -17003 -35736 52826 -29678 56099 -68428 61062 -49441 13873 17460
## 2015 -49946 -16111 53345 -34088 35219 -26773 31112 -39916 17042 6793
## 2016 -55998 4417 16425 21436 -21311 -5436 -11741 47819 -36957 14665
## 2017 -42637 2265 44723 -63714 83900 -49406 -8898 17480 -3132 1273
## 2018 -27711 -8980 26638 -4585 19338 -27233 7371 1304 -15305 18010
## 2019 -49135 -7665 38283 -30980 59935 -65910 48075 -26980 -10926 32685
## 2020 -29580 -4140 7086 -48363 91156 -25731 13908 -29276 20918 5037
## 2021 -69073 23425 30231 -56400 1517 84904 -40630 -10393 6672 -11094
## Nov Dec
## 2013 -39152 25752
## 2014 -37589 58083
## 2015 -37603 56831
## 2016 -6733 23874
## 2017 -38 13958
## 2018 -11440 37452
## 2019 -30617 30587
## 2020 -36543 52713
## 2021 7540 13581
plot.ts(dif2)
seasonplot(x)
ie <-desc$figure
meses <- c("enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre")
indices <- data.frame(meses,ie);indices
## meses ie
## 1 enero 1.0270038
## 2 febrero 0.9518760
## 3 marzo 0.9875256
## 4 abril 0.9166669
## 5 mayo 0.9863949
## 6 junio 0.9816528
## 7 julio 1.0146687
## 8 agosto 1.0105742
## 9 septiembre 0.9977380
## 10 octubre 1.0385644
## 11 noviembre 1.0008167
## 12 diciembre 1.0865180
may<-c(rep(1.09,12))
men<-c(rep(0.5,12))
dato<-data.frame(rbind(may,men,ie))
colnames(dato)<-paste(meses)
radarchart(dato)
HW1<-HoltWinters(x, beta=FALSE, gamma=FALSE);HW1
## Holt-Winters exponential smoothing without trend and without seasonal component.
##
## Call:
## HoltWinters(x = x, beta = FALSE, gamma = FALSE)
##
## Smoothing parameters:
## alpha: 0.3955523
## beta : FALSE
## gamma: FALSE
##
## Coefficients:
## [,1]
## a 286197.5
plot(HW1)
fitted(HW1)
## xhat level
## Feb 2013 347461.0 347461.0
## Mar 2013 334904.2 334904.2
## Apr 2013 325693.3 325693.3
## May 2013 337250.0 337250.0
## Jun 2013 348202.5 348202.5
## Jul 2013 345622.1 345622.1
## Aug 2013 347321.3 347321.3
## Sep 2013 346035.7 346035.7
## Oct 2013 341931.2 341931.2
## Nov 2013 349555.0 349555.0
## Dec 2013 348781.3 348781.3
## Jan 2014 353118.0 353118.0
## Feb 2014 353818.1 353818.1
## Mar 2014 338184.7 338184.7
## Apr 2014 333573.8 333573.8
## May 2014 323886.4 323886.4
## Jun 2014 333320.6 333320.6
## Jul 2014 327245.9 327245.9
## Aug 2014 335950.0 335950.0
## Sep 2014 334030.8 334030.8
## Oct 2014 331177.8 331177.8
## Nov 2014 334666.6 334666.6
## Dec 2014 327120.4 327120.4
## Jan 2015 335879.0 335879.0
## Feb 2015 334736.6 334736.6
## Mar 2015 321237.0 321237.0
## Apr 2015 321368.7 321368.7
## May 2015 316256.3 316256.3
## Jun 2015 321905.1 321905.1
## Jul 2015 323468.3 323468.3
## Aug 2015 334868.4 334868.4
## Sep 2015 336425.5 336425.5
## Oct 2015 338774.1 338774.1
## Nov 2015 344288.1 344288.1
## Dec 2015 336841.4 336841.4
## Jan 2016 344040.3 344040.3
## Feb 2016 337941.5 337941.5
## Mar 2016 325552.2 325552.2
## Apr 2016 315857.6 315857.6
## May 2016 316270.7 316270.7
## Jun 2016 314363.9 314363.9
## Jul 2016 308904.5 308904.5
## Aug 2016 296653.7 296653.7
## Sep 2016 299212.6 299212.6
## Oct 2016 296104.9 296104.9
## Nov 2016 295372.8 295372.8
## Dec 2016 293413.3 293413.3
## Jan 2017 300155.4 300155.4
## Feb 2017 295291.9 295291.9
## Mar 2017 284309.4 284309.4
## Apr 2017 287318.6 287318.6
## May 2017 273582.8 273582.8
## Jun 2017 282912.4 282912.4
## Jul 2017 286641.1 286641.1
## Aug 2017 283464.8 283464.8
## Sep 2017 283029.0 283029.0
## Oct 2017 283010.8 283010.8
## Nov 2017 283748.6 283748.6
## Dec 2017 284928.3 284928.3
## Jan 2018 291896.2 291896.2
## Feb 2018 291401.7 291401.7
## Mar 2018 282844.4 282844.4
## Apr 2018 279950.4 279950.4
## May 2018 278665.9 278665.9
## Jun 2018 286003.4 286003.4
## Jul 2018 287780.5 287780.5
## Aug 2018 289112.1 289112.1
## Sep 2018 290690.3 290690.3
## Oct 2018 286363.6 286363.6
## Nov 2018 285591.7 285591.7
## Dec 2018 282443.2 282443.2
## Jan 2019 292672.5 292672.5
## Feb 2019 291552.5 291552.5
## Mar 2019 280540.5 280540.5
## Apr 2019 278692.3 278692.3
## May 2019 270128.9 270128.9
## Jun 2019 281213.9 281213.9
## Jul 2019 278104.5 278104.5
## Aug 2019 285431.5 285431.5
## Sep 2019 288394.8 288394.8
## Oct 2019 284398.6 284398.6
## Nov 2019 289124.4 289124.4
## Dec 2019 287011.6 287011.6
## Jan 2020 292864.0 292864.0
## Feb 2020 291830.4 291830.4
## Mar 2020 284997.1 284997.1
## Apr 2020 277461.0 277461.0
## May 2020 250370.0 250370.0
## Jun 2020 247516.1 247516.1
## Jul 2020 249134.3 249134.3
## Aug 2020 258956.9 258956.9
## Sep 2020 262158.5 262158.5
## Oct 2020 269632.3 269632.3
## Nov 2020 281680.7 281680.7
## Dec 2020 282039.6 282039.6
## Jan 2021 296183.5 296183.5
## Feb 2021 291337.8 291337.8
## Mar 2021 284279.6 284279.6
## Apr 2021 287842.1 287842.1
## May 2021 275515.1 275515.1
## Jun 2021 254183.7 254183.7
## Jul 2021 260993.7 260993.7
## Aug 2021 268742.3 268742.3
## Sep 2021 272947.3 272947.3
## Oct 2021 277649.5 277649.5
## Nov 2021 278264.0 278264.0
## Dec 2021 279390.1 279390.1
pre1<-predict(HW1,12, prediction.interval = TRUE, level=0.95);pre1
## fit upr lwr
## Jan 2022 286197.5 322969.6 249425.5
## Feb 2022 286197.5 325741.8 246653.2
## Mar 2022 286197.5 328332.0 244063.0
## Apr 2022 286197.5 330772.0 241623.1
## May 2022 286197.5 333085.1 239309.9
## Jun 2022 286197.5 335289.4 237105.7
## Jul 2022 286197.5 337398.9 234996.2
## Aug 2022 286197.5 339424.8 232970.3
## Sep 2022 286197.5 341376.4 231018.7
## Oct 2022 286197.5 343261.3 229133.8
## Nov 2022 286197.5 345085.9 227309.2
## Dec 2022 286197.5 346855.6 225539.5
HW2<-HoltWinters(x, gamma=FALSE);HW2
## Holt-Winters exponential smoothing with trend and without seasonal component.
##
## Call:
## HoltWinters(x = x, gamma = FALSE)
##
## Smoothing parameters:
## alpha: 0.690958
## beta : 0.1821261
## gamma: FALSE
##
## Coefficients:
## [,1]
## a 292304.569
## b 2948.987
plot(HW2)
fitted(HW2)
## xhat level trend
## Mar 2013 283971.0 315716.0 -31745.00000
## Apr 2013 274808.1 303073.9 -28265.86161
## May 2013 311969.4 330155.1 -18185.71694
## Jun 2013 337049.2 348569.2 -11519.94770
## Jul 2013 329310.9 340248.2 -10937.32986
## Aug 2013 335205.4 343549.5 -8344.09941
## Sep 2013 334102.7 341331.2 -7228.44358
## Oct 2013 328145.4 335178.0 -7032.59946
## Nov 2013 348115.9 350988.2 -2872.33741
## Dec 2013 344821.4 347758.7 -2937.38110
## Jan 2014 354073.6 355133.0 -1059.36789
## Feb 2014 353679.4 354636.3 -956.88235
## Mar 2014 320553.4 326466.4 -5913.07627
## Apr 2014 319520.4 324681.6 -5161.22015
## May 2014 305833.9 312308.6 -6474.67359
## Jun 2014 333585.7 334787.2 -1201.52849
## Jul 2014 319623.6 322791.1 -3167.50600
## Aug 2014 340655.7 340094.9 560.85490
## Sep 2014 333409.8 334051.7 -641.90333
## Oct 2014 327383.7 328855.2 -1471.42953
## Nov 2014 336215.6 336099.7 115.96904
## Dec 2014 319483.8 321963.5 -2479.71557
## Jan 2015 341327.7 340060.0 1267.74451
## Feb 2015 335786.0 335567.4 218.64047
## Mar 2015 307271.3 311479.5 -4208.21429
## Apr 2015 314742.3 317151.1 -2408.84244
## May 2015 307189.0 310390.4 -3201.42346
## Jun 2015 323058.2 323321.5 -263.27756
## Jul 2015 325081.0 324992.1 88.92634
## Aug 2015 347393.4 343880.6 3512.82257
## Sep 2015 343891.2 341459.2 2432.04578
## Oct 2015 345075.0 342835.3 2239.73201
## Nov 2015 353554.3 350353.2 3201.03265
## Dec 2015 333809.6 334143.7 -334.13863
## Jan 2016 350817.2 348479.6 2337.65735
## Feb 2016 335025.8 335481.3 -455.42463
## Mar 2016 311368.5 315398.6 -4030.05655
## Apr 2016 298904.6 304234.0 -5329.43771
## May 2016 308275.4 311340.0 -3064.61753
## Jun 2016 307803.8 310468.9 -2665.12453
## Jul 2016 299223.6 302800.0 -3576.44291
## Aug 2016 278257.0 284512.7 -6255.67990
## Sep 2016 292311.9 295438.4 -3126.50703
## Oct 2016 288404.6 291651.4 -3246.79315
## Nov 2016 289935.6 292446.3 -2510.69697
## Dec 2016 287819.7 290269.6 -2449.86451
## Jan 2017 303860.8 303461.8 398.96645
## Feb 2017 291190.3 292804.9 -1614.59645
## Mar 2017 270247.5 274840.0 -4592.42298
## Apr 2017 283354.7 285220.2 -1865.50664
## May 2017 256363.1 262099.7 -5736.60571
## Jun 2017 283956.7 284558.2 -601.52715
## Jul 2017 290201.8 289748.5 453.31091
## Aug 2017 281187.8 282193.1 -1005.29642
## Sep 2017 281142.4 281999.8 -857.40236
## Oct 2017 281788.4 282414.2 -625.77843
## Nov 2017 283684.6 283921.8 -237.23019
## Dec 2017 285935.7 285789.5 146.13683
## Jan 2018 299647.5 297411.3 2236.15403
## Feb 2018 294531.2 293427.8 1103.39488
## Mar 2018 275408.0 277420.9 -2012.84580
## Apr 2018 273493.2 275490.9 -1997.74905
## May 2018 274117.2 275711.0 -1593.82020
## Jun 2018 291390.5 290077.5 1312.96496
## Jul 2018 291972.8 290772.4 1200.40389
## Aug 2018 292498.7 291402.2 1096.48001
## Sep 2018 294088.0 292915.6 1172.40056
## Oct 2018 283550.8 284182.4 -631.65666
## Nov 2018 283622.6 284145.8 -523.27647
## Dec 2018 278206.2 279483.3 -1277.13756
## Jan 2019 301512.9 299002.5 2510.41326
## Feb 2019 294489.7 293448.1 1041.60111
## Mar 2019 270392.9 273224.3 -2831.38543
## Apr 2019 272033.6 274176.0 -2142.39274
## May 2019 257646.9 261675.7 -4028.82841
## Jun 2019 286703.4 285634.9 1068.51899
## Jul 2019 276867.3 277478.8 -611.51812
## Aug 2019 292396.3 290521.1 1875.19370
## Sep 2019 294701.7 292760.2 1941.47258
## Oct 2019 283239.7 283363.3 -123.54834
## Nov 2019 293821.4 292295.6 1525.76230
## Dec 2019 287147.8 286885.3 262.51845
## Jan 2020 299383.9 297276.7 2107.25346
## Feb 2020 294031.4 293073.5 957.95060
## Mar 2020 279081.0 280574.0 -1492.98949
## Apr 2020 266858.5 270004.6 -3146.04791
## May 2020 216430.8 226861.4 -10430.57383
## Jun 2020 227828.5 234896.1 -7067.56209
## Jul 2020 240183.2 244258.5 -4075.24596
## Aug 2020 263702.5 263526.4 176.15506
## Sep 2020 266613.7 266016.2 597.52970
## Oct 2020 279005.2 276590.7 2414.59007
## Nov 2020 298643.5 293575.3 5068.17788
## Dec 2020 290597.6 287549.8 3047.73263
## Jan 2021 315861.8 309391.2 6470.55041
## Feb 2021 296252.9 293800.3 2452.58697
## Mar 2021 280116.0 280527.5 -411.42859
## Apr 2021 290461.8 289215.9 1245.89880
## May 2021 264113.1 267118.6 -3005.50662
## Jun 2021 226372.3 234729.4 -8357.05447
## Jul 2021 254793.8 257484.5 -2690.70413
## Aug 2021 273167.7 272613.1 554.64045
## Sep 2021 278790.8 277455.3 1335.52347
## Oct 2021 285063.2 282967.1 2096.13092
## Nov 2021 282372.7 281014.1 1358.67146
## Dec 2021 282700.8 281500.9 1199.89377
pre2<-predict(HW2,12, prediction.interval = TRUE, level=0.95);pre2
## fit upr lwr
## Jan 2022 295253.6 338762.8 251744.3
## Feb 2022 298202.5 354381.1 242024.0
## Mar 2022 301151.5 370708.3 231594.8
## Apr 2022 304100.5 387762.7 220438.4
## May 2022 307049.5 405536.2 208562.8
## Jun 2022 309998.5 424011.2 195985.7
## Jul 2022 312947.5 443167.1 182727.8
## Aug 2022 315896.5 462982.6 168810.3
## Sep 2022 318845.4 483437.1 154253.8
## Oct 2022 321794.4 504510.9 139077.9
## Nov 2022 324743.4 526185.8 123301.1
## Dec 2022 327692.4 548444.5 106940.3
HW3<-HoltWinters(x);HW3
## Holt-Winters exponential smoothing with trend and additive seasonal component.
##
## Call:
## HoltWinters(x = x)
##
## Smoothing parameters:
## alpha: 0.3678406
## beta : 0
## gamma: 0.3594492
##
## Coefficients:
## [,1]
## a 269931.178
## b -1215.655
## s1 8357.184
## s2 -11539.076
## s3 -3102.282
## s4 -30147.203
## s5 -10003.576
## s6 1092.296
## s7 10855.031
## s8 7727.340
## s9 5467.445
## s10 12860.402
## s11 4970.838
## s12 27411.986
plot(HW3)
fitted(HW3)
## xhat level trend season
## Jan 2014 363409.1 347863.0 -1215.655 16761.8229
## Feb 2014 319034.4 343512.9 -1215.655 -23262.8437
## Mar 2014 329217.3 340553.9 -1215.655 -10120.9271
## Apr 2014 310819.4 338349.0 -1215.655 -26313.9271
## May 2014 349836.4 336494.6 -1215.655 14557.4479
## Jun 2014 319845.0 334506.7 -1215.655 -13446.0521
## Jul 2014 337351.9 332598.8 -1215.655 5968.8229
## Aug 2014 334416.0 335760.1 -1215.655 -128.4271
## Sep 2014 323005.8 333323.9 -1215.655 -9102.4687
## Oct 2014 350026.6 333510.6 -1215.655 17731.7396
## Nov 2014 334142.3 328606.0 -1215.655 6751.9479
## Dec 2014 339952.9 320565.7 -1215.655 20602.8646
## Jan 2015 336384.6 322774.7 -1215.655 14825.5750
## Feb 2015 294755.3 320310.7 -1215.655 -24339.7707
## Mar 2015 309300.2 321247.9 -1215.655 -10732.0167
## Apr 2015 296621.4 324545.6 -1215.655 -26708.4918
## May 2015 340543.5 327678.7 -1215.655 14080.4001
## Jun 2015 307692.9 322782.3 -1215.655 -13873.6994
## Jul 2015 335705.1 328248.1 -1215.655 8672.6347
## Aug 2015 331034.7 333132.7 -1215.655 -882.3733
## Sep 2015 325323.4 334775.3 -1215.655 -8236.2273
## Oct 2015 354064.8 339827.5 -1215.655 15452.9397
## Nov 2015 339435.4 338115.0 -1215.655 2536.1072
## Dec 2015 353262.1 331759.3 -1215.655 22718.3970
## Jan 2016 344036.8 331198.0 -1215.655 14054.4563
## Feb 2016 300086.7 324312.2 -1215.655 -23009.8613
## Mar 2016 316340.1 325499.7 -1215.655 -7943.9703
## Apr 2016 293419.5 318657.2 -1215.655 -24022.0586
## May 2016 336670.3 326079.4 -1215.655 11806.6337
## Jun 2016 304624.7 315586.6 -1215.655 -9746.2948
## Jul 2016 324101.9 312876.6 -1215.655 12440.9813
## Aug 2016 294345.7 294678.1 -1215.655 883.2730
## Sep 2016 291111.1 296691.1 -1215.655 -4364.3333
## Oct 2016 309495.9 295565.5 -1215.655 15146.0051
## Nov 2016 286888.6 288743.3 -1215.655 -639.0608
## Dec 2016 310733.2 288826.3 -1215.655 23122.6240
## Jan 2017 296845.5 287509.4 -1215.655 10551.7565
## Feb 2017 260247.5 282988.5 -1215.655 -21525.2952
## Mar 2017 271814.9 284450.5 -1215.655 -11419.9232
## Apr 2017 270727.4 290629.2 -1215.655 -18686.1435
## May 2017 287603.2 282743.0 -1215.655 6075.8361
## Jun 2017 273160.9 285046.0 -1215.655 -10669.4569
## Jul 2017 291619.3 290884.9 -1215.655 1950.0614
## Aug 2017 286546.3 284884.2 -1215.655 2877.7242
## Sep 2017 276605.4 282129.8 -1215.655 -4308.6866
## Oct 2017 293727.0 283260.1 -1215.655 11682.6066
## Nov 2017 277736.1 278788.6 -1215.655 163.1555
## Dec 2017 302726.1 280881.7 -1215.655 23060.0821
## Jan 2018 286893.4 279599.0 -1215.655 8509.9951
## Feb 2018 258676.9 279763.7 -1215.655 -19871.1901
## Mar 2018 274560.0 282627.8 -1215.655 -6852.1482
## Apr 2018 257745.8 281768.2 -1215.655 -22806.8131
## May 2018 294559.6 287525.8 -1215.655 8249.4724
## Jun 2018 279760.0 287287.3 -1215.655 -6311.6374
## Jul 2018 287799.3 290020.8 -1215.655 -1005.7954
## Aug 2018 290748.0 290036.5 -1215.655 1927.1557
## Sep 2018 285611.6 289686.8 -1215.655 -2859.5206
## Oct 2018 294771.5 286315.7 -1215.655 9671.3988
## Nov 2018 282280.8 281289.4 -1215.655 2207.0498
## Dec 2018 300166.8 278363.7 -1215.655 23018.7064
## Jan 2019 288288.3 280141.3 -1215.655 9362.7029
## Feb 2019 260930.1 279496.8 -1215.655 -17350.9678
## Mar 2019 271456.9 279304.8 -1215.655 -6632.2000
## Apr 2019 259996.9 279711.7 -1215.655 -18499.1784
## May 2019 285046.9 277409.5 -1215.655 8853.0741
## Jun 2019 275927.0 281014.8 -1215.655 -3872.1036
## Jul 2019 277391.5 278852.3 -1215.655 -245.1049
## Aug 2019 285959.0 284712.6 -1215.655 2462.0466
## Sep 2019 280651.9 286058.6 -1215.655 -4190.9892
## Oct 2019 290076.6 283974.8 -1215.655 7317.4280
## Nov 2019 285000.4 285065.3 -1215.655 1150.7014
## Dec 2019 307053.9 283401.9 -1215.655 24867.7161
## Jan 2020 288756.0 280256.2 -1215.655 9715.5140
## Feb 2020 261656.2 279590.4 -1215.655 -16718.6211
## Mar 2020 276274.0 283119.5 -1215.655 -5629.8700
## Apr 2020 257718.4 278104.4 -1215.655 -19170.3795
## May 2020 269573.4 258957.9 -1215.655 11831.1623
## Jun 2020 242351.8 248024.5 -1215.655 -4456.9971
## Jul 2020 253123.6 250213.2 -1215.655 4125.9811
## Aug 2020 259493.5 256664.6 -1215.655 4044.4739
## Sep 2020 252286.1 258229.0 -1215.655 -4727.2371
## Oct 2020 275121.3 267595.0 -1215.655 8742.0137
## Nov 2020 275223.0 275564.5 -1215.655 874.0788
## Dec 2020 299517.8 277058.0 -1215.655 23675.4596
## Jan 2021 291405.8 282566.2 -1215.655 10055.2123
## Feb 2021 263598.5 278601.8 -1215.655 -13787.6275
## Mar 2021 271833.5 281026.1 -1215.655 -7976.9140
## Apr 2021 256238.9 287701.5 -1215.655 -30246.9833
## May 2021 291259.9 286647.4 -1215.655 5828.1357
## Jun 2021 256233.6 259803.2 -1215.655 -2353.9478
## Jul 2021 271812.9 264166.4 -1215.655 8862.2174
## Aug 2021 270722.8 266176.7 -1215.655 5761.7661
## Sep 2021 268736.7 268142.9 -1215.655 1809.4498
## Oct 2021 286049.3 272848.9 -1215.655 14416.0836
## Nov 2021 270446.9 269114.9 -1215.655 2547.6323
## Dec 2021 298435.3 271821.9 -1215.655 27829.0178
pre3<-predict(HW3,12, prediction.interval = TRUE, level=0.95);pre3
## fit upr lwr
## Jan 2022 277072.7 306754.4 247391.0
## Feb 2022 255960.8 287586.9 224334.7
## Mar 2022 263181.9 296639.6 229724.3
## Apr 2022 234921.4 270115.4 199727.3
## May 2022 253849.3 290698.0 217000.7
## Jun 2022 263729.5 302161.7 225297.4
## Jul 2022 272276.6 312229.5 232323.7
## Aug 2022 267933.3 309351.2 226515.4
## Sep 2022 264457.7 307290.5 221625.0
## Oct 2022 270635.0 314837.4 226432.6
## Nov 2022 261529.8 307060.7 215999.0
## Dec 2022 282755.3 329576.9 235933.7
ajuste <- auto.arima(x)
summary(ajuste)
## Series: x
## ARIMA(0,1,1)(1,0,1)[12]
##
## Coefficients:
## ma1 sar1 sma1
## -0.5965 0.8705 -0.5088
## s.e. 0.0900 0.0947 0.1900
##
## sigma^2 = 241467066: log likelihood = -1186.48
## AIC=2380.96 AICc=2381.35 BIC=2391.65
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -503.8295 15248.73 11021.25 -0.4031297 3.812375 0.7047725
## ACF1
## Training set 0.007266799
predicciones <- forecast(ajuste);predicciones
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Jan 2022 280441.2 260526.8 300355.5 249984.8 310897.6
## Feb 2022 269151.8 247677.3 290626.3 236309.4 301994.2
## Mar 2022 276829.9 253901.2 299758.7 241763.4 311896.4
## Apr 2022 250587.2 226291.1 274883.3 213429.5 287744.9
## May 2022 250323.4 224732.9 275913.9 211186.1 289460.7
## Jun 2022 266819.3 239996.8 293641.8 225797.8 307840.8
## Jul 2022 276148.4 248148.0 304148.8 233325.6 318971.3
## Aug 2022 274425.6 245295.0 303556.3 229874.2 318977.1
## Sep 2022 276831.0 246612.3 307049.6 230615.5 323046.4
## Oct 2022 280459.3 249190.5 311728.2 232637.8 328280.9
## Nov 2022 276137.4 243852.6 308422.3 226762.0 325512.9
## Dec 2022 292334.2 259064.3 325604.1 241452.2 343216.1
## Jan 2023 277489.7 240895.7 314083.7 221524.0 333455.4
## Feb 2023 267662.5 229467.5 305857.5 209248.2 326076.7
## Mar 2023 274346.2 234614.6 314077.7 213582.0 335110.3
## Apr 2023 251502.2 210291.3 292713.0 188475.6 314528.7
## May 2023 251272.6 208633.7 293911.4 186062.1 316483.0
## Jun 2023 265632.1 221611.5 309652.6 198308.5 332955.7
## Jul 2023 273752.9 228392.7 319113.1 204380.5 343125.3
## Aug 2023 272253.2 225591.9 318914.6 200890.9 343615.6
## Sep 2023 274347.1 226419.9 322274.3 201048.7 347645.5
## Oct 2023 277505.5 228345.0 326666.0 202321.0 352690.0
## Nov 2023 273743.4 223379.7 324107.0 196718.9 350767.9
## Dec 2023 287842.4 236303.8 339381.0 209020.9 366663.9
autoplot(predicciones)
arima1<- Arima(x, order=c(0,1,2), seasonal=list(order=c(0,1,1),period=12))
arima2<- Arima(x, order=c(1,1,0), seasonal=list(order=c(2,1,0),period=12))
arima3<- Arima(x, order=c(1,1,2), seasonal=list(order=c(2,1,1),period=12))
arima4<- Arima(x, order=c(1,1,1), seasonal=list(order=c(2,1,1),period=12))
arima5<- Arima(x, order=c(0,1,1), seasonal=list(order=c(0,1,1),period=12))
arima6<- Arima(x, order=c(1,2,0), seasonal=list(order=c(1,1,0),period=12))
AIC(arima1,arima2,arima3,arima4,arima5,arima6)
## Warning in AIC.default(arima1, arima2, arima3, arima4, arima5, arima6): models
## are not all fitted to the same number of observations
## df AIC
## arima1 4 2119.403
## arima2 4 2124.023
## arima3 7 2121.853
## arima4 6 2121.743
## arima5 3 2117.410
## arima6 3 2181.562
BIC(arima1,arima2,arima3,arima4,arima5,arima6)
## Warning in BIC.default(arima1, arima2, arima3, arima4, arima5, arima6): models
## are not all fitted to the same number of observations
## df BIC
## arima1 4 2129.619
## arima2 4 2134.238
## arima3 7 2139.730
## arima4 6 2137.066
## arima5 3 2125.071
## arima6 3 2189.192
accuracy(arima5)
## ME RMSE MAE MPE MAPE MASE
## Training set -185.6172 14792.87 9866.238 -0.2394599 3.499541 0.630913
## ACF1
## Training set -0.005411668
forecast5<-forecast(arima5, level = c(95), h =12)
forecast5
## Point Forecast Lo 95 Hi 95
## Jan 2022 278770.4 247525.0 310015.8
## Feb 2022 262372.0 228770.9 295973.0
## Mar 2022 272283.1 236481.1 308085.1
## Apr 2022 238782.7 200907.4 276658.0
## May 2022 242445.4 202604.6 282286.2
## Jun 2022 260559.0 218845.2 302272.9
## Jul 2022 272821.6 229315.2 316327.9
## Aug 2022 270658.4 225430.7 315886.2
## Sep 2022 272919.2 226033.1 319805.3
## Oct 2022 278774.2 230286.4 327261.9
## Nov 2022 272163.2 222125.1 322201.3
## Dec 2022 294592.1 243050.2 346134.0
autoplot(forecast5)
ajuste1<- ses(x)
summary(ajuste1)
##
## Forecast method: Simple exponential smoothing
##
## Model Information:
## Simple exponential smoothing
##
## Call:
## ses(y = x)
##
## Smoothing parameters:
## alpha = 0.3921
##
## Initial states:
## l = 342216.5221
##
## sigma: 18781.39
##
## AIC AICc BIC
## 2635.226 2635.456 2643.272
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -1324.898 18606.68 14354.81 -0.7675646 4.926907 0.9179424
## ACF1
## Training set 0.04632337
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Jan 2022 286114.3 262045.0 310183.6 249303.5 322925.2
## Feb 2022 286114.3 260261.1 311967.6 246575.2 325653.4
## Mar 2022 286114.3 258592.5 313636.1 244023.4 328205.3
## Apr 2022 286114.3 257019.5 315209.1 241617.7 330611.0
## May 2022 286114.3 255527.3 316701.3 239335.5 332893.1
## Jun 2022 286114.3 254104.6 318124.1 237159.6 335069.0
## Jul 2022 286114.3 252742.4 319486.2 235076.4 337152.2
## Aug 2022 286114.3 251433.8 320794.9 233075.0 339153.6
## Sep 2022 286114.3 250172.7 322055.9 231146.4 341082.3
## Oct 2022 286114.3 248954.4 323274.2 229283.2 342945.5
plot(forecast(ajuste1))
accuracy(ajuste1)
## ME RMSE MAE MPE MAPE MASE
## Training set -1324.898 18606.68 14354.81 -0.7675646 4.926907 0.9179424
## ACF1
## Training set 0.04632337
ajuste2<- ets(x)
summary(ajuste2)
## ETS(A,N,A)
##
## Call:
## ets(y = x)
##
## Smoothing parameters:
## alpha = 0.401
## gamma = 1e-04
##
## Initial states:
## l = 338209.574
## s = 25461.76 -45.4061 11707.82 -851.4906 3115.643 4715.732
## -5543.682 -3026.193 -22400.59 -4170.834 -14910.33 5947.569
##
## sigma: 15009.91
##
## AIC AICc BIC
## 2597.832 2603.050 2638.064
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -1470.902 14003.29 10113.97 -0.679988 3.482348 0.6467549
## ACF1
## Training set 0.03905256
pre2<-predict(ajuste2);pre2
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Jan 2022 280463.0 261227.0 299699.0 251044.1 309881.9
## Feb 2022 259601.8 238877.2 280326.4 227906.3 291297.3
## Mar 2022 270340.6 248227.4 292453.8 236521.4 304159.8
## Apr 2022 252116.6 228696.9 275536.2 216299.3 287933.9
## May 2022 271489.9 246832.9 296146.8 233780.3 309199.4
## Jun 2022 268969.7 243134.6 294804.8 229458.3 308481.0
## Jul 2022 279229.1 252267.3 306190.9 237994.6 320463.6
## Aug 2022 277629.4 249586.2 305672.6 234741.0 320517.8
## Sep 2022 273663.6 244579.0 302748.1 229182.6 318144.5
## Oct 2022 286220.7 256130.9 316310.4 240202.3 332239.0
## Nov 2022 274468.8 243406.2 305531.3 226962.7 321974.8
## Dec 2022 299974.5 267968.3 331980.7 251025.2 348923.7
## Jan 2023 280463.0 247540.6 313385.4 230112.6 330813.4
## Feb 2023 259601.8 225788.1 293415.5 207888.2 311315.4
## Mar 2023 270340.6 235658.4 305022.8 217298.8 323382.4
## Apr 2023 252116.6 216587.2 287646.0 197779.0 306454.2
## May 2023 271489.9 235132.9 307846.8 215886.7 327093.0
## Jun 2023 268969.7 231803.7 306135.7 212129.2 325810.2
## Jul 2023 279229.1 241271.3 317187.0 221177.6 337280.6
## Aug 2023 277629.4 238895.9 316362.9 218391.6 336867.2
## Sep 2023 273663.6 234169.6 313157.5 213262.8 334064.3
## Oct 2023 286220.7 245980.7 326460.6 224678.9 347762.4
## Nov 2023 274468.8 233496.3 315441.2 211806.8 337130.7
## Dec 2023 299974.5 258282.1 341666.9 236211.5 363737.5
plot(forecast(ajuste2))
accuracy(ajuste2)
## ME RMSE MAE MPE MAPE MASE
## Training set -1470.902 14003.29 10113.97 -0.679988 3.482348 0.6467549
## ACF1
## Training set 0.03905256
ajuste3 <- nnetar(x)
summary(ajuste3)
## Length Class Mode
## x 108 ts numeric
## m 1 -none- numeric
## p 1 -none- numeric
## P 1 -none- numeric
## scalex 2 -none- list
## size 1 -none- numeric
## subset 108 -none- numeric
## model 20 nnetarmodels list
## nnetargs 0 -none- list
## fitted 108 ts numeric
## residuals 108 ts numeric
## lags 4 -none- numeric
## series 1 -none- character
## method 1 -none- character
## call 2 -none- call
pre3<-predict(ajuste3);pre3
## Jan Feb Mar Apr May Jun Jul Aug
## 2022 283929.6 279445.6 284436.7 272964.9 245010.5 253620.1 271759.6 277380.1
## 2023 282486.6 281138.9 282073.7 278551.0 256806.3 250673.2 255121.3 265317.7
## Sep Oct Nov Dec
## 2022 281281.8 280280.3 280984.1 285570.9
## 2023 276802.7 279222.7 280616.7 282203.1
residuos3<-residuals(ajuste3);residuos3
## Jan Feb Mar Apr May Jun
## 2013 NA NA NA NA NA NA
## 2014 3593.8442 -16336.6965 9092.0276 -17884.7558 10764.7654 -3760.7041
## 2015 -1697.9751 -19693.3468 7167.0495 6451.4412 11163.7760 17009.9093
## 2016 396.2656 -6848.2123 -10100.9816 15911.8470 7338.7283 -6167.6102
## 2017 -11471.5302 -26570.4333 6840.0163 -35102.5211 8861.8421 8915.9611
## 2018 4310.6950 -9019.7736 -7209.9250 9440.5522 12392.6714 4675.1789
## 2019 3392.4597 -16481.8571 2776.8035 -19775.2631 15910.2200 -8952.0020
## 2020 3928.2034 -2727.5494 -11435.4276 -44006.0089 -10270.2763 -3570.1009
## 2021 -3896.0837 -8417.4175 15344.9851 9733.3804 -27595.8662 27014.4269
## Jul Aug Sep Oct Nov Dec
## 2013 NA NA NA NA NA NA
## 2014 7089.9681 3050.8073 -8738.5879 -1082.3409 -18198.0873 6515.0342
## 2015 17134.8653 11255.1555 9987.7893 16907.4127 1406.3466 9624.8983
## 2016 -35565.7600 3653.3207 -8312.4043 -15603.4023 -4374.0755 2764.9907
## 2017 -5131.2477 -6334.0832 -652.1805 -601.2165 2174.1501 11875.0984
## 2018 7751.2270 9648.4791 -4395.4152 1394.3226 -5062.9753 20754.7007
## 2019 11193.5739 8145.3632 -5794.2668 14217.0762 2358.0280 10031.8303
## 2020 -3676.8235 -13629.7750 4228.1019 16516.8797 -1776.8850 27595.8343
## 2021 8550.9211 3575.4456 3939.7494 -7689.8291 -502.4425 6655.8029
plot(forecast(ajuste3,h=24))
accuracy(ajuste3)
## ME RMSE MAE MPE MAPE MASE
## Training set 65.73028 12866.45 9984.774 -0.2168742 3.491192 0.6384931
## ACF1
## Training set -0.008464367
ajuste4<-rwf(x,h=24)
summary(ajuste4)
##
## Forecast method: Random walk
##
## Model Information:
## Call: rwf(y = x, h = 24)
##
## Residual sd: 21335.611
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set -475.3364 21335.61 17504.07 -0.421939 5.926089 1.119327 -0.4294697
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Jan 2022 296600 269257.3 323942.7 254782.97 338417.0
## Feb 2022 296600 257931.6 335268.4 237461.79 355738.2
## Mar 2022 296600 249241.1 343958.9 224170.78 369029.2
## Apr 2022 296600 241914.6 351285.4 212965.94 380234.1
## May 2022 296600 235459.9 357740.1 203094.28 390105.7
## Jun 2022 296600 229624.4 363575.6 194169.62 399030.4
## Jul 2022 296600 224258.1 368941.9 185962.54 407237.5
## Aug 2022 296600 219263.2 373936.8 178323.58 414876.4
## Sep 2022 296600 214571.9 378628.1 171148.91 422051.1
## Oct 2022 296600 210134.8 383065.2 164362.94 428837.1
## Nov 2022 296600 205914.6 387285.4 157908.60 435291.4
## Dec 2022 296600 201882.2 391317.8 151741.56 441458.4
## Jan 2023 296600 198014.5 395185.5 145826.56 447373.4
## Feb 2023 296600 194293.0 398907.0 140135.00 453065.0
## Mar 2023 296600 190702.2 402497.8 134643.34 458556.7
## Apr 2023 296600 187229.3 405970.7 129331.88 463868.1
## May 2023 296600 183863.2 409336.8 124183.97 469016.0
## Jun 2023 296600 180594.8 412605.2 119185.37 474014.6
## Jul 2023 296600 177416.0 415784.0 114323.80 478876.2
## Aug 2023 296600 174319.8 418880.2 109588.56 483611.4
## Sep 2023 296600 171300.1 421899.9 104970.30 488229.7
## Oct 2023 296600 168351.4 424848.6 100460.75 492739.3
## Nov 2023 296600 165469.1 427730.9 96052.57 497147.4
## Dec 2023 296600 162648.7 430551.3 91739.23 501460.8
residuos4<-residuals(ajuste4);residuos4
## Jan Feb Mar Apr May Jun Jul Aug Sep Oct
## 2013 NA -31745 -4098 43292 10029 -23260 8239 -5847 -8412 25546
## 2014 -4857 -40593 12233 -17445 38654 -29774 31288 -18153 -4280 13180
## 2015 -16272 -32383 20962 -13126 22093 -4680 26432 -13484 3558 10351
## 2016 -26419 -22002 -5577 15859 -5452 -10888 -22629 25190 -11767 2898
## 2017 -22598 -20333 24390 -39324 44576 -4830 -13728 3752 620 1893
## 2018 -11898 -20878 5760 1175 20513 -6720 651 1955 -13350 4660
## 2019 -18463 -26128 12155 -18825 41110 -24800 23275 -3705 -14631 18054
## 2020 -11556 -15696 -8610 -56973 34183 8452 22360 -6916 14002 19039
## 2021 -33864 -10439 19792 -36608 -35091 49813 9183 -1210 5462 -5632
## Nov Dec
## 2013 -13606 12146
## 2014 -24409 33674
## 2015 -27252 29579
## 2016 -3835 20039
## 2017 1855 15813
## 2018 -6780 30672
## 2019 -12563 18024
## 2020 -17504 35209
## 2021 1908 15489
plot(ajuste4)
accuracy(ajuste4)
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set -475.3364 21335.61 17504.07 -0.421939 5.926089 1.119327 -0.4294697
ajuste5<-ar(x, aic = TRUE,order.max =12)
summary(ajuste5)
## Length Class Mode
## order 1 -none- numeric
## ar 12 -none- numeric
## var.pred 1 -none- numeric
## x.mean 1 -none- numeric
## aic 13 -none- numeric
## n.used 1 -none- numeric
## n.obs 1 -none- numeric
## order.max 1 -none- numeric
## partialacf 12 -none- numeric
## resid 108 ts numeric
## method 1 -none- character
## series 1 -none- character
## frequency 1 -none- numeric
## call 4 -none- call
## asy.var.coef 144 -none- numeric
pre5<-predict(ajuste5,n.ahead = 12);pre5
## $pred
## Jan Feb Mar Apr May Jun Jul Aug
## 2022 297630.8 292317.0 301011.7 289827.2 273799.0 281429.1 281976.3 281086.8
## Sep Oct Nov Dec
## 2022 283059.1 281366.8 279481.3 283786.7
##
## $se
## Jan Feb Mar Apr May Jun Jul Aug
## 2022 18178.10 19898.77 21285.71 22633.21 23087.86 23834.12 24132.11 24766.98
## Sep Oct Nov Dec
## 2022 24815.35 24912.46 24917.09 24937.37
residuos5<-residuals(ajuste5);residuos5
## Jan Feb Mar Apr May Jun
## 2013 NA NA NA NA NA NA
## 2014 2675.5848 -26802.2877 4562.1167 -19849.8016 19913.7150 -13805.5697
## 2015 -3092.1155 -32710.7298 7022.7646 -1173.7899 9579.7203 9297.6123
## 2016 -11676.7412 -21470.0439 -16326.2553 15989.6908 -3616.5312 -6286.4257
## 2017 -23340.0037 -25623.0188 2758.1458 -35489.1831 15444.0977 4267.3831
## 2018 -1259.3710 -18600.8561 -10036.6587 9214.7403 13621.5736 -1349.2371
## 2019 -6360.7017 -24149.4978 -2321.2614 -13082.3171 22797.2116 -11958.3396
## 2020 -2298.7123 -15711.2050 -15319.6344 -55418.9401 -10938.2289 9923.6044
## 2021 -20865.6166 -24742.4706 8966.2934 -9604.1717 -46465.4885 31309.3295
## Jul Aug Sep Oct Nov Dec
## 2013 NA NA NA NA NA NA
## 2014 21106.9072 -7771.0518 4833.7277 -4297.3978 -12430.1659 7082.2622
## 2015 19534.8998 3226.6334 11022.6204 5872.3795 -7001.9389 8382.8473
## 2016 -42280.9160 12304.2844 -13709.1412 -10519.8710 -13796.4203 6169.9848
## 2017 -5982.9386 -8947.2312 3639.2875 -6275.0616 6342.5419 -297.5819
## 2018 2010.9138 4124.8133 -7616.5659 -3660.1069 -7259.0817 17735.2340
## 2019 11956.7927 1357.5905 -5102.9755 4679.7929 1849.9092 -1714.9759
## 2020 15448.3761 -5217.5043 16652.6439 16281.4760 843.4932 13310.4265
## 2021 17535.7075 16340.6573 2678.0604 -6241.9480 2623.7968 4333.2948
plot(forecast(ajuste5,h=12))
points(1:length(x),fitted(ajuste5),type="l",col="red")
Paquetes utilizados: forecast y TTR.
|-|-|-|
O.M.F.
|-|-|-|