Integrantes del equipo:
Regina Enríquez Chapa A01721435
Maximiliano Carvajal A01552179
Guillermo Cazares Cruz A01283709
#install.packages("maps")
#install.packages("readr")
#install.packages("forecast")
#install.packages("ggplot2")
#install.packages("dplyr")
library(maps)
library(readr)
library(forecast)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
#Importación de base de datos
#green_go <- read_csv("/Users/reginaenriquez/Desktop/historical_state_population_by_year.csv")
green_go <- read_csv("D:/8vo semestre/historical_state_population_by_year.csv")
## Rows: 6020 Columns: 3
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (1): State
## dbl (2): Year, Population
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
colnames(green_go) <- c("State","Year","Population")
green_go
## # A tibble: 6,020 x 3
## State Year Population
## <chr> <dbl> <dbl>
## 1 AK 1950 135000
## 2 AK 1951 158000
## 3 AK 1952 189000
## 4 AK 1953 205000
## 5 AK 1954 215000
## 6 AK 1955 222000
## 7 AK 1956 224000
## 8 AK 1957 231000
## 9 AK 1958 224000
## 10 AK 1959 224000
## # i 6,010 more rows
Estados Seleccionados:
PA - Pensylvannia
IL - Illinois
OH - Ohio
NC - North Carolina
GA - Georgia
#Guardar solo los datos de Pennsylvania
PA <- subset(green_go, State == "PA")
#Crear la serie de tiempo, empezando desde 1900 hasta 2019, por año
ts_PA <- ts(data=PA$Population, start = c(1900,1), frequency = 1)
ts_PA
## Time Series:
## Start = 1900
## End = 2019
## Frequency = 1
## [1] 6313000 6439000 6567000 6699000 6833000 6970000 7110000 7253000
## [9] 7398000 7546000 7706000 7850000 7986000 8139000 8276000 8362000
## [17] 8463000 8578000 8524000 8643000 8740000 8900000 8982000 9148000
## [25] 9383000 9478000 9594000 9745000 9802000 9723000 9649000 9707000
## [33] 9764000 9784000 9795000 9774000 9767000 9790000 9952000 9901000
## [41] 9896000 9911000 9704000 9444000 9214000 9143000 9866000 10196000
## [49] 10287000 10390000 10507000 10461000 10503000 10662000 10817000 10939000
## [57] 10972000 10954000 11058000 11234000 11329000 11392000 11355000 11424000
## [65] 11519000 11620000 11664000 11681000 11741000 11741000 11800766 11886400
## [73] 11908233 11890527 11870884 11906095 11897378 11893591 11879396 11887975
## [81] 11868305 11858567 11845146 11837723 11815172 11770862 11782752 11810866
## [89] 11845752 11865996 11895604 11943160 11980819 12022128 12042545 12044780
## [97] 12038008 12015888 12002329 11994016 12284173 12298970 12331031 12374658
## [105] 12410722 12449990 12510809 12563937 12612285 12666858 12711160 12745815
## [113] 12767118 12776309 12788313 12784826 12782275 12787641 12800922 12801989
#Crear el modelo ARIMA para Pennsylvania
arima_PA <- auto.arima(ts_PA)
arima_PA
## Series: ts_PA
## ARIMA(0,2,2)
##
## Coefficients:
## ma1 ma2
## -0.5098 -0.4160
## s.e. 0.0797 0.0787
##
## sigma^2 = 8.94e+09: log likelihood = -1519.25
## AIC=3044.49 AICc=3044.7 BIC=3052.81
summary(arima_PA)
## Series: ts_PA
## ARIMA(0,2,2)
##
## Coefficients:
## ma1 ma2
## -0.5098 -0.4160
## s.e. 0.0797 0.0787
##
## sigma^2 = 8.94e+09: log likelihood = -1519.25
## AIC=3044.49 AICc=3044.7 BIC=3052.81
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -11297.47 92964.68 48959.44 -0.1096944 0.4757895 0.6274881
## ACF1
## Training set 0.007469667
#Pronosticar la población durante las siguientes décadas, hasta 2070
pronostico_PA <- forecast(arima_PA, level=c(95), h=51)
pronostico_PA
## Point Forecast Lo 95 Hi 95
## 2020 12818547 12633225 13003870
## 2021 12844768 12512190 13177346
## 2022 12870989 12429792 13312185
## 2023 12897209 12361614 13432804
## 2024 12923430 12300848 13546011
## 2025 12949651 12244476 13654825
## 2026 12975871 12190869 13760873
## 2027 13002092 12139040 13865144
## 2028 13028312 12088344 13968281
## 2029 13054533 12038338 14070728
## 2030 13080754 11988706 14172802
## 2031 13106974 11939211 14274738
## 2032 13133195 11889677 14376714
## 2033 13159416 11839967 14478865
## 2034 13185636 11789974 14581298
## 2035 13211857 11739615 14684099
## 2036 13238078 11688821 14787334
## 2037 13264298 11637538 14891058
## 2038 13290519 11585722 14995316
## 2039 13316740 11533336 15100143
## 2040 13342960 11480352 15205568
## 2041 13369181 11426745 15311616
## 2042 13395402 11372496 15418307
## 2043 13421622 11317588 15525656
## 2044 13447843 11262009 15633677
## 2045 13474064 11205747 15742380
## 2046 13500284 11148794 15851775
## 2047 13526505 11091143 15961867
## 2048 13552725 11032789 16072662
## 2049 13578946 10973728 16184164
## 2050 13605167 10913957 16296377
## 2051 13631387 10853473 16409302
## 2052 13657608 10792276 16522940
## 2053 13683829 10730365 16637293
## 2054 13710049 10667739 16752360
## 2055 13736270 10604399 16868141
## 2056 13762491 10540347 16984635
## 2057 13788711 10475582 17101841
## 2058 13814932 10410107 17219756
## 2059 13841153 10343924 17338381
## 2060 13867373 10277035 17457712
## 2061 13893594 10209441 17577746
## 2062 13919815 10141146 17698483
## 2063 13946035 10072152 17819919
## 2064 13972256 10002461 17942051
## 2065 13998477 9932077 18064876
## 2066 14024697 9861001 18188393
## 2067 14050918 9789238 18312597
## 2068 14077138 9716790 18437486
## 2069 14103359 9643661 18563057
## 2070 14129580 9569853 18689307
plot(pronostico_PA)
#Guardar la población de 2030, 2040, 2050, 2060, 2070
PopPA <- pronostico_PA$mean[c(11,21,31,41,51)]
#Guardar solo los datos de Illinois
IL <- subset(green_go, State == "IL")
#Crear la serie de tiempo, empezando desde 1900 hasta 2019, por año
ts_IL <- ts(data=IL$Population, start = c(1900,1), frequency = 1)
ts_IL
## Time Series:
## Start = 1900
## End = 2019
## Frequency = 1
## [1] 4828000 4914000 4992000 5071000 5161000 5241000 5309000 5384000
## [9] 5474000 5567000 5668000 5757000 5828000 5961000 6109000 6194000
## [17] 6274000 6313000 6275000 6392000 6663000 6858000 6958000 7068000
## [25] 7215000 7306000 7395000 7519000 7576000 7606000 7644000 7687000
## [33] 7736000 7768000 7772000 7797000 7840000 7857000 7866000 7890000
## [41] 7905000 7995000 8057000 7761000 7719000 7601000 8155000 8341000
## [49] 8552000 8670000 8738000 8790000 8956000 9065000 9252000 9435000
## [57] 9530000 9668000 9886000 9986000 10086000 10130000 10280000 10402000
## [65] 10580000 10693000 10836000 10947000 10995000 11039000 11110285 11202397
## [73] 11251948 11251367 11262145 11291743 11342853 11386316 11412561 11396837
## [81] 11434702 11443458 11423412 11408818 11412132 11399806 11387257 11391178
## [89] 11390183 11409782 11446979 11535973 11635197 11725984 11804986 11884935
## [97] 11953003 12011509 12069774 12128370 12434161 12488445 12525556 12556006
## [105] 12589773 12609903 12643955 12695866 12747038 12796778 12840503 12867454
## [113] 12882510 12895129 12884493 12858913 12820527 12778828 12723071 12671821
#Crear el modelo ARIMA para Illinois
arima_IL <- auto.arima(ts_IL)
arima_IL
## Series: ts_IL
## ARIMA(3,2,1)
##
## Coefficients:
## ar1 ar2 ar3 ma1
## 0.0790 0.0424 -0.3400 -0.7050
## s.e. 0.1186 0.1000 0.0925 0.1044
##
## sigma^2 = 6.155e+09: log likelihood = -1495.86
## AIC=3001.72 AICc=3002.26 BIC=3015.58
summary(arima_IL)
## Series: ts_IL
## ARIMA(3,2,1)
##
## Coefficients:
## ar1 ar2 ar3 ma1
## 0.0790 0.0424 -0.3400 -0.7050
## s.e. 0.1186 0.1000 0.0925 0.1044
##
## sigma^2 = 6.155e+09: log likelihood = -1495.86
## AIC=3001.72 AICc=3002.26 BIC=3015.58
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -3927.761 76468.62 43652.01 -0.02872944 0.4920267 0.5507371
## ACF1
## Training set -0.0177474
#Pronosticar la población durante las siguientes décadas, hasta 2070
pronostico_IL <- forecast(arima_IL, level=c(95), h=51)
pronostico_IL
## Point Forecast Lo 95 Hi 95
## 2020 12643893 12490124 12797662
## 2021 12622778 12361459 12884098
## 2022 12601658 12227546 12975771
## 2023 12572899 12112870 13032927
## 2024 12541218 11994239 13088198
## 2025 12508985 11873087 13144884
## 2026 12479182 11741896 13216467
## 2027 12450540 11604989 13296091
## 2028 12422281 11462097 13382465
## 2029 12393275 11315874 13470676
## 2030 12363832 11165502 13562162
## 2031 12334192 11011347 13657038
## 2032 12304772 10852824 13756720
## 2033 12275510 10690286 13860735
## 2034 12246337 10523755 13968919
## 2035 12217102 10353550 14080654
## 2036 12187813 10179715 14195910
## 2037 12158486 10002376 14314597
## 2038 12129176 9821553 14436799
## 2039 12099883 9637336 14562430
## 2040 12070605 9449785 14691425
## 2041 12041324 9258986 14823662
## 2042 12012037 9065000 14959074
## 2043 11982744 8867892 15097596
## 2044 11953452 8667715 15239189
## 2045 11924162 8464524 15383800
## 2046 11894873 8258367 15531379
## 2047 11865585 8049296 15681874
## 2048 11836296 7837357 15835235
## 2049 11807007 7622594 15991419
## 2050 11777717 7405050 16150384
## 2051 11748427 7184765 16312090
## 2052 11719138 6961778 16476498
## 2053 11689849 6736126 16643572
## 2054 11660560 6507845 16813275
## 2055 11631270 6276969 16985572
## 2056 11601981 6043530 17160432
## 2057 11572692 5807562 17337822
## 2058 11543403 5569094 17517711
## 2059 11514113 5328156 17700071
## 2060 11484824 5084776 17884872
## 2061 11455535 4838982 18072087
## 2062 11426245 4590801 18261690
## 2063 11396956 4340258 18453654
## 2064 11367667 4087378 18647955
## 2065 11338377 3832186 18844569
## 2066 11309088 3574705 19043471
## 2067 11279799 3314957 19244641
## 2068 11250510 3052965 19448054
## 2069 11221220 2788750 19653691
## 2070 11191931 2522333 19861529
plot(pronostico_IL)
#Guardar la población de 2030, 2040, 2050, 2060, 2070
PopIL <- pronostico_IL$mean[c(11,21,31,41,51)]
#Guardar solo los datos de Ohio
OH <- subset(green_go, State == "OH")
#Crear la serie de tiempo, empezando desde 1900 hasta 2019, por año
ts_OH <- ts(data=OH$Population, start = c(1900,1), frequency = 1)
ts_OH
## Time Series:
## Start = 1900
## End = 2019
## Frequency = 1
## [1] 4161000 4216000 4322000 4386000 4458000 4530000 4587000 4630000
## [9] 4677000 4701000 4786000 4821000 4893000 4997000 5109000 5251000
## [17] 5366000 5510000 5547000 5683000 5799000 5921000 6054000 6183000
## [25] 6319000 6434000 6504000 6577000 6608000 6626000 6662000 6694000
## [33] 6717000 6740000 6751000 6787000 6801000 6809000 6837000 6886000
## [41] 6929000 6958000 6969000 6868000 6918000 6916000 7512000 7705000
## [49] 7876000 7973000 7980000 8061000 8275000 8591000 8873000 9017000
## [57] 9207000 9410000 9599000 9671000 9734000 9854000 9929000 9986000
## [65] 10080000 10201000 10330000 10414000 10516000 10563000 10657423 10734818
## [73] 10746993 10767314 10765759 10770425 10752662 10771394 10795581 10798298
## [81] 10800650 10788330 10757087 10737632 10737746 10734926 10730268 10760090
## [89] 10798552 10829217 10861837 10933683 11007609 11070385 11111451 11155493
## [97] 11187032 11212498 11237752 11256654 11363543 11387404 11407889 11434788
## [105] 11452251 11463320 11481213 11500468 11515391 11528896 11539336 11544663
## [113] 11548923 11576684 11602700 11617527 11634370 11659650 11676341 11689100
#Crear el modelo ARIMA para Ohio
arima_OH <- auto.arima(ts_OH)
arima_OH
## Series: ts_OH
## ARIMA(3,2,2)
##
## Coefficients:
## ar1 ar2 ar3 ma1 ma2
## 0.6508 -0.0937 -0.3696 -1.2446 0.5125
## s.e. 0.3045 0.1325 0.0988 0.3349 0.2599
##
## sigma^2 = 4.363e+09: log likelihood = -1474.97
## AIC=2961.94 AICc=2962.7 BIC=2978.56
summary(arima_OH)
## Series: ts_OH
## ARIMA(3,2,2)
##
## Coefficients:
## ar1 ar2 ar3 ma1 ma2
## 0.6508 -0.0937 -0.3696 -1.2446 0.5125
## s.e. 0.3045 0.1325 0.0988 0.3349 0.2599
##
## sigma^2 = 4.363e+09: log likelihood = -1474.97
## AIC=2961.94 AICc=2962.7 BIC=2978.56
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -1236.664 64095.18 33364.11 0.0004268429 0.4295383 0.5017015
## ACF1
## Training set -0.002722796
#Pronosticar la población durante las siguientes décadas, hasta 2070
pronostico_OH <- forecast(arima_OH, level=c(95), h=51)
pronostico_OH
## Point Forecast Lo 95 Hi 95
## 2020 11704481 11575025 11833938
## 2021 11721498 11498120 11944876
## 2022 11740786 11413787 12067785
## 2023 11760429 11344110 12176749
## 2024 11779487 11277839 12281135
## 2025 11797291 11209546 12385037
## 2026 11814203 11130618 12497788
## 2027 11830868 11038385 12623350
## 2028 11847919 10933810 12762028
## 2029 11865574 10821160 12909988
## 2030 11883678 10704300 13063055
## 2031 11901874 10585186 13218562
## 2032 11919865 10463540 13376189
## 2033 11937548 10337977 13537119
## 2034 11955015 10207143 13702888
## 2035 11972448 10070493 13874403
## 2036 11989991 9928364 14051618
## 2037 12007689 9781585 14233793
## 2038 12025491 9630942 14420040
## 2039 12043305 9476833 14609777
## 2040 12061059 9319244 14802874
## 2041 12078736 9157941 14999531
## 2042 12096363 8992708 15200017
## 2043 12113986 8823500 15404473
## 2044 12131642 8650448 15612835
## 2045 12149336 8473775 15824898
## 2046 12167054 8293679 16040429
## 2047 12184772 8110275 16259269
## 2048 12202474 7923590 16481358
## 2049 12220156 7733606 16706706
## 2050 12237827 7540315 16935339
## 2051 12255498 7343746 17167251
## 2052 12273178 7143963 17402393
## 2053 12290868 6941048 17640688
## 2054 12308563 6735073 17882054
## 2055 12326258 6526087 18126429
## 2056 12343948 6314123 18373772
## 2057 12361633 6099203 18624063
## 2058 12379316 5881352 18877279
## 2059 12396999 5660601 19133396
## 2060 12414684 5436991 19392378
## 2061 12432372 5210562 19654182
## 2062 12450061 4981353 19918769
## 2063 12467750 4749397 20186103
## 2064 12485438 4514721 20456154
## 2065 12503124 4277350 20728898
## 2066 12520810 4037310 21004309
## 2067 12538496 3794628 21282363
## 2068 12556182 3549332 21563033
## 2069 12573869 3301449 21846290
## 2070 12591557 3051005 22132108
plot(pronostico_OH)
#Guardar la población de 2030, 2040, 2050, 2060, 2070
PopOH <- pronostico_OH$mean[c(11,21,31,41,51)]
#Guardar solo los datos de North Carolina
NC <- subset(green_go, State == "NC")
#Crear la serie de tiempo, empezando desde 1900 hasta 2019, por año
ts_NC <- ts(data=NC$Population, start = c(1900,1), frequency = 1)
ts_NC
## Time Series:
## Start = 1900
## End = 2019
## Frequency = 1
## [1] 1897000 1926000 1956000 1986000 2017000 2051000 2077000 2105000
## [9] 2142000 2174000 2221000 2276000 2313000 2362000 2421000 2473000
## [17] 2513000 2546000 2522000 2535000 2588000 2651000 2700000 2761000
## [25] 2830000 2895000 2959000 3027000 3082000 3133000 3167000 3184000
## [33] 3227000 3268000 3304000 3323000 3346000 3385000 3440000 3514000
## [41] 3574000 3589000 3569000 3654000 3560000 3533000 3706000 3769000
## [49] 3837000 3911000 4068000 4120000 4109000 4120000 4131000 4242000
## [57] 4309000 4368000 4376000 4458000 4573000 4663000 4707000 4742000
## [65] 4802000 4863000 4896000 4952000 5004000 5031000 5084411 5203531
## [73] 5301150 5389852 5470911 5547188 5607964 5685607 5759492 5823491
## [81] 5898980 5956653 6019101 6077056 6164006 6253954 6321578 6403700
## [89] 6480594 6565459 6656987 6748135 6831850 6947412 7060959 7185403
## [97] 7307658 7428672 7545828 7650789 8081614 8210122 8326201 8422501
## [105] 8553152 8705407 8917270 9118037 9309449 9449566 9574323 9657592
## [113] 9749476 9843336 9932887 10031646 10154788 10268233 10381615 10488084
#Crear el modelo ARIMA para North Carolina
arima_NC <- auto.arima(ts_NC)
arima_NC
## Series: ts_NC
## ARIMA(0,2,2)
##
## Coefficients:
## ma1 ma2
## -0.7066 -0.1454
## s.e. 0.0928 0.0920
##
## sigma^2 = 2.134e+09: log likelihood = -1434.41
## AIC=2874.83 AICc=2875.04 BIC=2883.14
summary(arima_NC)
## Series: ts_NC
## ARIMA(0,2,2)
##
## Coefficients:
## ma1 ma2
## -0.7066 -0.1454
## s.e. 0.0928 0.0920
##
## sigma^2 = 2.134e+09: log likelihood = -1434.41
## AIC=2874.83 AICc=2875.04 BIC=2883.14
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 4905.901 45417.83 25061.71 0.09923176 0.5388346 0.3334805
## ACF1
## Training set -0.0222108
#Pronosticar la población durante las siguientes décadas, hasta 2070
pronostico_NC <- forecast(arima_NC, level=c(95), h=51)
pronostico_NC
## Point Forecast Lo 95 Hi 95
## 2020 10604382 10513843 10694921
## 2021 10722519 10574498 10870540
## 2022 10840655 10643321 11037990
## 2023 10958792 10714560 11203024
## 2024 11076929 10786423 11367435
## 2025 11195065 10858117 11532013
## 2026 11313202 10929237 11697167
## 2027 11431338 10999554 11863123
## 2028 11549475 11068934 12030016
## 2029 11667612 11137296 12197927
## 2030 11785748 11204594 12366902
## 2031 11903885 11270800 12536970
## 2032 12022021 11335900 12708143
## 2033 12140158 11399889 12880426
## 2034 12258294 11462769 13053820
## 2035 12376431 11524544 13228318
## 2036 12494568 11585223 13403912
## 2037 12612704 11644814 13580594
## 2038 12730841 11703330 13758351
## 2039 12848977 11760782 13937173
## 2040 12967114 11817182 14117046
## 2041 13085250 11872543 14297958
## 2042 13203387 11926877 14479897
## 2043 13321524 11980197 14662850
## 2044 13439660 12032516 14846804
## 2045 13557797 12083846 15031748
## 2046 13675933 12134198 15217669
## 2047 13794070 12183586 15404554
## 2048 13912207 12232019 15592394
## 2049 14030343 12279511 15781175
## 2050 14148480 12326071 15970888
## 2051 14266616 12371711 16161522
## 2052 14384753 12416441 16353065
## 2053 14502889 12460271 16545508
## 2054 14621026 12503211 16738841
## 2055 14739163 12545270 16933055
## 2056 14857299 12586459 17128139
## 2057 14975436 12626787 17324085
## 2058 15093572 12666261 17520884
## 2059 15211709 12704891 17718527
## 2060 15329845 12742686 17917005
## 2061 15447982 12779652 18116312
## 2062 15566119 12815800 18316438
## 2063 15684255 12851135 18517375
## 2064 15802392 12885666 18719117
## 2065 15920528 12919400 18921656
## 2066 16038665 12952345 19124985
## 2067 16156802 12984507 19329096
## 2068 16274938 13015893 19533984
## 2069 16393075 13046509 19739640
## 2070 16511211 13076364 19946059
plot(pronostico_NC)
#Guardar la población de 2030, 2040, 2050, 2060, 2070
PopNC <- pronostico_NC$mean[c(11,21,31,41,51)]
#Guardar solo los datos de Georgia
GA <- subset(green_go, State == "GA")
#Crear la serie de tiempo, empezando desde 1900 hasta 2019, por año
ts_GA <- ts(data=GA$Population, start = c(1900,1), frequency = 1)
ts_GA
## Time Series:
## Start = 1900
## End = 2019
## Frequency = 1
## [1] 2220000 2263000 2305000 2346000 2387000 2427000 2466000 2505000
## [9] 2543000 2580000 2618000 2644000 2676000 2733000 2776000 2810000
## [17] 2856000 2885000 2941000 2870000 2926000 2965000 2965000 2954000
## [25] 2920000 2883000 2869000 2891000 2903000 2903000 2910000 2924000
## [33] 2935000 2950000 2964000 2955000 2978000 3037000 3091000 3120000
## [41] 3119000 3179000 3209000 3245000 3176000 3119000 3242000 3272000
## [49] 3259000 3325000 3458000 3531000 3584000 3558000 3602000 3636000
## [57] 3701000 3766000 3804000 3868000 3956000 4015000 4086000 4172000
## [65] 4258000 4332000 4379000 4408000 4482000 4551000 4587930 4711550
## [73] 4809490 4910374 4999419 5064075 5132812 5219697 5295751 5401384
## [81] 5486174 5568345 5649792 5728250 5834954 5962661 6084666 6208467
## [89] 6316142 6411099 6506531 6621279 6759474 6894092 7045900 7188538
## [97] 7332225 7486094 7636522 7788240 8227303 8377038 8508256 8622793
## [105] 8769252 8925922 9155813 9349988 9504843 9620846 9711881 9802431
## [113] 9901430 9972479 10067278 10178447 10301890 10410330 10511131 10617423
#Crear el modelo ARIMA para Georgia
arima_GA <- auto.arima(ts_GA)
arima_GA
## Series: ts_GA
## ARIMA(0,2,1)
##
## Coefficients:
## ma1
## -0.7683
## s.e. 0.0599
##
## sigma^2 = 1.943e+09: log likelihood = -1429.24
## AIC=2862.48 AICc=2862.58 BIC=2868.02
summary(arima_GA)
## Series: ts_GA
## ARIMA(0,2,1)
##
## Coefficients:
## ma1
## -0.7683
## s.e. 0.0599
##
## sigma^2 = 1.943e+09: log likelihood = -1429.24
## AIC=2862.48 AICc=2862.58 BIC=2868.02
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 2364.619 43524.82 25511.15 0.0491154 0.5731293 0.3342898
## ACF1
## Training set 0.08456536
#Pronosticar la población durante las siguientes décadas, hasta 2070
pronostico_GA <- forecast(arima_GA, level=c(95), h=51)
pronostico_GA
## Point Forecast Lo 95 Hi 95
## 2020 10725727 10639333 10812121
## 2021 10834031 10696967 10971094
## 2022 10942335 10755872 11128798
## 2023 11050639 10813550 11287727
## 2024 11158942 10869260 11448624
## 2025 11267246 10922742 11611750
## 2026 11375550 10973911 11777189
## 2027 11483854 11022758 11944951
## 2028 11592158 11069308 12115008
## 2029 11700462 11113605 12287319
## 2030 11808766 11155698 12461834
## 2031 11917070 11195638 12638502
## 2032 12025374 11233477 12817270
## 2033 12133677 11269266 12998089
## 2034 12241981 11303052 13180910
## 2035 12350285 11334883 13365687
## 2036 12458589 11364803 13552375
## 2037 12566893 11392852 13740933
## 2038 12675197 11419072 13931322
## 2039 12783501 11443498 14123504
## 2040 12891805 11466167 14317442
## 2041 13000108 11487112 14513105
## 2042 13108412 11506365 14710459
## 2043 13216716 11523957 14909475
## 2044 13325020 11539917 15110123
## 2045 13433324 11554272 15312376
## 2046 13541628 11567048 15516208
## 2047 13649932 11578270 15721594
## 2048 13758236 11587963 15928509
## 2049 13866540 11596148 16136931
## 2050 13974843 11602849 16346838
## 2051 14083147 11608087 16558208
## 2052 14191451 11611880 16771022
## 2053 14299755 11614249 16985261
## 2054 14408059 11615213 17200905
## 2055 14516363 11614789 17417937
## 2056 14624667 11612995 17636339
## 2057 14732971 11609847 17856094
## 2058 14841275 11605362 18077187
## 2059 14949578 11599554 18299603
## 2060 15057882 11592440 18523325
## 2061 15166186 11584033 18748339
## 2062 15274490 11574348 18974632
## 2063 15382794 11563398 19202190
## 2064 15491098 11551196 19431000
## 2065 15599402 11537755 19661048
## 2066 15707706 11523088 19892323
## 2067 15816009 11507207 20124812
## 2068 15924313 11490123 20358504
## 2069 16032617 11471848 20593387
## 2070 16140921 11452392 20829450
plot(pronostico_GA)
#Guardar la población de 2030, 2040, 2050, 2060, 2070
PopGA <- pronostico_GA$mean[c(11,21,31,41,51)]
#Cargar librerías
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
#Pronóstico de población para las siguientes 5 décadas en una base datos
Population_forecast <- data.frame(region = c("pennsylvania","illinois","ohio","north carolina","georgia"),
D2030 = c(PopPA[1], PopIL[1], PopOH[1], PopNC[1], PopGA[1]),
D2040 = c(PopPA[2], PopIL[2], PopOH[2], PopNC[2], PopGA[2]),
D2050 = c(PopPA[3], PopIL[3], PopOH[3], PopNC[3], PopGA[3]),
D2060 = c(PopPA[4], PopIL[4], PopOH[4], PopNC[4], PopGA[4]),
D2070 = c(PopPA[5], PopIL[5], PopOH[5], PopNC[5], PopGA[5]))
Population_forecast
## region D2030 D2040 D2050 D2060 D2070
## 1 pennsylvania 13080754 13342960 13605167 13867373 14129580
## 2 illinois 12363832 12070605 11777717 11484824 11191931
## 3 ohio 11883678 12061059 12237827 12414684 12591557
## 4 north carolina 11785748 12967114 14148480 15329845 16511211
## 5 georgia 11808766 12891805 13974843 15057882 16140921
#Juntar la base del mapa con la de los pronósticos de la población
usa <- map_data("state")
mapas <- left_join(usa, Population_forecast, by = "region")
#Décadas 2030, 2040, 2050, 2060, 2070
ggplot(data = mapas) +
geom_polygon(aes(x = long, y = lat, fill = D2030, group = group), color = "white") +
coord_fixed(1.3) +
scale_fill_gradient(low = "red", high = "green") +
ggtitle("Población 2030")
ggplot(data = mapas) +
geom_polygon(aes(x = long, y = lat, fill = D2040, group = group), color = "white") +
coord_fixed(1.3) +
scale_fill_gradient(low = "red", high = "green") +
ggtitle("Población 2040")
ggplot(data = mapas) +
geom_polygon(aes(x = long, y = lat, fill = D2050, group = group), color = "white") +
coord_fixed(1.3) +
scale_fill_gradient(low = "red", high = "green") +
ggtitle("Población 2050")
ggplot(data = mapas) +
geom_polygon(aes(x = long, y = lat, fill = D2060, group = group), color = "white") +
coord_fixed(1.3) +
scale_fill_gradient(low = "red", high = "green") +
ggtitle("Población 2060")
ggplot(data = mapas) +
geom_polygon(aes(x = long, y = lat, fill = D2070, group = group), color = "white") +
coord_fixed(1.3) +
scale_fill_gradient(low = "red", high = "green") +
ggtitle("Población 2070")
Se puede observar cómo dentro de la primera década Pennsylvania lidera entre los 5 estados. Sin embargo, conforme pasan los años los estados de North Carolina y Georgia lo sobrepasan, volviéndose éstos los más poblados. Por otro lado, el estado de Illinois comienza siendo el segundo estado con mayor población, pero va decrementando hasta convertirse en el estado con menos población. Por último, el estado de Ohio mantiene su posición como uno de los estados con menor población durante los años.