library(readr)
poblacion <- read_csv("C:/Users/melis/Downloads/Poblacion.csv")
## Rows: 6020 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): State
## dbl (2): Date, Population
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#View(poblacion)
#install.packages("tidyverse")
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ purrr 1.0.2
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
#install.packages("forecast")
library(forecast)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
poblacion_ma <- poblacion %>% filter(State == "MA")
ts_ma <- ts(poblacion_ma$Population, start =1900, frequency = 1)
ts_ma
## Time Series:
## Start = 1900
## End = 2019
## Frequency = 1
## [1] 2788000 2794000 2856000 2924000 2969000 3018000 3107000 3183000 3251000
## [10] 3316000 3365000 3383000 3440000 3534000 3636000 3705000 3726000 3738000
## [19] 3695000 3785000 3882000 3951000 4010000 4057000 4102000 4154000 4194000
## [28] 4223000 4217000 4229000 4250000 4248000 4259000 4282000 4305000 4343000
## [37] 4355000 4358000 4365000 4347000 4318000 4389000 4370000 4257000 4192000
## [46] 4201000 4494000 4580000 4674000 4741000 4686000 4654000 4650000 4806000
## [55] 4910000 4882000 4891000 4929000 5010000 5117000 5160000 5219000 5263000
## [64] 5344000 5448000 5502000 5535000 5594000 5618000 5650000 5689170 5737580
## [73] 5760302 5781172 5773548 5757756 5743672 5738199 5736469 5738404 5746075
## [82] 5768685 5771222 5799407 5840773 5880733 5902678 5935204 5979982 6015478
## [91] 6018664 5998652 5993474 6010884 6031352 6062335 6085393 6115476 6144407
## [100] 6175169 6361104 6397634 6417206 6422565 6412281 6403290 6410084 6431559
## [109] 6468967 6517613 6566307 6613583 6663005 6713315 6762596 6794228 6823608
## [118] 6859789 6882635 6892503
arima_ma <- auto.arima(ts_ma)
arima_ma
## Series: ts_ma
## ARIMA(0,1,1) with drift
##
## Coefficients:
## ma1 drift
## 0.4026 34308.594
## s.e. 0.0838 5577.936
##
## sigma^2 = 1.923e+09: log likelihood = -1439.88
## AIC=2885.77 AICc=2885.98 BIC=2894.1
summary(arima_ma)
## Series: ts_ma
## ARIMA(0,1,1) with drift
##
## Coefficients:
## ma1 drift
## 0.4026 34308.594
## s.e. 0.0838 5577.936
##
## sigma^2 = 1.923e+09: log likelihood = -1439.88
## AIC=2885.77 AICc=2885.98 BIC=2894.1
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 111.988 43304.41 26800.86 0.02741526 0.5808001 0.6240271
## ACF1
## Training set 0.01917487
pronostico_ma <- forecast(arima_ma, level = c(95),h=51)
pronostico_ma
## Point Forecast Lo 95 Hi 95
## 2020 6919008 6833052 7004965
## 2021 6953317 6805247 7101387
## 2022 6987625 6796678 7178573
## 2023 7021934 6796108 7247760
## 2024 7056243 6800248 7312238
## 2025 7090551 6807585 7373517
## 2026 7124860 6817279 7432440
## 2027 7159168 6828802 7489535
## 2028 7193477 6841798 7545156
## 2029 7227786 6856013 7599558
## 2030 7262094 6871261 7652928
## 2031 7296403 6887395 7705410
## 2032 7330711 6904304 7757119
## 2033 7365020 6921895 7808145
## 2034 7399329 6940095 7858562
## 2035 7433637 6958840 7908434
## 2036 7467946 6978080 7957811
## 2037 7502254 6997770 8006739
## 2038 7536563 7017872 8055254
## 2039 7570872 7038352 8103391
## 2040 7605180 7059183 8151177
## 2041 7639489 7080338 8198639
## 2042 7673797 7101796 8245799
## 2043 7708106 7123536 8292676
## 2044 7742414 7145541 8339288
## 2045 7776723 7167794 8385652
## 2046 7811032 7190282 8431782
## 2047 7845340 7212990 8477690
## 2048 7879649 7235908 8523390
## 2049 7913957 7259023 8568892
## 2050 7948266 7282327 8614205
## 2051 7982575 7305809 8659340
## 2052 8016883 7329462 8704304
## 2053 8051192 7353278 8749106
## 2054 8085500 7377249 8793752
## 2055 8119809 7401369 8838249
## 2056 8154118 7425631 8882604
## 2057 8188426 7450030 8926822
## 2058 8222735 7474560 8970909
## 2059 8257043 7499217 9014870
## 2060 8291352 7523994 9058710
## 2061 8325661 7548889 9102432
## 2062 8359969 7573897 9146042
## 2063 8394278 7599013 9189543
## 2064 8428586 7624234 9232939
## 2065 8462895 7649557 9276233
## 2066 8497204 7674978 9319429
## 2067 8531512 7700494 9362530
## 2068 8565821 7726102 9405539
## 2069 8600129 7751799 9448459
## 2070 8634438 7777583 9491293
plot(pronostico_ma, main="Población Massachusetts")
poblacion_nv <- poblacion %>% filter(State == "NV")
ts_nv <- ts(poblacion_nv$Population, start =1900, frequency = 1)
ts_nv
## Time Series:
## Start = 1900
## End = 2019
## Frequency = 1
## [1] 43000 45000 49000 52000 56000 59000 64000 68000 73000
## [10] 78000 82000 81000 81000 82000 83000 82000 82000 81000
## [19] 77000 77000 78000 80000 81000 82000 84000 85000 87000
## [28] 88000 89000 90000 92000 94000 96000 96000 98000 100000
## [37] 101000 103000 105000 107000 113000 120000 137000 151000 153000
## [46] 149000 143000 149000 156000 157000 162000 168000 181000 195000
## [55] 213000 237000 250000 260000 269000 279000 291000 315000 352000
## [64] 397000 426000 444000 446000 449000 464000 480000 488738 520018
## [73] 546789 568991 596822 619972 646975 678333 719436 765367 810215
## [82] 847655 881537 901977 924922 951030 980613 1023376 1075022 1137382
## [91] 1218629 1285046 1330694 1380197 1456388 1525777 1596476 1675581 1743772
## [100] 1809253 2018741 2098399 2173791 2248850 2346222 2432143 2522658 2601072
## [109] 2653630 2684665 2702405 2712730 2743996 2775970 2817628 2866939 2917563
## [118] 2969905 3027341 3080156
arima_nv <- auto.arima(ts_nv)
arima_nv
## Series: ts_nv
## ARIMA(0,2,1)
##
## Coefficients:
## ma1
## -0.5476
## s.e. 0.0879
##
## sigma^2 = 312757986: log likelihood = -1321.21
## AIC=2646.41 AICc=2646.52 BIC=2651.95
summary(arima_nv)
## Series: ts_nv
## ARIMA(0,2,1)
##
## Coefficients:
## ma1
## -0.5476
## s.e. 0.0879
##
## sigma^2 = 312757986: log likelihood = -1321.21
## AIC=2646.41 AICc=2646.52 BIC=2651.95
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 927.0664 17462.5 8548.911 0.2684665 1.668587 0.33125 0.04030084
pronostico_nv <- forecast(arima_nv, level = c(95),h=51)
pronostico_nv
## Point Forecast Lo 95 Hi 95
## 2020 3132873 3098211 3167535
## 2021 3185590 3124468 3246713
## 2022 3238308 3148333 3328282
## 2023 3291025 3169486 3412564
## 2024 3343742 3187997 3499487
## 2025 3396459 3203996 3588922
## 2026 3449176 3217617 3680736
## 2027 3501894 3228980 3774807
## 2028 3554611 3238193 3871028
## 2029 3607328 3245352 3969304
## 2030 3660045 3250543 4069548
## 2031 3712762 3253840 4171685
## 2032 3765480 3255312 4275647
## 2033 3818197 3255020 4381373
## 2034 3870914 3253021 4488807
## 2035 3923631 3249365 4597897
## 2036 3976348 3244099 4708597
## 2037 4029066 3237267 4820865
## 2038 4081783 3228907 4934659
## 2039 4134500 3219057 5049943
## 2040 4187217 3207752 5166682
## 2041 4239934 3195024 5284845
## 2042 4292652 3180902 5404401
## 2043 4345369 3165415 5525323
## 2044 4398086 3148590 5647582
## 2045 4450803 3130452 5771154
## 2046 4503520 3111025 5896016
## 2047 4556238 3090332 6022144
## 2048 4608955 3068393 6149517
## 2049 4661672 3045229 6278115
## 2050 4714389 3020860 6407918
## 2051 4767106 2995304 6538909
## 2052 4819824 2968579 6671068
## 2053 4872541 2940702 6804380
## 2054 4925258 2911689 6938828
## 2055 4977975 2881555 7074396
## 2056 5030692 2850316 7211069
## 2057 5083410 2817985 7348834
## 2058 5136127 2784578 7487676
## 2059 5188844 2750106 7627582
## 2060 5241561 2714583 7768540
## 2061 5294278 2678021 7910536
## 2062 5346996 2640432 8053559
## 2063 5399713 2601828 8197598
## 2064 5452430 2562219 8342641
## 2065 5505147 2521617 8488677
## 2066 5557864 2480032 8635697
## 2067 5610582 2437475 8783689
## 2068 5663299 2393954 8932644
## 2069 5716016 2349480 9082552
## 2070 5768733 2304061 9233405
plot(pronostico_nv, main="Población Nevada")
#Estado Texas
poblacion_tx <- poblacion %>% filter(State == "TX")
ts_tx <- ts(poblacion_tx$Population, start =1900, frequency = 1)
ts_tx
## Time Series:
## Start = 1900
## End = 2019
## Frequency = 1
## [1] 3055000 3132000 3210000 3291000 3374000 3459000 3546000 3636000
## [9] 3727000 3821000 3922000 4016000 4107000 4207000 4300000 4368000
## [17] 4444000 4563000 4666000 4631000 4723000 4853000 4955000 5077000
## [25] 5210000 5332000 5453000 5577000 5675000 5762000 5844000 5907000
## [33] 5961000 6014000 6053000 6123000 6192000 6250000 6301000 6360000
## [41] 6425000 6585000 6711000 7012000 6876000 6826000 7197000 7388000
## [49] 7626000 7623000 7776000 8111000 8314000 8336000 8382000 8660000
## [57] 8830000 9070000 9252000 9405000 9624000 9820000 10053000 10159000
## [65] 10270000 10378000 10492000 10599000 10819000 11045000 11198655 11509848
## [73] 11759148 12019543 12268629 12568843 12904089 13193050 13500429 13888371
## [81] 14338208 14746318 15331415 15751676 16007086 16272734 16561113 16621791
## [89] 16667022 16806735 17044714 17339904 17650479 17996764 18338319 18679706
## [97] 19006240 19355427 19712389 20044141 20944499 21319622 21690325 22030931
## [105] 22394023 22778123 23359580 23831983 24309039 24801761 25241971 25645629
## [113] 26084481 26480266 26964333 27470056 27914410 28295273 28628666 28995881
arima_tx <- auto.arima(ts_tx)
arima_tx
## Series: ts_tx
## ARIMA(0,2,2)
##
## Coefficients:
## ma1 ma2
## -0.5950 -0.1798
## s.e. 0.0913 0.0951
##
## sigma^2 = 1.031e+10: log likelihood = -1527.14
## AIC=3060.28 AICc=3060.5 BIC=3068.6
summary(arima_tx)
## Series: ts_tx
## ARIMA(0,2,2)
##
## Coefficients:
## ma1 ma2
## -0.5950 -0.1798
## s.e. 0.0913 0.0951
##
## sigma^2 = 1.031e+10: log likelihood = -1527.14
## AIC=3060.28 AICc=3060.5 BIC=3068.6
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 12147.62 99818.31 59257.39 0.1046163 0.5686743 0.2672197
## ACF1
## Training set -0.02136734
pronostico_tx <- forecast(arima_tx, level = c(95),h=51)
pronostico_tx
## Point Forecast Lo 95 Hi 95
## 2020 29398472 29199487 29597457
## 2021 29806827 29463665 30149990
## 2022 30215183 29742956 30687410
## 2023 30623538 30024100 31222977
## 2024 31031894 30303359 31760429
## 2025 31440249 30579246 32301253
## 2026 31848605 30851090 32846119
## 2027 32256960 31118581 33395339
## 2028 32665316 31381587 33949044
## 2029 33073671 31640070 34507272
## 2030 33482027 31894047 35070007
## 2031 33890382 32143561 35637204
## 2032 34298738 32388674 36208801
## 2033 34707093 32629456 36784730
## 2034 35115449 32865983 37364914
## 2035 35523804 33098330 37949278
## 2036 35932160 33326573 38537746
## 2037 36340515 33550788 39130242
## 2038 36748871 33771046 39726695
## 2039 37157226 33987418 40327034
## 2040 37565581 34199972 40931191
## 2041 37973937 34408774 41539100
## 2042 38382292 34613887 42150698
## 2043 38790648 34815371 42765925
## 2044 39199003 35013284 43384723
## 2045 39607359 35207682 44007036
## 2046 40015714 35398618 44632810
## 2047 40424070 35586145 45261995
## 2048 40832425 35770311 45894540
## 2049 41240781 35951163 46530399
## 2050 41649136 36128748 47169524
## 2051 42057492 36303110 47811874
## 2052 42465847 36474290 48457405
## 2053 42874203 36642330 49106076
## 2054 43282558 36807269 49757848
## 2055 43690914 36969145 50412683
## 2056 44099269 37127994 51070544
## 2057 44507625 37283853 51731396
## 2058 44915980 37436755 52395205
## 2059 45324336 37586734 53061937
## 2060 45732691 37733822 53731560
## 2061 46141047 37878050 54404044
## 2062 46549402 38019447 55079357
## 2063 46957758 38158044 55757471
## 2064 47366113 38293868 56438358
## 2065 47774469 38426948 57121989
## 2066 48182824 38557310 57808338
## 2067 48591180 38684979 58497380
## 2068 48999535 38809982 59189088
## 2069 49407891 38932343 59883438
## 2070 49816246 39052086 60580406
plot(pronostico_tx, main="Población Texas")
poblacion_ny <- poblacion %>% filter(State == "NY")
ts_ny <- ts(poblacion_ny$Population, start =1900, frequency = 1)
ts_ny
## Time Series:
## Start = 1900
## End = 2019
## Frequency = 1
## [1] 7283000 7449000 7612000 7771000 7927000 8084000 8289000 8499000
## [9] 8714000 8935000 9137000 9249000 9361000 9473000 9585000 9700000
## [17] 9848000 9993000 9936000 10252000 10282000 10416000 10589000 10752000
## [25] 10953000 11186000 11257000 11174000 11599000 12171000 12647000 12848000
## [33] 13001000 13126000 13253000 13375000 13481000 13511000 13512000 13523000
## [41] 13456000 13267000 13002000 12807000 12628000 12495000 13398000 13982000
## [49] 14497000 14892000 14865000 14890000 15192000 15527000 15814000 15966000
## [57] 16112000 16374000 16601000 16685000 16838000 17061000 17301000 17461000
## [65] 17589000 17734000 17843000 17935000 18051000 18105000 18241391 18357982
## [73] 18339400 18177063 18049775 18003485 17940541 17812602 17680589 17583838
## [81] 17566754 17567734 17589738 17686905 17745684 17791672 17833419 17868848
## [89] 17941309 17983086 18002855 18029532 18082032 18140894 18156652 18150928
## [97] 18143805 18143184 18159175 18196601 19001780 19082838 19137800 19175939
## [105] 19171567 19132610 19104631 19132335 19212436 19307066 19399878 19499241
## [113] 19572932 19624447 19651049 19654666 19633428 19589572 19530351 19453561
arima_ny <- auto.arima(ts_ny)
arima_ny
## Series: ts_ny
## ARIMA(1,2,1)
##
## Coefficients:
## ar1 ma1
## 0.5065 -0.9697
## s.e. 0.0855 0.0271
##
## sigma^2 = 2.326e+10: log likelihood = -1575.62
## AIC=3157.25 AICc=3157.46 BIC=3165.56
summary(arima_ny)
## Series: ts_ny
## ARIMA(1,2,1)
##
## Coefficients:
## ar1 ma1
## 0.5065 -0.9697
## s.e. 0.0855 0.0271
##
## sigma^2 = 2.326e+10: log likelihood = -1575.62
## AIC=3157.25 AICc=3157.46 BIC=3165.56
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -14563.74 149933.4 82036.53 -0.08319142 0.5752184 0.5840548
## ACF1
## Training set -0.009336835
pronostico_ny <- forecast(arima_ny, level = c(95),h=51)
pronostico_ny
## Point Forecast Lo 95 Hi 95
## 2020 19441372 19142479 19740265
## 2021 19461901 18913884 20009918
## 2022 19499001 18722834 20275168
## 2023 19544494 18560730 20528257
## 2024 19594237 18419928 20768546
## 2025 19646134 18294652 20997616
## 2026 19699121 18180758 21217483
## 2027 19752660 18075313 21430006
## 2028 19806478 17976225 21636732
## 2029 19860439 17881980 21838897
## 2030 19914471 17791466 22037476
## 2031 19968539 17703845 22233234
## 2032 20022626 17618478 22426774
## 2033 20076722 17534869 22618576
## 2034 20130823 17452622 22809025
## 2035 20184927 17371422 22998431
## 2036 20239031 17291010 23187052
## 2037 20293136 17211176 23375097
## 2038 20347242 17131741 23562742
## 2039 20401347 17052559 23750136
## 2040 20455453 16973503 23937403
## 2041 20509559 16894467 24124650
## 2042 20563664 16815359 24311970
## 2043 20617770 16736100 24499440
## 2044 20671876 16656621 24687131
## 2045 20725982 16576862 24875101
## 2046 20780087 16496771 25063404
## 2047 20834193 16416303 25252084
## 2048 20888299 16335416 25441182
## 2049 20942405 16254076 25630733
## 2050 20996510 16172251 25820770
## 2051 21050616 16089912 26011320
## 2052 21104722 16007036 26202407
## 2053 21158828 15923601 26394055
## 2054 21212933 15839586 26586281
## 2055 21267039 15754974 26779104
## 2056 21321145 15669750 26972540
## 2057 21375251 15583900 27166601
## 2058 21429356 15497412 27361301
## 2059 21483462 15410274 27556650
## 2060 21537568 15322477 27752659
## 2061 21591674 15234012 27949335
## 2062 21645780 15144871 28146688
## 2063 21699885 15055048 28344722
## 2064 21753991 14964536 28543446
## 2065 21808097 14873330 28742864
## 2066 21862203 14781425 28942980
## 2067 21916308 14688817 29143799
## 2068 21970414 14595503 29345325
## 2069 22024520 14501479 29547561
## 2070 22078626 14406742 29750509
plot(pronostico_ny, main="Población Nueva York")
poblacion_ca <- poblacion %>% filter(State == "CA")
ts_ca <- ts(poblacion_ca$Population, start =1900, frequency = 1)
ts_ca
## Time Series:
## Start = 1900
## End = 2019
## Frequency = 1
## [1] 1490000 1550000 1623000 1702000 1792000 1893000 1976000 2054000
## [9] 2161000 2282000 2406000 2534000 2668000 2811000 2934000 3008000
## [17] 3071000 3171000 3262000 3339000 3554000 3795000 3991000 4270000
## [25] 4541000 4730000 4929000 5147000 5344000 5531000 5711000 5824000
## [33] 5894000 5963000 6060000 6175000 6341000 6528000 6656000 6785000
## [41] 6950000 7237000 7735000 8506000 8945000 9344000 9559000 9832000
## [49] 10064000 10337000 10677000 11134000 11635000 12251000 12746000 13133000
## [57] 13713000 14264000 14880000 15467000 15870000 16497000 17072000 17668000
## [65] 18151000 18585000 18858000 19176000 19394000 19711000 19971069 20345939
## [73] 20585469 20868728 21173865 21537849 21935909 22352396 22835958 23256880
## [81] 23800800 24285933 24820009 25360026 25844393 26441109 27102237 27777158
## [89] 28464249 29218164 29950111 30414114 30875920 31147208 31317179 31493525
## [97] 31780829 32217708 32682794 33145121 33987977 34479458 34871843 35253159
## [105] 35574576 35827943 36021202 36250311 36604337 36961229 37319502 37638369
## [113] 37948800 38260787 38596972 38918045 39167117 39358497 39461588 39512223
arima_ca <- auto.arima(ts_ca)
arima_ca
## Series: ts_ca
## ARIMA(0,2,0)
##
## sigma^2 = 9.971e+09: log likelihood = -1525.79
## AIC=3053.57 AICc=3053.61 BIC=3056.34
summary(arima_ca)
## Series: ts_ca
## ARIMA(0,2,0)
##
## sigma^2 = 9.971e+09: log likelihood = -1525.79
## AIC=3053.57 AICc=3053.61 BIC=3056.34
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -88.02939 99017.45 65793.72 0.06388803 0.560492 0.2059178
## ACF1
## Training set -0.1174913
pronostico_ca <- forecast(arima_ca, level = c(95),h=51)
pronostico_ca
## Point Forecast Lo 95 Hi 95
## 2020 39562858 39367149.6 39758566
## 2021 39613493 39175875.8 40051110
## 2022 39664128 38931854.3 40396402
## 2023 39714763 38642824.0 40786702
## 2024 39765398 38313985.8 41216810
## 2025 39816033 37949094.0 41682972
## 2026 39866668 37551015.2 42182321
## 2027 39917303 37122028.2 42712578
## 2028 39967938 36664000.2 43271876
## 2029 40018573 36178497.2 43858649
## 2030 40069208 35666856.8 44471559
## 2031 40119843 35130238.7 45109447
## 2032 40170478 34569661.1 45771295
## 2033 40221113 33986027.0 46456199
## 2034 40271748 33380144.7 47163351
## 2035 40322383 32752743.0 47892023
## 2036 40373018 32104483.6 48641552
## 2037 40423653 31435970.6 49411335
## 2038 40474288 30747758.6 50200817
## 2039 40524923 30040359.0 51009487
## 2040 40575558 29314245.3 51836871
## 2041 40626193 28569857.7 52682528
## 2042 40676828 27807606.7 53546049
## 2043 40727463 27027876.2 54427050
## 2044 40778098 26231026.6 55325169
## 2045 40828733 25417396.8 56240069
## 2046 40879368 24587306.3 57171430
## 2047 40930003 23741057.1 58118949
## 2048 40980638 22878935.0 59082341
## 2049 41031273 22001211.4 60061335
## 2050 41081908 21108144.0 61055672
## 2051 41132543 20199978.4 62065108
## 2052 41183178 19276948.5 63089407
## 2053 41233813 18339277.9 64128348
## 2054 41284448 17387180.2 65181716
## 2055 41335083 16420860.1 66249306
## 2056 41385718 15440513.7 67330922
## 2057 41436353 14446329.2 68426377
## 2058 41486988 13438487.6 69535488
## 2059 41537623 12417162.7 70658083
## 2060 41588258 11382522.0 71793994
## 2061 41638893 10334727.0 72943059
## 2062 41689528 9273933.2 74105123
## 2063 41740163 8200291.0 75280035
## 2064 41790798 7113945.5 76467651
## 2065 41841433 6015037.0 77667829
## 2066 41892068 4903701.4 78880435
## 2067 41942703 3780070.2 80105336
## 2068 41993338 2644270.7 81342405
## 2069 42043973 1496426.6 82591519
## 2070 42094608 336657.5 83852558
plot(pronostico_ca, main="Población California")
#install.packages("maps")
library(maps)
##
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
##
## map
#forecasted_values_CA <- pronostico_ca$mean
#forecasted_values_NV <- pronostico_nv$mean
#forecasted_values_TX <- pronostico_tx$mean
#forecasted_values_NY <- pronostico_ny$mean
#forecasted_values_MA <- pronostico_ma$mean
#start_year <- as.numeric(format(pronostico_ca$model$series$start, "%Y")) + length(pronostico_ca$model$series$residuals)
#end_year <- start_year + 50
#years <- seq(from = start_year, to = end_year)
#decades <- cut(years, breaks = seq(from = start_year, to = end_year, by = 10), include.lowest = TRUE, labels = FALSE)
#all_states_data <- data.frame(
#state = rep(c("CA", "NV", "TX", "NY", "MA"), each = length(years)),
#year = rep(years, times = 5),
#forecasted_values = c(forecasted_values_CA, forecasted_values_NV, forecasted_values_TX, forecasted_values_NY, forecasted_values_MA))
#library(dplyr)
#decade_averages <- all_states_data %>%
#group_by(state, decade = cut(year, breaks = seq(from = start_year, to = end_year, by = 10), include.lowest = TRUE, labels = FALSE)) %>%
#summarise(average_population = mean(forecasted_values))
#library(maps)
#us_map_data <- map_data("state")
#us_map_data <- merge(us_map_data, decade_averages, by.x = "region", by.y = "state", all.x = TRUE)