Una serie de tiempo o serie cronológica es un conjunto de observaciones para una variable registrada en diferentes épocas o periodos, generalmente equidistantes en el tiempo. Lo más común es que las series de tiempo se registren en forma anual, semestral, trimestral o mensual.
El objetivo de los métodos de serie de tiempo es establecer un patrón en los datos históricos, establecer un modelo para su comportamiento y luego extrapolarlo hacia el futuro.
Las técnicas de pronósticos son métodos que se utiliza en el análisis de las series de tiempo para predecir una variable de respuesta, que se basan en la tendencia mostrada por la serie, es decir su comportamiento a largo plazo. Este comportamiento se modela mediante un modelo o ecuación que tiende a replicar el comportamiento de la variable.
Se presentan varios modelos que se pueden ajustar a unos datos anuales.
Los datos corresponden a las remesas enviadas a Colombia por trabajadores colombianos que se encuentran en el exterior. Los datos corresponden al periodo 2000-2021. Fuente: Banco de la República.
remesas<-c(1578.02,2021.39,2453.71,3060.1,3169.9,3313.73,3860.94,4429.73,4784.92,
4090.28,3996.34,4064.1,3969.67,4401.04,4093.21,4957.4,5147.47,5783.71,6636.19,
7086.53,6908.84,8597.24)
length(remesas)
## [1] 22
t<-seq(1,22,1)
modelo1<-lm(remesas~t)
summary(modelo1)
##
## Call:
## lm(formula = remesas ~ t)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1233.70 -486.77 19.04 396.17 1562.37
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1666.99 297.19 5.609 1.72e-05 ***
## t 243.99 22.63 10.783 8.78e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 673.3 on 20 degrees of freedom
## Multiple R-squared: 0.8532, Adjusted R-squared: 0.8459
## F-statistic: 116.3 on 1 and 20 DF, p-value: 8.778e-10
predicho1<-predict(modelo1);predicho1
## 1 2 3 4 5 6 7 8
## 1910.988 2154.983 2398.977 2642.972 2886.966 3130.961 3374.955 3618.949
## 9 10 11 12 13 14 15 16
## 3862.944 4106.938 4350.933 4594.927 4838.922 5082.916 5326.911 5570.905
## 17 18 19 20 21 22
## 5814.899 6058.894 6302.888 6546.883 6790.877 7034.872
plot(t,remesas,type="o",pch=16)
points(t,predicho1,pch=16,col="steelblue")
lines(predicho1,lwd=2,col="red")
residuos1<-residuals(modelo1);residuos1
## 1 2 3 4 5 6
## -332.96834 -133.59278 54.73277 417.12833 282.93388 182.76944
## 7 8 9 10 11 12
## 485.98500 810.78055 921.97611 -16.65833 -354.59278 -530.82722
## 13 14 15 16 17 18
## -869.25167 -681.87611 -1233.70055 -613.50500 -667.42944 -275.18388
## 19 20 21 22
## 333.30167 539.64723 117.96278 1562.36834
nuevo<-data.frame(t = seq(23,27))
pronostico1<-predict(modelo1,nuevo);pronostico1
## 1 2 3 4 5
## 7278.866 7522.861 7766.855 8010.849 8254.844
AIC(modelo1)
## [1] 352.8759
modelo2<-lm(remesas~poly(t,2))
summary(modelo2)
##
## Call:
## lm(formula = remesas ~ poly(t, 2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1039.5 -467.6 -122.2 296.9 1157.7
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4472.9 135.8 32.944 < 2e-16 ***
## poly(t, 2)1 7260.6 636.8 11.401 6.12e-10 ***
## poly(t, 2)2 1167.2 636.8 1.833 0.0826 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 636.8 on 19 degrees of freedom
## Multiple R-squared: 0.8753, Adjusted R-squared: 0.8622
## F-statistic: 66.67 on 2 and 19 DF, p-value: 2.578e-09
predicho2<-predict(modelo2);predicho2
## 1 2 3 4 5 6 7 8
## 2396.353 2501.672 2620.858 2753.912 2900.834 3061.623 3236.279 3424.803
## 9 10 11 12 13 14 15 16
## 3627.195 3843.454 4073.581 4317.576 4575.438 4847.167 5132.765 5432.229
## 17 18 19 20 21 22
## 5745.562 6072.761 6413.829 6768.764 7137.567 7520.237
plot(t,remesas,type="o",pch=16)
points(t,predicho2,pch=16,col="steelblue")
lines(predicho2,lwd=2,col="red")
residuos2<-resid(modelo2);residuos2
## 1 2 3 4 5 6
## -818.33341 -480.28212 -167.14840 306.18774 269.06631 252.10731
## 7 8 9 10 11 12
## 624.66073 1004.92658 1157.72486 246.82556 -77.24131 -253.47575
## 13 14 15 16 17 18
## -605.76777 -446.12736 -1039.55453 -474.82926 -598.09157 -289.05146
## 19 20 21 22
## 222.36108 317.76605 -228.72655 1077.00327
pronostico2<-predict(modelo2,nuevo);pronostico2
## 1 2 3 4 5
## 7916.774 8327.180 8751.453 9189.593 9641.601
AIC(modelo2)
## [1] 351.2944
modelo3<-lm(remesas~poly(t,3))
summary(modelo3)
##
## Call:
## lm(formula = remesas ~ poly(t, 3))
##
## Residuals:
## Min 1Q Median 3Q Max
## -655.93 -167.17 -18.24 161.30 745.51
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4472.9 76.3 58.626 < 2e-16 ***
## poly(t, 3)1 7260.6 357.9 20.289 7.52e-14 ***
## poly(t, 3)2 1167.2 357.9 3.262 0.00433 **
## poly(t, 3)3 2323.9 357.9 6.494 4.16e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 357.9 on 18 degrees of freedom
## Multiple R-squared: 0.9627, Adjusted R-squared: 0.9565
## F-statistic: 154.8 on 3 and 18 DF, p-value: 4.852e-13
predicho3<-predict(modelo3);predicho3
## 1 2 3 4 5 6 7 8
## 1399.537 2074.465 2620.858 3053.707 3388.000 3638.727 3820.878 3949.444
## 9 10 11 12 13 14 15 16
## 4039.412 4105.775 4163.520 4227.637 4313.118 4434.950 4608.124 4847.630
## 17 18 19 20 21 22
## 5168.457 5585.596 6114.035 6768.764 7564.774 8517.053
plot(t,remesas,type="o",pch=16)
points(t,predicho3,pch=16,col="steelblue")
lines(predicho3,lwd=2,col="red")
residuos3<-resid(modelo3);residuos3
## 1 2 3 4 5 6
## 178.482957 -53.075105 -167.148402 6.393346 -218.099582 -324.996904
## 7 8 9 10 11 12
## 40.061660 480.286389 745.507563 -15.494536 -167.179629 -163.537435
## 13 14 15 16 17 18
## -343.447675 -33.910068 -514.914333 109.769808 -20.987362 198.114435
## 19 20 21 22
## 522.155480 317.766053 -655.933565 80.186905
pronostico3<-predict(modelo3,nuevo);pronostico3
## 1 2 3 4 5
## 9640.592 10950.381 12461.408 14188.665 16147.140
AIC(modelo3)
## [1] 326.7445
modelo4<-nls(remesas~a*t^b,start=list(a=2,b=1))
summary(modelo4)
##
## Formula: remesas ~ a * t^b
##
## Parameters:
## Estimate Std. Error t value Pr(>|t|)
## a 1.186e+03 2.309e+02 5.135 5.05e-05 ***
## b 5.612e-01 7.256e-02 7.733 1.96e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 750.4 on 20 degrees of freedom
##
## Number of iterations to convergence: 9
## Achieved convergence tolerance: 4.537e-09
predicho4<-predict(modelo4);predicho4
## [1] 1185.812 1749.602 2196.610 2581.443 2925.793 3240.980 3533.813 3808.779
## [9] 4069.023 4316.850 4554.016 4781.890 5001.571 5213.950 5419.769 5619.648
## [17] 5814.115 6003.623 6188.564 6369.279 6546.071 6719.204
plot(t,remesas,type="o",pch=16)
points(t,predicho4,pch=16,col="steelblue")
lines(predicho4,lwd=2,col="red")
residuos4<-residuals(modelo4)
pronostico4 = predict(modelo4,data.frame(t=nuevo));pronostico4
## [1] 6888.917 7055.421 7218.907 7379.547 7537.498
AIC(modelo4)
## [1] 357.6405
t1<-log(t);t1
## [1] 0.0000000 0.6931472 1.0986123 1.3862944 1.6094379 1.7917595 1.9459101
## [8] 2.0794415 2.1972246 2.3025851 2.3978953 2.4849066 2.5649494 2.6390573
## [15] 2.7080502 2.7725887 2.8332133 2.8903718 2.9444390 2.9957323 3.0445224
## [22] 3.0910425
modelo5<-lm(remesas~t1)
summary(modelo5)
##
## Call:
## lm(formula = remesas ~ t1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1276.3 -551.0 -106.1 299.7 2547.4
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 559.6 573.9 0.975 0.341
## t1 1776.2 244.7 7.258 5.07e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 922 on 20 degrees of freedom
## Multiple R-squared: 0.7248, Adjusted R-squared: 0.711
## F-statistic: 52.68 on 1 and 20 DF, p-value: 5.071e-07
predicho5<-predict(modelo3);predicho5
## 1 2 3 4 5 6 7 8
## 1399.537 2074.465 2620.858 3053.707 3388.000 3638.727 3820.878 3949.444
## 9 10 11 12 13 14 15 16
## 4039.412 4105.775 4163.520 4227.637 4313.118 4434.950 4608.124 4847.630
## 17 18 19 20 21 22
## 5168.457 5585.596 6114.035 6768.764 7564.774 8517.053
plot(t,remesas,type="o",pch=16)
points(t,predicho5,pch=16,col="steelblue")
lines(predicho5,lwd=2,col="red")
residuos5<-residuals(modelo5)
pronostico5 = predict(modelo5,data.frame(t=nuevo));pronostico5
## Warning: 'newdata' had 5 rows but variables found have 22 rows
## 1 2 3 4 5 6 7 8
## 559.6276 1790.7690 2510.9406 3021.9105 3418.2495 3742.0820 4015.8786 4253.0519
## 9 10 11 12 13 14 15 16
## 4462.2536 4649.3909 4818.6772 4973.2235 5115.3922 5247.0200 5369.5625 5484.1933
## 17 18 19 20 21 22
## 5591.8725 5693.3950 5789.4272 5880.5323 5967.1916 6049.8186
AIC(modelo5)
## [1] 366.7061
modelo6<-nls(remesas~a*exp(b*t),start=list(a=20000,b=0.1))
summary(modelo6)
##
## Formula: remesas ~ a * exp(b * t)
##
## Parameters:
## Estimate Std. Error t value Pr(>|t|)
## a 2.178e+03 1.771e+02 12.30 8.78e-11 ***
## b 5.687e-02 4.899e-03 11.61 2.43e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 598.7 on 20 degrees of freedom
##
## Number of iterations to convergence: 6
## Achieved convergence tolerance: 2.662e-06
predicho6<-predict(modelo6);predicho6
## [1] 2305.650 2440.582 2583.410 2734.596 2894.631 3064.031 3243.344 3433.151
## [9] 3634.067 3846.740 4071.859 4310.153 4562.392 4829.393 5112.019 5411.185
## [17] 5727.859 6063.065 6417.889 6793.477 7191.046 7611.881
plot(t,remesas,type="o",pch=16)
points(t,predicho6,pch=16,col="steelblue")
lines(predicho6,lwd=2,col="red")
residuos6<-residuals(modelo6)
pronostico6 = predict(modelo6,data.frame(t=nuevo));pronostico6
## [1] 8057.344 8528.876 9028.004 9556.342 10115.599
AIC(modelo6)
## [1] 347.7045
modelo7<-nls(remesas~a+b/t,start=list(a=2,b=0.1))
summary(modelo7)
##
## Formula: remesas ~ a + b/t
##
## Parameters:
## Estimate Std. Error t value Pr(>|t|)
## a 5353.9 358.8 14.923 2.65e-12 ***
## b -5251.1 1330.2 -3.948 0.000795 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1318 on 20 degrees of freedom
##
## Number of iterations to convergence: 1
## Achieved convergence tolerance: 1.283e-07
predicho7<-predict(modelo7);predicho7
## [1] 102.7663 2728.3227 3603.5081 4041.1009 4303.6565 4478.6936 4603.7201
## [8] 4697.4900 4770.4221 4828.7678 4876.5052 4916.2863 4949.9473 4978.7996
## [15] 5003.8049 5025.6845 5044.9901 5062.1506 5077.5047 5091.3234 5103.8261
## [22] 5115.1921
plot(t,remesas,type="o",pch=16)
points(t,predicho7,pch=16,col="steelblue")
lines(predicho7,lwd=2,col="red")
resisiduos7<-residuals(modelo7)
pronostico7 = predict(modelo7,data.frame(t=nuevo));pronostico7
## [1] 5125.570 5135.083 5143.835 5151.913 5159.393
AIC(modelo7)
## [1] 382.4162
modelo8<-nls(remesas~exp(a+b/t),start=list(a=2,b=0.1))
summary(modelo8)
##
## Formula: remesas ~ exp(a + b/t)
##
## Parameters:
## Estimate Std. Error t value Pr(>|t|)
## a 8.86897 0.09292 95.444 < 2e-16 ***
## b -3.99898 0.96797 -4.131 0.000518 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1044 on 20 degrees of freedom
##
## Number of iterations to convergence: 16
## Achieved convergence tolerance: 5.473e-06
predicho8<-predict(modelo8);predicho8
## [1] 130.3195 962.4476 1874.2735 2615.5372 3194.4615 3649.9661 4014.5759
## [8] 4311.7424 4557.9980 4765.0909 4941.5101 5093.5054 5225.7628 5341.8562
## [15] 5444.5547 5536.0341 5618.0269 5691.9283 5758.8742 5819.7985 5875.4757
## [22] 5926.5534
plot(t,remesas,type="o",pch=16)
points(t,predicho8,pch=16,col="steelblue")
lines(predicho8,lwd=2,col="red")
residuos8<-residuals(modelo8)
pronostico8= predict(modelo8,data.frame(t=nuevo));pronostico8
## [1] 5973.577 6017.010 6057.247 6094.628 6129.445
AIC(modelo8)
## [1] 372.1636
modelo9<-lm(remesas~bs(t,knots = c(10,16)))
summary(modelo9)
##
## Call:
## lm(formula = remesas ~ bs(t, knots = c(10, 16)))
##
## Residuals:
## Min 1Q Median 3Q Max
## -760.35 -169.19 8.26 151.39 582.42
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1527.0 285.3 5.353 6.47e-05 ***
## bs(t, knots = c(10, 16))1 1608.2 630.4 2.551 0.02136 *
## bs(t, knots = c(10, 16))2 3365.4 477.9 7.042 2.78e-06 ***
## bs(t, knots = c(10, 16))3 2009.7 557.9 3.603 0.00239 **
## bs(t, knots = c(10, 16))4 5731.9 488.1 11.743 2.81e-09 ***
## bs(t, knots = c(10, 16))5 6685.0 423.7 15.779 3.57e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 334.7 on 16 degrees of freedom
## Multiple R-squared: 0.971, Adjusted R-squared: 0.9619
## F-statistic: 107.1 on 5 and 16 DF, p-value: 1.02e-11
predicho9<-predict(modelo9);predicho9
## 1 2 3 4 5 6 7 8
## 1526.974 2041.936 2512.357 2934.717 3305.499 3621.186 3878.260 4073.203
## 9 10 11 12 13 14 15 16
## 4202.499 4262.628 4257.885 4223.801 4203.719 4240.982 4378.932 4660.913
## 17 18 19 20 21 22
## 5113.633 5697.274 6355.382 7031.505 7669.190 8211.985
plot(t,remesas,type="o",pch=16)
points(t,predicho9,pch=16,col="steelblue")
lines(predicho9,lwd=2,col="red")
pronostico9 = predict(modelo9,nuevo);pronostico9
## Warning in bs(t, degree = 3L, knots = c(10, 16), Boundary.knots = c(1, 22: some
## 'x' values beyond boundary knots may cause ill-conditioned bases
## 1 2 3 4 5
## 8603.436 8787.091 8706.497 8305.202 7526.752
AIC(modelo9)
## [1] 325.209
modelo10 =svm(remesas~t)
summary(modelo10)
##
## Call:
## svm(formula = remesas ~ t)
##
##
## Parameters:
## SVM-Type: eps-regression
## SVM-Kernel: radial
## cost: 1
## gamma: 1
## epsilon: 0.1
##
##
## Number of Support Vectors: 15
W = t(modelo10$coefs) %*% modelo10$SV
b = modelo10$rho
predicho10<-predict(modelo10);predicho10
## 1 2 3 4 5 6 7 8
## 2055.695 2217.774 2508.257 2887.974 3302.017 3690.530 4001.163 4200.313
## 9 10 11 12 13 14 15 16
## 4280.514 4262.275 4189.881 4122.023 4119.128 4229.982 4480.455 4866.803
## 17 18 19 20 21 22
## 5355.248 5888.187 6395.805 6810.420 7080.030 7177.745
plot(t,remesas,type="o",pch=16)
points(t,predicho10,pch=16,col="steelblue")
lines(t,predicho10,pch=16,col="blue",lwd=2)
pronostico10 = predict(modelo10,nuevo);pronostico10
## 1 2 3 4 5
## 7104.974 6888.097 6570.208 6200.654 5825.297
modelo11<-ses(remesas)
plot(modelo11)
forecast(modelo11)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 23 8597.071 7821.813 9372.329 7411.416 9782.725
## 24 8597.071 7500.746 9693.396 6920.386 10273.755
## 25 8597.071 7254.375 9939.767 6543.594 10650.547
## 26 8597.071 7046.672 10147.470 6225.940 10968.201
## 27 8597.071 6863.681 10330.461 5946.079 11248.062
## 28 8597.071 6698.243 10495.898 5693.065 11501.077
## 29 8597.071 6546.108 10648.034 5460.393 11733.748
## 30 8597.071 6404.503 10789.639 5243.828 11950.314
## 31 8597.071 6271.505 10922.637 5040.424 12153.717
## 32 8597.071 6145.712 11048.430 4848.040 12346.101
points(1:length(remesas),fitted(modelo11),type="l",col="red")
modelo12<- ets(remesas)
summary(modelo12)
## ETS(M,A,N)
##
## Call:
## ets(y = remesas)
##
## Smoothing parameters:
## alpha = 0.9492
## beta = 1e-04
##
## Initial states:
## l = 1461.7115
## b = 302.0547
##
## sigma: 0.1031
##
## AIC AICc BIC
## 340.3365 344.0865 345.7917
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 20.21921 476.3231 365.2452 -0.717959 8.163698 0.7861757
## ACF1
## Training set -0.05512101
predicho12<-forecast(modelo12);predicho12
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 23 8830.117 7663.282 9996.952 7045.597 10614.64
## 24 9132.217 7490.193 10774.240 6620.958 11643.47
## 25 9434.316 7401.435 11467.196 6325.293 12543.34
## 26 9736.415 7354.303 12118.527 6093.289 13379.54
## 27 10038.514 7331.909 12745.120 5899.119 14177.91
## 28 10340.614 7325.600 13355.627 5729.548 14951.68
## 29 10642.713 7330.279 13955.147 5576.782 15708.64
## 30 10944.812 7342.663 14546.962 5435.800 16453.82
## 31 11246.912 7360.507 15133.316 5303.169 17190.65
## 32 11549.011 7382.201 15715.820 5176.426 17921.60
residuos12<-residuals(modelo12);residuos12
## Time Series:
## Start = 1
## End = 22
## Frequency = 1
## [1] -0.10531227 0.06980562 0.05912262 0.11324363 -0.05273747 -0.04803655
## [7] 0.06529705 0.06714757 0.01425260 -0.19540047 -0.10048352 -0.05945256
## [13] -0.09349626 0.02531514 -0.12862917 0.12012280 -0.01621301 0.06051472
## [19] 0.09347882 0.02564199 -0.06378433 0.18833134
plot(forecast(modelo12,h=5))
points(1:length(remesas),fitted(modelo12),type="l",col="red")
modelo13=auto.arima(remesas)
summary(modelo13)
## Series: remesas
## ARIMA(0,1,0) with drift
##
## Coefficients:
## drift
## 334.2486
## s.e. 106.1825
##
## sigma^2 = 248607: log likelihood = -159.73
## AIC=323.47 AICc=324.13 BIC=325.56
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.05653504 475.401 351.4481 -0.8644262 7.494596 0.7564779
## ACF1
## Training set -0.08432773
predicho13<-forecast(modelo13);predicho13
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 23 8931.489 8292.501 9570.476 7954.241 9908.736
## 24 9265.737 8362.072 10169.402 7883.701 10647.774
## 25 9599.986 8493.227 10706.745 7907.344 11292.628
## 26 9934.234 8656.259 11212.210 7979.740 11888.729
## 27 10268.483 8839.663 11697.303 8083.291 12453.674
## 28 10602.731 9037.538 12167.925 8208.974 12996.489
## 29 10936.980 9246.378 12627.582 8351.427 13522.533
## 30 11271.229 9463.898 13078.559 8507.156 14035.301
## 31 11605.477 9688.514 13522.440 8673.735 14537.219
## 32 11939.726 9919.069 13960.382 8849.398 15030.053
plot(forecast(modelo13,h=5))
points(1:length(remesas),fitted(modelo13),type="l",col="red")
modelo14 <- nnetar(remesas)
summary(modelo14)
## Length Class Mode
## x 22 ts numeric
## m 1 -none- numeric
## p 1 -none- numeric
## P 1 -none- numeric
## scalex 2 -none- list
## size 1 -none- numeric
## subset 22 -none- numeric
## model 20 nnetarmodels list
## nnetargs 0 -none- list
## fitted 22 ts numeric
## residuals 22 ts numeric
## lags 1 -none- numeric
## series 1 -none- character
## method 1 -none- character
## call 2 -none- call
predicho14<-predict(modelo14);predicho14
## Point Forecast
## 23 9363.091
## 24 10021.920
## 25 10502.073
## 26 10803.019
## 27 10971.733
## 28 11059.932
## 29 11104.276
## 30 11126.122
## 31 11136.775
## 32 11141.944
residuos14<-residuals(modelo14);residuos14
## Time Series:
## Start = 1
## End = 22
## Frequency = 1
## [1] NA -188.84160 -40.04167 255.95177 -127.80204 -80.61229
## [7] 336.68232 377.85459 133.31366 -958.27773 -291.50258 -126.08584
## [13] -290.81982 238.32861 -527.02546 666.48966 -98.96859 315.96787
## [19] 410.46231 -163.14784 -867.69742 1026.60299
plot(forecast(modelo14,h=5))
points(1:length(remesas),fitted(modelo14),type="l",col="red")
modelo15<-rwf(remesas,h=5)
summary(modelo15)
##
## Forecast method: Random walk
##
## Model Information:
## Call: rwf(y = remesas, h = 5)
##
## Residual sd: 590.3307
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 334.2486 590.3307 464.5848 7.249471 10.27848 1 -0.08437044
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 23 8597.24 7840.701 9353.779 7440.213 9754.267
## 24 8597.24 7527.332 9667.148 6960.957 10233.523
## 25 8597.24 7286.876 9907.604 6593.211 10601.269
## 26 8597.24 7084.162 10110.318 6283.186 10911.294
## 27 8597.24 6905.567 10288.913 6010.049 11184.431
predicho15<-forecast(modelo15);predicho15
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 23 8597.24 7840.701 9353.779 7440.213 9754.267
## 24 8597.24 7527.332 9667.148 6960.957 10233.523
## 25 8597.24 7286.876 9907.604 6593.211 10601.269
## 26 8597.24 7084.162 10110.318 6283.186 10911.294
## 27 8597.24 6905.567 10288.913 6010.049 11184.431
residuos15<-residuals(modelo15);residuos15
## Time Series:
## Start = 1
## End = 22
## Frequency = 1
## [1] NA 443.37 432.32 606.39 109.80 143.83 547.21 568.79 355.19
## [10] -694.64 -93.94 67.76 -94.43 431.37 -307.83 864.19 190.07 636.24
## [19] 852.48 450.34 -177.69 1688.40
plot(modelo15)
points(1:length(remesas),fitted(modelo15),type="l",col="red")
modelo16<-ar(remesas, aic = TRUE,order.max =1)
summary(modelo16)
## Length Class Mode
## order 1 -none- numeric
## ar 1 -none- numeric
## var.pred 1 -none- numeric
## x.mean 1 -none- numeric
## aic 2 -none- numeric
## n.used 1 -none- numeric
## n.obs 1 -none- numeric
## order.max 1 -none- numeric
## partialacf 1 -none- numeric
## resid 22 -none- numeric
## method 1 -none- character
## series 1 -none- character
## frequency 1 -none- numeric
## call 4 -none- call
## asy.var.coef 1 -none- numeric
predicho16<-predict(modelo16,n.ahead = 5);predicho16
## $pred
## Time Series:
## Start = 23
## End = 27
## Frequency = 1
## [1] 7505.537 6702.807 6112.560 5678.550 5359.423
##
## $se
## Time Series:
## Start = 23
## End = 27
## Frequency = 1
## [1] 1191.212 1478.576 1612.757 1680.849 1716.539
residuos16<-residuals(modelo16);residuos16
## [1] NA -322.91146 -216.60161 71.90331 -264.17551 -201.08149
## [7] 240.37025 406.79650 343.75498 -612.05638 -195.22729 -58.39317
## [13] -202.64713 298.15729 -326.85925 763.67828 318.30901 814.79045
## [19] 1199.44292 1022.95401 514.12882 2333.18435
plot(forecast(modelo16,h=5))
points(1:length(remesas),fitted(modelo16),type="l",col="red")
Paquetes utilizados: forecast, splines, e1071
|-|-|-|
O.M.F.
|-|-|-|