Inflation has been a major topic of discussion over the past few years. The COVID-19 pandemic and the shutdowns that ensued from it brought on global supply shortages, causing prices of goods and services to skyrocket across industries. Notable among them was the surge in oil prices, which was initially caused low investment in oil production prior to the pandemic and exacerbated by the Russia-Ukraine conflict.
The goal of this project is to track inflation in the New York Metro Area using monthly consumer price index (CPI) data from the U.S. Bureau of Labor Statistics (BLS). It calculates the 12-month percent change in prices for CPI components and uses visuals to highlights headline and core inflation, as well as price changes for select components. Lastly, using an ARIMA model, it predicts the monthly headline inflation in the NY-Metro Area for the next 12 months.
This analysis uses the non-seasonally adjusted CPI data for the NY-Metro Area published by the BLS. The data is extracted using an API, and then transformed, loaded and cleaned for use in this analysis.1 The latest month for which CPI data is available is December 2022.
I extracted monthly data for all 61 CPI components for which BLS
publishes data pertaining to the NY Metro Area. The extracted data were
cleaned and merged into a data frame object called
cpi_use
.2 The data includes monthly CPI for 2003
through 2022 as BLS limits data downloads via API to 20 years per
request. In the future, the project may be expanded to include data
prior to 2003.
Below are the top and bottom five rows of the data.
cpi_use %>% head(10) %>%
kbl(align = "rrrrrrrrrrrrrrr") %>%
kable_material(c("striped", "hover"),
html_font = "calibri") %>%
scroll_box(width = "100%", height = "300px")
year | period | periodName | all.items | energy | all.items.less.food.energy | all.items.less.shelter | all.items.less.medical.care | all.items.less.energy | apparel | commodities | commodities.less.food | commodities.less.food.beverages | durables | education.communication | education.communication.commodities | education.communication.services | food.beverages | food | food.at.home | cereals.bakery.products | meats.poultry.fish.egg | fruits.vegetables | nonalcoholic.beverages.beverage.materials | other.food.at.home | alcoholic.beverages | other.goods.services | other.goods | other.personal.services | housing | shelter | fuels.utilities | household.energy | household.furnishing.operations | household.furnishing.supplies | medical.care | nondurables | nondurables.less.food | nondurables.less.food.beverages | recreation | services | services.less.rent.of.shelter | services.less.medical.services | transportation | private.transportation | transportation.commodities.less.motor.fuel | tuition.other.school.fees.childcare | dairy.related.products | food.away.from.home | rent.of.primary.residence | owners.equivalent.rent.of.residences | owners.equivalent.rent.of.primary.residence | value | electricity | utility.piped.gas.services | new.used.motor.vehicles | new.vehicles | used.cars.trucks | motor.fuel | gasoline.all.types | motor.vehicle.insurance | gasoline.unleaded.regular | gasoline.unleaded.midgrade | gasoline.unleaded.premium |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 | M01 | January | 194.7 | 124.6 | 208.4 | 174.6 | 189.6 | 202.7 | 107.2 | 153.4 | 135.8 | 133.0 | 117.4 | 111.4 | NA | NA | 180.7 | 179.3 | 178.6 | NA | NA | NA | NA | NA | 198.3 | 309.3 | NA | NA | 204.6 | 246.4 | 127.7 | 125.4 | 130.8 | NA | 305.4 | 163.3 | 146.2 | 142.7 | 110.3 | 230.1 | 220.5 | 224.0 | 163.4 | 156.3 | NA | NA | NA | 185.1 | 229.0 | 256.2 | 256.2 | 129.4 | 115.9 | 154.5 | NA | NA | NA | 120.4 | 120.0 | NA | 120.8 | 120.8 | 120.0 |
2003 | M02 | February | 196.2 | 131.3 | 208.9 | 176.8 | 191.1 | 203.7 | 110.3 | 156.0 | 138.0 | 135.2 | 117.7 | 111.5 | NA | NA | 183.9 | 182.7 | 182.2 | NA | NA | NA | NA | NA | 198.5 | 309.7 | NA | NA | 205.4 | 246.4 | 132.8 | 131.1 | 131.2 | NA | 305.0 | 166.8 | 149.7 | 146.3 | 111.3 | 230.6 | 221.8 | 224.6 | 165.1 | 158.1 | NA | NA | NA | 188.2 | 229.6 | 257.0 | 257.0 | 133.0 | 119.7 | 157.6 | NA | NA | NA | 128.3 | 127.8 | NA | 128.9 | 128.3 | 127.6 |
2003 | M03 | March | 197.1 | 138.3 | 209.4 | 177.3 | 192.1 | 204.0 | 110.0 | 156.1 | 138.4 | 135.7 | 117.4 | 111.5 | NA | NA | 183.4 | 182.2 | 181.0 | NA | NA | NA | NA | NA | 198.8 | 307.4 | NA | NA | 207.6 | 248.1 | 141.0 | 140.2 | 130.9 | NA | 303.3 | 167.1 | 150.7 | 147.4 | 111.3 | 232.2 | 223.1 | 226.3 | 166.1 | 159.1 | NA | NA | NA | 188.6 | 230.0 | 257.2 | 257.2 | 141.7 | 123.6 | 175.8 | NA | NA | NA | 132.4 | 131.9 | NA | 133.4 | 132.0 | 130.6 |
2003 | M04 | April | 196.7 | 133.8 | 209.7 | 177.1 | 191.7 | 204.1 | 111.2 | 155.6 | 138.0 | 135.3 | 116.9 | 111.0 | NA | NA | 182.8 | 181.5 | 179.7 | NA | NA | NA | NA | NA | 199.3 | 308.9 | NA | NA | 206.7 | 247.4 | 136.1 | 134.7 | 132.2 | NA | 305.8 | 166.6 | 150.4 | 147.0 | 111.5 | 232.0 | 223.5 | 226.0 | 165.9 | 158.8 | NA | NA | NA | 188.8 | 230.9 | 256.5 | 256.5 | 138.7 | 125.5 | 163.3 | NA | NA | NA | 129.3 | 128.8 | NA | 130.1 | 129.2 | 128.4 |
2003 | M05 | May | 196.8 | 130.1 | 210.1 | 176.6 | 191.7 | 204.6 | 106.1 | 153.9 | 135.3 | 132.4 | 116.6 | 110.6 | NA | NA | 183.1 | 181.8 | 180.1 | NA | NA | NA | NA | NA | 199.1 | 310.0 | NA | NA | 207.2 | 249.0 | 134.2 | 132.6 | 130.7 | NA | 307.4 | 164.3 | 145.9 | 142.3 | 111.5 | 233.7 | 225.5 | 227.7 | 167.0 | 157.4 | NA | NA | NA | 189.0 | 231.2 | 257.7 | 257.7 | 138.5 | 125.4 | 163.0 | NA | NA | NA | 123.4 | 123.0 | NA | 123.8 | 123.3 | 123.5 |
2003 | M06 | June | 196.9 | 131.6 | 210.1 | 176.8 | 191.8 | 204.5 | 106.4 | 153.1 | 134.3 | 131.4 | 115.7 | 110.3 | NA | NA | 183.0 | 181.7 | 179.8 | NA | NA | NA | NA | NA | 199.5 | 307.6 | NA | NA | 207.9 | 248.9 | 139.0 | 137.9 | 131.2 | NA | 308.4 | 163.7 | 144.8 | 141.2 | 111.8 | 234.5 | 227.4 | 228.5 | 166.2 | 156.4 | NA | NA | NA | 189.1 | 232.3 | 257.8 | 257.8 | 146.9 | 135.5 | 167.8 | NA | NA | NA | 119.9 | 119.4 | NA | 120.1 | 119.5 | 120.6 |
2003 | M07 | July | 197.7 | 131.4 | 211.0 | 177.5 | 192.5 | 205.4 | 108.0 | 153.8 | 134.8 | 131.9 | 114.7 | 110.8 | NA | NA | 184.0 | 182.7 | 181.0 | NA | NA | NA | NA | NA | 200.9 | 313.7 | NA | NA | 208.8 | 250.0 | 139.5 | 138.3 | 131.8 | NA | 310.7 | 165.0 | 146.5 | 142.8 | 111.6 | 235.3 | 228.0 | 229.2 | 165.2 | 155.4 | NA | NA | NA | 189.8 | 233.8 | 259.2 | 259.2 | 147.7 | 138.3 | 164.6 | NA | NA | NA | 118.7 | 118.3 | NA | 118.8 | 118.7 | 119.6 |
2003 | M08 | August | 199.1 | 134.3 | 212.5 | 178.5 | 194.0 | 206.7 | 114.1 | 155.3 | 136.7 | 133.9 | 113.6 | 111.6 | NA | NA | 184.3 | 183.1 | 181.6 | NA | NA | NA | NA | NA | 200.2 | 313.8 | NA | NA | 210.3 | 252.4 | 140.4 | 139.4 | 130.3 | NA | 309.9 | 167.4 | 150.4 | 147.0 | 111.8 | 236.8 | 228.3 | 230.8 | 166.0 | 156.4 | NA | NA | NA | 189.9 | 234.5 | 260.1 | 260.1 | 148.9 | 141.9 | 161.1 | NA | NA | NA | 124.0 | 123.5 | NA | 124.2 | 123.8 | 124.5 |
2003 | M09 | September | 199.6 | 142.4 | 212.2 | 180.3 | 194.5 | 206.5 | 120.6 | 157.5 | 140.0 | 137.2 | 112.6 | 112.9 | NA | NA | 184.5 | 183.2 | 181.9 | NA | NA | NA | NA | NA | 200.7 | 314.6 | NA | NA | 208.7 | 249.8 | 141.6 | 140.6 | 130.1 | NA | 311.0 | 170.9 | 156.8 | 153.6 | 111.5 | 235.7 | 229.1 | 229.6 | 168.7 | 159.7 | NA | NA | NA | 189.8 | 235.0 | 261.7 | 261.7 | 150.5 | 141.1 | 167.3 | NA | NA | NA | 141.4 | 140.9 | NA | 142.7 | 140.5 | 139.8 |
2003 | M10 | October | 200.0 | 135.2 | 213.3 | 179.5 | 194.9 | 207.5 | 118.3 | 156.8 | 138.5 | 135.7 | 113.1 | 112.5 | NA | NA | 185.3 | 184.1 | 183.6 | NA | NA | NA | NA | NA | 200.9 | 314.6 | NA | NA | 209.9 | 252.9 | 134.3 | 132.5 | 130.3 | NA | 309.6 | 169.7 | 153.9 | 150.6 | 111.5 | 237.0 | 228.1 | 230.9 | 168.6 | 159.4 | NA | NA | NA | 189.6 | 235.3 | 263.5 | 263.5 | 140.5 | 127.9 | 163.9 | NA | NA | NA | 135.5 | 135.0 | NA | 136.5 | 134.6 | 134.9 |
cpi_use %>%
tail(10) %>%
kbl(align = "rrrrrrrr") %>%
kable_material(c("striped", "hovered"),
html_font = "calibri") %>%
scroll_box(width = "100%", height = "300px")
year | period | periodName | all.items | energy | all.items.less.food.energy | all.items.less.shelter | all.items.less.medical.care | all.items.less.energy | apparel | commodities | commodities.less.food | commodities.less.food.beverages | durables | education.communication | education.communication.commodities | education.communication.services | food.beverages | food | food.at.home | cereals.bakery.products | meats.poultry.fish.egg | fruits.vegetables | nonalcoholic.beverages.beverage.materials | other.food.at.home | alcoholic.beverages | other.goods.services | other.goods | other.personal.services | housing | shelter | fuels.utilities | household.energy | household.furnishing.operations | household.furnishing.supplies | medical.care | nondurables | nondurables.less.food | nondurables.less.food.beverages | recreation | services | services.less.rent.of.shelter | services.less.medical.services | transportation | private.transportation | transportation.commodities.less.motor.fuel | tuition.other.school.fees.childcare | dairy.related.products | food.away.from.home | rent.of.primary.residence | owners.equivalent.rent.of.residences | owners.equivalent.rent.of.primary.residence | value | electricity | utility.piped.gas.services | new.used.motor.vehicles | new.vehicles | used.cars.trucks | motor.fuel | gasoline.all.types | motor.vehicle.insurance | gasoline.unleaded.regular | gasoline.unleaded.midgrade | gasoline.unleaded.premium | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
231 | 2022 | M03 | March | 305.024 | 267.556 | 314.449 | 266.211 | 294.115 | 311.558 | 134.936 | 221.613 | 173.670 | 169.054 | 111.810 | 154.990 | 66.417 | 118.713 | 306.791 | 307.940 | 293.548 | 338.718 | 307.003 | 361.793 | 286.341 | 256.321 | 285.821 | 473.131 | 116.805 | 134.665 | 323.204 | 402.690 | 230.781 | 222.201 | 126.609 | 93.781 | 555.768 | 263.104 | 220.650 | 216.380 | 141.364 | 375.485 | 357.505 | 359.440 | 261.280 | 261.303 | 135.169 | 1303.045 | 249.525 | 335.373 | 414.021 | 412.162 | 411.652 | 204.719 | 200.122 | 199.830 | 114.712 | 242.971 | 405.395 | 335.871 | 334.595 | NA | 334.932 | 339.305 | 335.669 |
232 | 2022 | M04 | April | 307.781 | 270.704 | 316.879 | 269.430 | 296.762 | 314.315 | 127.341 | 221.803 | 172.148 | 167.452 | 112.132 | 155.131 | 66.414 | 118.834 | 311.345 | 312.658 | 298.825 | 344.547 | 310.064 | 371.918 | 286.533 | 261.032 | 287.923 | 472.350 | 115.821 | 134.965 | 325.428 | 404.237 | 238.903 | 231.031 | 127.324 | 94.441 | 561.104 | 263.145 | 216.797 | 212.172 | 141.036 | 380.500 | 366.603 | 364.242 | 270.029 | 268.103 | 135.442 | 1304.026 | 259.163 | 339.119 | 414.401 | 413.477 | 412.965 | 211.740 | 208.589 | 203.460 | 121.113 | 245.205 | 401.553 | 328.344 | 326.948 | NA | 326.734 | 334.962 | 331.517 |
233 | 2022 | M05 | May | 309.243 | 293.717 | 316.140 | 270.999 | 298.292 | 314.028 | 132.492 | 226.222 | 177.069 | 172.350 | 112.328 | 155.119 | 65.513 | 118.997 | 313.714 | 314.914 | 301.121 | 344.468 | 315.452 | 369.151 | 292.951 | 264.597 | 291.908 | 468.287 | 115.326 | 133.474 | 327.419 | 405.410 | 250.155 | 243.299 | 126.427 | 93.623 | 560.619 | 270.046 | 227.430 | 223.193 | 140.927 | 379.299 | 362.670 | 363.005 | 269.939 | 266.264 | 136.848 | 1306.547 | 257.739 | 341.316 | 415.565 | 414.705 | 414.192 | 219.794 | 214.488 | 215.289 | 113.437 | 247.817 | 405.064 | 369.870 | 368.128 | NA | 368.637 | 372.647 | 368.403 |
234 | 2022 | M06 | June | 313.589 | 305.732 | 320.418 | 276.310 | 302.384 | 317.795 | 129.609 | 227.812 | 178.755 | 174.064 | 113.069 | 155.051 | 64.955 | 119.046 | 314.683 | 315.948 | 301.169 | 354.080 | 314.700 | 354.723 | 299.112 | 265.840 | 291.919 | 474.322 | 114.022 | 137.036 | 329.507 | 407.236 | 255.749 | 248.971 | 127.163 | 94.301 | 571.113 | 271.983 | 230.081 | 225.999 | 141.231 | 386.050 | 375.262 | 369.321 | 287.237 | 286.535 | 138.827 | 1307.013 | 262.037 | 344.116 | 417.792 | 416.827 | 416.311 | 226.848 | 220.208 | 224.541 | 126.618 | 250.238 | 414.351 | 392.904 | 391.297 | NA | 391.120 | 398.842 | 396.448 |
235 | 2022 | M07 | July | 312.615 | 287.905 | 319.882 | 274.604 | 301.214 | 318.190 | 126.323 | 227.670 | 176.441 | 171.680 | 114.062 | 155.494 | 64.766 | 119.457 | 320.077 | 321.624 | 308.723 | 360.658 | 322.909 | 368.453 | 301.367 | 273.726 | 293.127 | 474.676 | 114.849 | 136.648 | 328.877 | 408.155 | 244.131 | 235.959 | 128.237 | 95.317 | 575.350 | 270.949 | 223.480 | 218.936 | 142.582 | 384.345 | 370.527 | 367.272 | 278.009 | 277.935 | 139.566 | 1315.938 | 265.683 | 346.473 | 419.087 | 418.234 | 417.716 | 216.397 | 205.959 | 222.447 | 121.921 | 252.135 | 414.985 | 367.217 | 365.709 | NA | 364.394 | 378.367 | 378.310 |
236 | 2022 | M08 | August | 313.280 | 282.833 | 321.010 | 275.141 | 301.831 | 319.333 | 130.923 | 226.731 | 174.737 | 169.918 | 114.067 | 156.553 | 65.068 | 120.298 | 321.344 | 322.899 | 309.877 | 366.000 | 319.374 | 370.153 | 305.963 | 276.296 | 294.268 | 470.212 | 113.283 | 135.684 | 331.064 | 409.148 | 255.108 | 248.129 | 128.784 | 95.781 | 577.213 | 269.445 | 219.692 | 214.854 | 142.332 | 386.436 | 373.917 | 369.286 | 272.659 | 273.017 | 139.981 | 1330.256 | 265.663 | 347.972 | 420.194 | 420.031 | 419.511 | 231.253 | 221.271 | 235.359 | 122.933 | 253.150 | 414.887 | 330.598 | 329.190 | NA | 327.078 | 345.211 | 346.957 |
237 | 2022 | M09 | September | 313.880 | 267.439 | 323.291 | 274.886 | 302.232 | 321.250 | 133.312 | 224.197 | 171.454 | 166.515 | 112.939 | 156.339 | 64.289 | 120.266 | 321.447 | 322.838 | 308.665 | 365.245 | 315.370 | 375.459 | 298.191 | 274.851 | 296.748 | 476.643 | 113.645 | 138.324 | 332.460 | 411.946 | 252.862 | 245.319 | 128.183 | 95.275 | 582.938 | 266.314 | 214.066 | 208.745 | 141.277 | 389.828 | 378.068 | 372.339 | 270.454 | 270.048 | 138.165 | 1330.562 | 267.570 | 349.964 | 422.015 | 422.618 | 422.095 | 229.340 | 217.457 | 237.399 | 125.586 | 254.620 | 397.046 | 292.852 | 291.441 | NA | 288.716 | 309.329 | 313.305 |
238 | 2022 | M10 | October | 314.338 | 266.048 | 323.668 | 274.812 | 302.817 | 321.865 | 129.743 | 224.172 | 170.679 | 165.681 | 111.843 | 156.708 | 62.263 | 120.968 | 323.412 | 324.816 | 310.550 | 373.297 | 317.735 | 376.440 | 306.939 | 272.672 | 298.499 | 484.434 | 119.170 | 138.163 | 333.699 | 413.770 | 254.865 | 247.060 | 127.314 | 94.540 | 580.004 | 267.165 | 213.962 | 208.528 | 144.058 | 390.710 | 377.900 | 373.465 | 267.935 | 267.152 | 136.953 | 1341.453 | 266.022 | 352.119 | 423.709 | 424.372 | 423.846 | 223.510 | 208.940 | 237.375 | 122.803 | 254.787 | 387.770 | 285.758 | 284.268 | NA | 281.763 | 299.876 | 304.637 |
239 | 2022 | M11 | November | 314.975 | 274.553 | 323.219 | 274.661 | 303.624 | 321.865 | 123.985 | 225.125 | 170.969 | 165.955 | 111.305 | 158.216 | 63.159 | 122.075 | 325.845 | 327.358 | 312.627 | 376.817 | 316.908 | 375.920 | 307.964 | 276.292 | 299.317 | 478.053 | 115.944 | 137.437 | 336.047 | 416.435 | 257.233 | 249.633 | 128.574 | 94.829 | 576.156 | 269.126 | 215.400 | 210.002 | 142.249 | 391.057 | 375.614 | 374.097 | 267.255 | 266.469 | 135.780 | 1341.218 | 274.675 | 355.506 | 427.047 | 427.512 | 426.983 | 221.379 | 205.973 | 237.071 | 119.090 | 254.968 | 377.543 | 304.727 | 302.950 | NA | 300.449 | 318.270 | 323.524 |
240 | 2022 | M12 | December | 315.656 | 260.773 | 325.305 | 274.422 | 304.406 | 323.738 | 122.084 | 222.673 | 167.490 | 162.345 | 110.754 | 158.000 | 60.907 | 122.324 | 326.722 | 328.103 | 313.065 | 376.941 | 316.717 | 380.802 | 306.163 | 276.399 | 302.110 | 473.827 | 115.994 | 135.512 | 338.008 | 419.480 | 252.648 | 244.557 | 130.892 | 96.844 | 574.129 | 265.655 | 208.488 | 202.512 | 142.202 | 394.528 | 379.653 | 377.918 | 267.482 | 268.669 | 134.654 | 1345.039 | 273.396 | 356.802 | 430.800 | 430.489 | 429.956 | 224.431 | 205.291 | 247.419 | 125.211 | 255.361 | 369.120 | 275.668 | 274.270 | NA | 270.605 | 295.746 | 302.990 |
I examine the data in an attempt to spot anomalies that need to be cleaned, as well as patterns and trends that exist in the data.
The table below provides summary statistics about the variables in the data frame.
cpi_use %>%
skim() %>%
kbl() %>%
kable_material(c("striped", "hovered"),
html_font = "calibri") %>%
scroll_box(width = "100%", height = "300px")
skim_type | skim_variable | n_missing | complete_rate | character.min | character.max | character.empty | character.n_unique | character.whitespace | numeric.mean | numeric.sd | numeric.p0 | numeric.p25 | numeric.p50 | numeric.p75 | numeric.p100 | numeric.hist |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
character | year | 0 | 1.0000000 | 4 | 4 | 0 | 20 | 0 | NA | NA | NA | NA | NA | NA | NA | NA |
character | period | 0 | 1.0000000 | 3 | 3 | 0 | 12 | 0 | NA | NA | NA | NA | NA | NA | NA | NA |
character | periodName | 0 | 1.0000000 | 3 | 9 | 0 | 12 | 0 | NA | NA | NA | NA | NA | NA | NA | NA |
numeric | all.items | 0 | 1.0000000 | NA | NA | NA | NA | NA | 251.16999 | 28.980474 | 194.700 | 229.77775 | 254.6805 | 270.2370 | 315.656 | ▅▆▇▆▂ |
numeric | energy | 0 | 1.0000000 | NA | NA | NA | NA | NA | 202.66202 | 34.133784 | 124.600 | 181.96250 | 202.2935 | 226.9973 | 305.732 | ▂▆▇▃▁ |
numeric | all.items.less.food.energy | 0 | 1.0000000 | NA | NA | NA | NA | NA | 262.22068 | 29.672673 | 208.400 | 238.22275 | 261.8765 | 284.0627 | 325.305 | ▆▇▇▇▃ |
numeric | all.items.less.shelter | 0 | 1.0000000 | NA | NA | NA | NA | NA | 219.26924 | 22.646806 | 174.600 | 202.97325 | 224.7460 | 230.2820 | 276.310 | ▃▅▇▂▁ |
numeric | all.items.less.medical.care | 0 | 1.0000000 | NA | NA | NA | NA | NA | 243.53465 | 27.105832 | 189.600 | 223.61975 | 247.5285 | 261.1970 | 304.406 | ▅▆▇▆▂ |
numeric | all.items.less.energy | 0 | 1.0000000 | NA | NA | NA | NA | NA | 257.66492 | 30.244941 | 202.700 | 233.02550 | 257.9935 | 279.2635 | 323.738 | ▆▇▇▇▂ |
numeric | apparel | 0 | 1.0000000 | NA | NA | NA | NA | NA | 120.72181 | 7.583787 | 103.300 | 114.74200 | 121.6990 | 126.9562 | 136.900 | ▂▆▇▇▃ |
numeric | commodities | 0 | 1.0000000 | NA | NA | NA | NA | NA | 184.62502 | 15.488343 | 153.100 | 173.84150 | 187.4300 | 192.4733 | 227.812 | ▂▃▇▁▁ |
numeric | commodities.less.food | 0 | 1.0000000 | NA | NA | NA | NA | NA | 151.57163 | 9.280468 | 134.300 | 145.19700 | 149.6960 | 160.0230 | 178.755 | ▃▇▂▃▁ |
numeric | commodities.less.food.beverages | 0 | 1.0000000 | NA | NA | NA | NA | NA | 147.77493 | 9.137919 | 131.400 | 141.18300 | 145.9905 | 156.5223 | 174.064 | ▃▇▂▃▁ |
numeric | durables | 0 | 1.0000000 | NA | NA | NA | NA | NA | 103.61933 | 7.190191 | 91.778 | 97.80725 | 104.0335 | 110.8778 | 117.700 | ▆▃▇▆▃ |
numeric | education.communication | 0 | 1.0000000 | NA | NA | NA | NA | NA | 135.87248 | 12.408276 | 110.300 | 127.55725 | 139.9000 | 143.1565 | 158.216 | ▃▂▅▇▂ |
numeric | education.communication.commodities | 83 | 0.6541667 | NA | NA | NA | NA | NA | 80.75446 | 11.663649 | 60.907 | 69.52600 | 77.8060 | 93.2150 | 100.261 | ▇▇▃▅▇ |
numeric | education.communication.services | 83 | 0.6541667 | NA | NA | NA | NA | NA | 108.06154 | 5.709921 | 99.858 | 104.17900 | 107.3610 | 111.7550 | 122.324 | ▆▇▂▂▂ |
numeric | food.beverages | 0 | 1.0000000 | NA | NA | NA | NA | NA | 242.23547 | 34.045137 | 180.700 | 215.93775 | 245.8145 | 262.6265 | 326.722 | ▅▅▇▃▂ |
numeric | food | 0 | 1.0000000 | NA | NA | NA | NA | NA | 241.87916 | 34.684985 | 179.300 | 215.10425 | 245.3025 | 262.8100 | 328.103 | ▅▅▇▃▂ |
numeric | food.at.home | 0 | 1.0000000 | NA | NA | NA | NA | NA | 237.40444 | 30.295748 | 178.600 | 213.23675 | 245.2715 | 254.8017 | 313.065 | ▃▃▇▂▁ |
numeric | cereals.bakery.products | 179 | 0.2541667 | NA | NA | NA | NA | NA | 316.69357 | 21.919781 | 291.754 | 303.62800 | 307.4490 | 323.2520 | 376.941 | ▇▅▁▁▂ |
numeric | meats.poultry.fish.egg | 179 | 0.2541667 | NA | NA | NA | NA | NA | 274.25497 | 24.212628 | 249.423 | 254.37200 | 263.7920 | 292.1270 | 322.909 | ▇▂▂▂▂ |
numeric | fruits.vegetables | 179 | 0.2541667 | NA | NA | NA | NA | NA | 340.92725 | 15.585375 | 317.788 | 329.98200 | 339.1050 | 345.5180 | 380.802 | ▅▇▂▁▂ |
numeric | nonalcoholic.beverages.beverage.materials | 179 | 0.2541667 | NA | NA | NA | NA | NA | 266.56789 | 17.694494 | 243.716 | 254.06500 | 261.8080 | 276.8010 | 307.964 | ▇▇▃▂▂ |
numeric | other.food.at.home | 179 | 0.2541667 | NA | NA | NA | NA | NA | 238.01269 | 16.025470 | 219.943 | 226.66700 | 234.7350 | 242.6250 | 276.399 | ▇▅▂▁▂ |
numeric | alcoholic.beverages | 0 | 1.0000000 | NA | NA | NA | NA | NA | 243.42278 | 24.417894 | 198.300 | 224.57075 | 246.8510 | 256.5797 | 302.110 | ▅▃▇▃▁ |
numeric | other.goods.services | 0 | 1.0000000 | NA | NA | NA | NA | NA | 387.67666 | 46.612390 | 307.400 | 340.27700 | 393.3905 | 423.7647 | 484.434 | ▇▃▇▇▂ |
numeric | other.goods | 83 | 0.6541667 | NA | NA | NA | NA | NA | 108.90306 | 3.621810 | 99.563 | 106.26100 | 108.9310 | 111.6690 | 119.170 | ▁▇▇▅▁ |
numeric | other.personal.services | 83 | 0.6541667 | NA | NA | NA | NA | NA | 115.04572 | 10.310850 | 99.971 | 107.23100 | 113.7110 | 122.9460 | 138.324 | ▇▇▆▅▂ |
numeric | housing | 0 | 1.0000000 | NA | NA | NA | NA | NA | 269.41827 | 32.054588 | 204.600 | 249.64625 | 267.7090 | 294.1012 | 338.008 | ▃▅▇▆▂ |
numeric | shelter | 0 | 1.0000000 | NA | NA | NA | NA | NA | 332.25743 | 45.749951 | 246.400 | 300.03075 | 327.3330 | 372.4447 | 419.480 | ▅▇▇▆▆ |
numeric | fuels.utilities | 0 | 1.0000000 | NA | NA | NA | NA | NA | 191.12058 | 24.181923 | 127.700 | 182.91275 | 195.1235 | 202.3438 | 257.233 | ▂▂▇▂▁ |
numeric | household.energy | 0 | 1.0000000 | NA | NA | NA | NA | NA | 187.15244 | 23.591940 | 125.400 | 177.92625 | 189.3145 | 200.1507 | 249.633 | ▂▂▇▃▁ |
numeric | household.furnishing.operations | 0 | 1.0000000 | NA | NA | NA | NA | NA | 121.06888 | 8.040206 | 107.772 | 113.34375 | 121.8995 | 128.5813 | 132.800 | ▇▃▆▅▇ |
numeric | household.furnishing.supplies | 83 | 0.6541667 | NA | NA | NA | NA | NA | 89.08393 | 6.675423 | 79.245 | 82.40500 | 88.5180 | 95.7870 | 100.886 | ▇▃▃▅▅ |
numeric | medical.care | 0 | 1.0000000 | NA | NA | NA | NA | NA | 423.48169 | 76.500532 | 303.300 | 365.46150 | 416.4570 | 481.7050 | 582.938 | ▆▇▆▅▅ |
numeric | nondurables | 0 | 1.0000000 | NA | NA | NA | NA | NA | 213.82888 | 23.639505 | 163.300 | 196.57400 | 221.5725 | 228.0600 | 271.983 | ▂▃▇▃▁ |
numeric | nondurables.less.food | 0 | 1.0000000 | NA | NA | NA | NA | NA | 185.75699 | 17.594017 | 144.800 | 176.39750 | 185.9050 | 199.4075 | 230.081 | ▂▅▇▅▁ |
numeric | nondurables.less.food.beverages | 0 | 1.0000000 | NA | NA | NA | NA | NA | 181.85669 | 17.636078 | 141.200 | 171.42350 | 181.5450 | 196.4595 | 225.999 | ▂▃▇▅▁ |
numeric | recreation | 0 | 1.0000000 | NA | NA | NA | NA | NA | 120.30390 | 7.851837 | 109.700 | 114.88350 | 118.5065 | 123.3448 | 144.058 | ▇▇▂▁▂ |
numeric | services | 0 | 1.0000000 | NA | NA | NA | NA | NA | 307.76881 | 41.184029 | 230.100 | 276.52525 | 306.2780 | 339.5777 | 394.528 | ▅▇▇▇▃ |
numeric | services.less.rent.of.shelter | 0 | 1.0000000 | NA | NA | NA | NA | NA | 291.34085 | 37.582943 | 220.500 | 261.63375 | 294.0050 | 315.3043 | 379.653 | ▅▆▇▅▂ |
numeric | services.less.medical.services | 0 | 1.0000000 | NA | NA | NA | NA | NA | 297.97181 | 38.151177 | 224.000 | 269.26275 | 297.2985 | 327.8065 | 377.918 | ▅▇▇▇▃ |
numeric | transportation | 0 | 1.0000000 | NA | NA | NA | NA | NA | 210.16533 | 24.433002 | 163.400 | 194.27400 | 212.8785 | 226.0990 | 287.237 | ▅▆▇▁▁ |
numeric | private.transportation | 0 | 1.0000000 | NA | NA | NA | NA | NA | 199.66432 | 25.297677 | 155.400 | 184.49150 | 199.7010 | 213.5938 | 286.535 | ▅▇▅▁▁ |
numeric | transportation.commodities.less.motor.fuel | 83 | 0.6541667 | NA | NA | NA | NA | NA | 108.58498 | 9.753566 | 99.735 | 104.07500 | 105.7610 | 106.7060 | 139.981 | ▇▁▁▁▁ |
numeric | tuition.other.school.fees.childcare | 179 | 0.2541667 | NA | NA | NA | NA | NA | 1251.75218 | 52.815088 | 1165.927 | 1204.28200 | 1258.2410 | 1299.4020 | 1345.039 | ▆▃▇▇▂ |
numeric | dairy.related.products | 179 | 0.2541667 | NA | NA | NA | NA | NA | 238.32679 | 14.324174 | 220.666 | 227.06000 | 238.4470 | 242.6570 | 274.675 | ▇▅▂▁▂ |
numeric | food.away.from.home | 0 | 1.0000000 | NA | NA | NA | NA | NA | 254.58351 | 42.370320 | 185.100 | 222.14125 | 251.1745 | 283.6687 | 356.802 | ▆▇▆▅▂ |
numeric | rent.of.primary.residence | 0 | 1.0000000 | NA | NA | NA | NA | NA | 333.81439 | 56.989040 | 229.000 | 288.56900 | 332.6230 | 385.2432 | 430.800 | ▆▆▇▇▇ |
numeric | owners.equivalent.rent.of.residences | 0 | 1.0000000 | NA | NA | NA | NA | NA | 339.68790 | 45.804346 | 256.200 | 306.87175 | 334.6685 | 379.1350 | 430.489 | ▅▇▇▆▅ |
numeric | owners.equivalent.rent.of.primary.residence | 0 | 1.0000000 | NA | NA | NA | NA | NA | 339.46236 | 45.604013 | 256.200 | 306.87175 | 334.4870 | 378.6658 | 429.956 | ▅▇▇▆▅ |
numeric | value | 0 | 1.0000000 | NA | NA | NA | NA | NA | 179.91330 | 18.573211 | 129.400 | 171.52375 | 180.1825 | 189.7603 | 231.253 | ▁▂▇▂▁ |
numeric | electricity | 0 | 1.0000000 | NA | NA | NA | NA | NA | 176.18708 | 21.903459 | 115.900 | 171.50575 | 179.4705 | 188.9230 | 227.366 | ▂▂▇▇▁ |
numeric | utility.piped.gas.services | 0 | 1.0000000 | NA | NA | NA | NA | NA | 181.28290 | 30.692599 | 124.721 | 160.63050 | 172.7520 | 203.0055 | 256.392 | ▂▇▃▃▂ |
numeric | new.used.motor.vehicles | 179 | 0.2541667 | NA | NA | NA | NA | NA | 99.67403 | 12.004867 | 88.651 | 90.51300 | 93.2990 | 108.7910 | 126.618 | ▇▁▁▁▂ |
numeric | new.vehicles | 179 | 0.2541667 | NA | NA | NA | NA | NA | 216.32100 | 18.800492 | 199.778 | 202.67900 | 206.3950 | 232.2010 | 255.361 | ▇▂▁▁▂ |
numeric | used.cars.trucks | 179 | 0.2541667 | NA | NA | NA | NA | NA | 312.60951 | 58.283302 | 259.428 | 266.95700 | 274.2530 | 379.6520 | 414.985 | ▇▁▁▂▃ |
numeric | motor.fuel | 0 | 1.0000000 | NA | NA | NA | NA | NA | 221.88661 | 54.444127 | 118.700 | 180.20975 | 215.2075 | 269.5430 | 392.904 | ▃▇▅▃▁ |
numeric | gasoline.all.types | 0 | 1.0000000 | NA | NA | NA | NA | NA | 220.96549 | 54.250135 | 118.300 | 179.28875 | 214.2075 | 268.3068 | 391.297 | ▃▇▅▃▁ |
numeric | motor.vehicle.insurance | 191 | 0.2041667 | NA | NA | NA | NA | NA | 758.50288 | 22.237984 | 681.767 | 745.22800 | 757.9260 | 777.2240 | 792.842 | ▁▁▅▇▇ |
numeric | gasoline.unleaded.regular | 0 | 1.0000000 | NA | NA | NA | NA | NA | 221.76810 | 55.030858 | 118.800 | 178.30800 | 216.3445 | 269.1218 | 391.120 | ▅▇▅▃▁ |
numeric | gasoline.unleaded.midgrade | 0 | 1.0000000 | NA | NA | NA | NA | NA | 225.79582 | 54.028201 | 118.700 | 191.54000 | 219.8115 | 272.9248 | 398.842 | ▃▇▅▃▁ |
numeric | gasoline.unleaded.premium | 0 | 1.0000000 | NA | NA | NA | NA | NA | 224.42657 | 52.420142 | 119.600 | 193.96250 | 220.1980 | 267.3587 | 396.448 | ▃▇▅▂▁ |
The summary table shows that the data has some missing are missing values. I use the plot below to visualize where the missing values are located to try to understand how to deal with them.
cpi_use %>% missmap(main = "Observed vs Missing Data")
The chart above shows that, overall, about 15 percent of the rows are have missing values. However, most of the missing data are from earlier years when BLS did not collect CPI data for those variables. Those missing values do not need to be replaced or removed as they will not affect our analysis in any way.
From the chart, it appears there are no recent data for
Motor Vehicle Insurance
. It appears that the BLS has
discontinued the CPI series for the item as of the end of 2021. Hence, I
remove the CPI series for Motor Vehicle Insurance
from the
data in the section below.
In this section, I remove Motor Vehicle Insurance
from
the data as explained above. I also drop the period
column
as it is not needed for this analysis.
Finally, I change the data type for the year
field from
character to number and create a new field called date
,
which combines the month
and year
columns.
cpi_use <-
cpi_use %>%
select(-period, -motor.vehicle.insurance) %>%
mutate(year = as.numeric(year),
date = as.POSIXct(strptime(paste0('1',cpi_use$periodName,cpi_use$year),'%d%B%Y'))
)
In calculating inflation, I do a year-over-year comparison since the CPI data used in this analysis are not seasonally adjusted. I compare CPI for the month to CPI for the same month of the previous year.
The code chunk below calculates 12-month percent change in CPI per
month for all the components and stores that in a new data frame called
monthly_pchg
.
monthly_pchg <- cpi_use %>%
arrange(date) %>%
mutate(year = as.character(year)) %>%
mutate_if(is.numeric,
~round((./lag(., 12)-1), 3)) %>%
filter(year != "2003")
The table below shows the monthly inflation for all components.
year | periodName | all.items | energy | all.items.less.food.energy | all.items.less.shelter | all.items.less.medical.care | all.items.less.energy | apparel | commodities | commodities.less.food | commodities.less.food.beverages | durables | education.communication | education.communication.commodities | education.communication.services | food.beverages | food | food.at.home | cereals.bakery.products | meats.poultry.fish.egg | fruits.vegetables | nonalcoholic.beverages.beverage.materials | other.food.at.home | alcoholic.beverages | other.goods.services | other.goods | other.personal.services | housing | shelter | fuels.utilities | household.energy | household.furnishing.operations | household.furnishing.supplies | medical.care | nondurables | nondurables.less.food | nondurables.less.food.beverages | recreation | services | services.less.rent.of.shelter | services.less.medical.services | transportation | private.transportation | transportation.commodities.less.motor.fuel | tuition.other.school.fees.childcare | dairy.related.products | food.away.from.home | rent.of.primary.residence | owners.equivalent.rent.of.residences | owners.equivalent.rent.of.primary.residence | value | electricity | utility.piped.gas.services | new.used.motor.vehicles | new.vehicles | used.cars.trucks | motor.fuel | gasoline.all.types | gasoline.unleaded.regular | gasoline.unleaded.midgrade | gasoline.unleaded.premium | date |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2022 | January | 0.051 | 0.285 | 0.033 | 0.074 | 0.053 | 0.038 | 0.010 | 0.102 | 0.123 | 0.130 | 0.172 | 0.029 | -0.007 | 0.031 | 0.071 | 0.075 | 0.076 | 0.086 | 0.160 | 0.012 | 0.066 | 0.058 | 0.011 | 0.043 | 0.045 | 0.038 | 0.034 | 0.015 | 0.188 | 0.214 | 0.073 | 0.094 | 0.033 | 0.085 | 0.097 | 0.105 | 0.071 | 0.030 | 0.049 | 0.029 | 0.131 | 0.179 | 0.229 | 0.024 | 0.038 | 0.074 | 0.006 | 0.018 | 0.018 | 0.191 | 0.202 | 0.167 | 0.184 | 0.146 | 0.416 | 0.395 | 0.396 | 0.408 | 0.354 | 0.315 | 2022-01-01 |
2022 | February | 0.051 | 0.157 | 0.040 | 0.072 | 0.053 | 0.045 | 0.027 | 0.110 | 0.132 | 0.139 | 0.182 | 0.032 | 0.021 | 0.032 | 0.076 | 0.081 | 0.091 | 0.090 | 0.170 | 0.057 | 0.055 | 0.069 | 0.014 | 0.075 | 0.051 | 0.085 | 0.025 | 0.019 | 0.026 | 0.024 | 0.083 | 0.104 | 0.032 | 0.092 | 0.107 | 0.115 | 0.079 | 0.026 | 0.035 | 0.025 | 0.140 | 0.177 | 0.241 | 0.024 | 0.054 | 0.065 | 0.012 | 0.022 | 0.022 | -0.019 | -0.103 | 0.164 | 0.190 | 0.159 | 0.427 | 0.374 | 0.375 | 0.387 | 0.332 | 0.298 | 2022-02-01 |
2022 | March | 0.061 | 0.327 | 0.041 | 0.086 | 0.063 | 0.046 | 0.051 | 0.119 | 0.147 | 0.153 | 0.159 | 0.026 | -0.022 | 0.030 | 0.077 | 0.080 | 0.094 | 0.116 | 0.141 | 0.045 | 0.064 | 0.114 | 0.030 | 0.052 | 0.062 | 0.045 | 0.041 | 0.021 | 0.193 | 0.223 | 0.094 | 0.115 | 0.040 | 0.112 | 0.152 | 0.163 | 0.083 | 0.036 | 0.053 | 0.035 | 0.147 | 0.174 | 0.216 | 0.024 | 0.033 | 0.060 | 0.014 | 0.024 | 0.024 | 0.175 | 0.195 | 0.138 | 0.154 | 0.151 | 0.370 | 0.475 | 0.475 | 0.485 | 0.441 | 0.405 | 2022-03-01 |
2022 | April | 0.063 | 0.298 | 0.044 | 0.089 | 0.065 | 0.050 | 0.021 | 0.111 | 0.127 | 0.133 | 0.131 | 0.026 | -0.030 | 0.030 | 0.085 | 0.088 | 0.100 | 0.093 | 0.132 | 0.089 | 0.068 | 0.107 | 0.032 | 0.051 | 0.041 | 0.054 | 0.041 | 0.022 | 0.185 | 0.212 | 0.089 | 0.103 | 0.046 | 0.109 | 0.134 | 0.144 | 0.079 | 0.043 | 0.069 | 0.041 | 0.155 | 0.176 | 0.173 | 0.025 | 0.072 | 0.069 | 0.014 | 0.025 | 0.025 | 0.146 | 0.126 | 0.189 | 0.168 | 0.150 | 0.236 | 0.421 | 0.420 | 0.427 | 0.402 | 0.370 | 2022-04-01 |
2022 | May | 0.063 | 0.375 | 0.036 | 0.088 | 0.064 | 0.044 | 0.055 | 0.125 | 0.145 | 0.150 | 0.118 | 0.025 | -0.037 | 0.030 | 0.093 | 0.096 | 0.111 | 0.100 | 0.146 | 0.087 | 0.099 | 0.121 | 0.051 | 0.042 | 0.047 | 0.038 | 0.043 | 0.022 | 0.229 | 0.261 | 0.072 | 0.081 | 0.044 | 0.131 | 0.174 | 0.185 | 0.078 | 0.035 | 0.051 | 0.033 | 0.126 | 0.150 | 0.162 | 0.025 | 0.076 | 0.073 | 0.018 | 0.027 | 0.027 | 0.177 | 0.130 | 0.284 | 0.079 | 0.167 | 0.170 | 0.537 | 0.534 | 0.542 | 0.504 | 0.485 | 2022-05-01 |
2022 | June | 0.067 | 0.392 | 0.041 | 0.096 | 0.067 | 0.048 | 0.039 | 0.121 | 0.141 | 0.146 | 0.087 | 0.020 | -0.045 | 0.025 | 0.089 | 0.091 | 0.101 | 0.160 | 0.100 | 0.046 | 0.120 | 0.118 | 0.051 | 0.052 | 0.025 | 0.065 | 0.042 | 0.021 | 0.218 | 0.247 | 0.069 | 0.077 | 0.068 | 0.134 | 0.188 | 0.200 | 0.051 | 0.043 | 0.072 | 0.040 | 0.163 | 0.192 | 0.126 | 0.022 | 0.083 | 0.075 | 0.023 | 0.031 | 0.031 | 0.173 | 0.118 | 0.299 | 0.122 | 0.164 | 0.080 | 0.604 | 0.602 | 0.607 | 0.578 | 0.570 | 2022-06-01 |
2022 | July | 0.065 | 0.306 | 0.042 | 0.091 | 0.065 | 0.051 | 0.029 | 0.114 | 0.122 | 0.125 | 0.091 | 0.018 | -0.052 | 0.025 | 0.099 | 0.102 | 0.119 | 0.165 | 0.108 | 0.087 | 0.109 | 0.149 | 0.057 | 0.044 | 0.031 | 0.051 | 0.040 | 0.023 | 0.173 | 0.195 | 0.083 | 0.091 | 0.070 | 0.123 | 0.150 | 0.158 | 0.048 | 0.043 | 0.068 | 0.039 | 0.153 | 0.183 | 0.121 | 0.026 | 0.096 | 0.075 | 0.028 | 0.033 | 0.033 | 0.134 | 0.074 | 0.265 | 0.155 | 0.161 | 0.071 | 0.461 | 0.459 | 0.459 | 0.462 | 0.465 | 2022-07-01 |
2022 | August | 0.066 | 0.257 | 0.046 | 0.089 | 0.065 | 0.054 | 0.010 | 0.100 | 0.099 | 0.101 | 0.089 | 0.016 | -0.048 | 0.022 | 0.098 | 0.102 | 0.119 | 0.160 | 0.093 | 0.104 | 0.121 | 0.147 | 0.052 | 0.033 | 0.005 | 0.047 | 0.047 | 0.028 | 0.195 | 0.221 | 0.085 | 0.098 | 0.073 | 0.106 | 0.112 | 0.117 | 0.049 | 0.050 | 0.078 | 0.047 | 0.145 | 0.159 | 0.119 | 0.029 | 0.102 | 0.073 | 0.029 | 0.035 | 0.035 | 0.170 | 0.101 | 0.328 | 0.168 | 0.145 | 0.085 | 0.304 | 0.302 | 0.298 | 0.321 | 0.332 | 2022-08-01 |
2022 | September | 0.062 | 0.181 | 0.050 | 0.079 | 0.061 | 0.055 | 0.022 | 0.074 | 0.066 | 0.066 | 0.065 | 0.010 | -0.063 | 0.017 | 0.083 | 0.085 | 0.100 | 0.130 | 0.083 | 0.078 | 0.073 | 0.133 | 0.065 | 0.031 | 0.003 | 0.046 | 0.049 | 0.035 | 0.182 | 0.204 | 0.050 | 0.061 | 0.083 | 0.078 | 0.071 | 0.072 | 0.029 | 0.057 | 0.086 | 0.053 | 0.135 | 0.141 | 0.089 | 0.024 | 0.108 | 0.060 | 0.030 | 0.040 | 0.040 | 0.161 | 0.101 | 0.291 | 0.181 | 0.097 | 0.075 | 0.143 | 0.141 | 0.134 | 0.172 | 0.191 | 2022-09-01 |
2022 | October | 0.060 | 0.150 | 0.049 | 0.072 | 0.059 | 0.055 | 0.008 | 0.066 | 0.052 | 0.050 | 0.045 | 0.009 | -0.094 | 0.019 | 0.085 | 0.086 | 0.104 | 0.167 | 0.066 | 0.105 | 0.100 | 0.115 | 0.073 | 0.038 | 0.052 | 0.030 | 0.055 | 0.041 | 0.184 | 0.204 | 0.058 | 0.071 | 0.079 | 0.075 | 0.062 | 0.061 | 0.037 | 0.058 | 0.079 | 0.054 | 0.099 | 0.104 | 0.062 | 0.027 | 0.101 | 0.059 | 0.033 | 0.042 | 0.042 | 0.147 | 0.100 | 0.241 | 0.129 | 0.088 | 0.021 | 0.072 | 0.069 | 0.062 | 0.099 | 0.120 | 2022-10-01 |
2022 | November | 0.059 | 0.177 | 0.045 | 0.067 | 0.058 | 0.051 | 0.005 | 0.064 | 0.048 | 0.048 | 0.028 | 0.018 | -0.062 | 0.027 | 0.085 | 0.086 | 0.104 | 0.158 | 0.044 | 0.094 | 0.113 | 0.137 | 0.062 | 0.041 | 0.024 | 0.049 | 0.060 | 0.045 | 0.210 | 0.234 | 0.056 | 0.060 | 0.066 | 0.078 | 0.068 | 0.068 | 0.012 | 0.056 | 0.071 | 0.054 | 0.079 | 0.084 | 0.034 | 0.027 | 0.128 | 0.060 | 0.041 | 0.048 | 0.048 | 0.156 | 0.122 | 0.222 | 0.077 | 0.071 | -0.028 | 0.100 | 0.097 | 0.089 | 0.125 | 0.150 | 2022-11-01 |
2022 | December | 0.063 | 0.133 | 0.054 | 0.068 | 0.064 | 0.059 | 0.007 | 0.053 | 0.030 | 0.028 | 0.010 | 0.019 | -0.094 | 0.031 | 0.085 | 0.086 | 0.101 | 0.160 | 0.046 | 0.113 | 0.097 | 0.126 | 0.076 | 0.029 | 0.036 | 0.025 | 0.068 | 0.055 | 0.203 | 0.226 | 0.061 | 0.065 | 0.058 | 0.068 | 0.046 | 0.044 | 0.028 | 0.069 | 0.086 | 0.068 | 0.082 | 0.087 | 0.016 | 0.032 | 0.094 | 0.063 | 0.049 | 0.054 | 0.054 | 0.184 | 0.157 | 0.232 | 0.113 | 0.082 | -0.083 | 0.007 | 0.005 | -0.007 | 0.054 | 0.085 | 2022-12-01 |
In this section, I use bar charts to depict inflation in the NY-Metro area for the current month - December 2022.
The chart in the first tab depicts headline and core inflation, while the second tab shows inflation for some of the important CPI components.
monthly_pchg %>% select(date, all.items, all.items.less.food.energy) %>%
filter(date == max(date)) %>%
rename('Headline' = all.items,
'Core' = all.items.less.food.energy) %>%
pivot_longer(cols = 2:3,
names_to = "Item",
values_to = "p_chg",
values_drop_na = T) %>%
ggplot(aes(x = Item, y = p_chg)) +
geom_bar(position = 'dodge', fill = '#bb969a', stat = "identity") +
scale_y_continuous(labels = percent) +
geom_text(aes(label = percent(p_chg, accuracy = .1))) +
theme_economist() +
theme(panel.grid = element_blank()) +
labs(x = NULL,
y = "Inflation Rate (%)",
title = "YoY Change in Inflation, Dec. 2022",
subtitle = "Healine and Core CPI",
caption = "Non seasonally adjusted data")
monthly_pchg %>%
select(date, food, rent.of.primary.residence,household.energy,
medical.care, apparel, tuition.other.school.fees.childcare,
recreation, new.used.motor.vehicles, gasoline.all.types, energy) %>%
rename('Food' = food,
'Rent' = rent.of.primary.residence,
'Home utilities' = household.energy,
'Medical Care' = medical.care,
'Apparel' = apparel,
'Tuition & Child Care' = tuition.other.school.fees.childcare,
'Recreation' = recreation,
'Vehicles' = new.used.motor.vehicles,
'Gasoline' = gasoline.all.types,
'Energy' = energy) %>%
filter(date == max(date)) %>%
pivot_longer(cols = 2:11,
names_to = "item",
values_to = "p_chg",
values_drop_na = T) %>%
ggplot(aes(x = reorder(item, -p_chg),
y = p_chg)
) +
geom_bar(position='dodge', fill = '#bb969a', stat='identity') +
#facet_wrap(~item) +
scale_y_continuous(labels = percent) +
geom_text(aes(label = percent(p_chg, accuracy = .1))) +
coord_flip() +
theme_economist() +
theme(panel.grid.major = element_blank()) +
labs(x = NULL,
y = "Inflation Rate (%)",
title = "YoY Change in Prices, Dec. 2022",
subtitle = "Select CPI Prices",
caption = "Not seasonally adjusted")
In this section, I use line graphs to depict the trend in monthly inflation, highlighting the recent spikes in the prices of certain items.
monthly_pchg %>% select(date, all.items, all.items.less.food.energy) %>%
rename('Headline' = all.items,
'Core' = all.items.less.food.energy) %>%
pivot_longer(cols = 2:3, names_to = "Component:",
values_to = "p_chg", values_drop_na = T) %>%
ggplot(aes(x = date, y = p_chg)) +
geom_line(aes(color = `Component:`), lwd = 1) +
scale_y_continuous(labels = percent) +
scale_color_manual(values = c("#bb969a", "#00578a")) +
geom_hline(yintercept = 0, color = "White") +
theme_economist() +
theme(panel.grid.major = element_blank()) +
labs(x = NULL,
y = "Inflation Rate (%)",
title = "YoY Change in Prices",
subtitle = "Headline & Core Inflation",
caption = "Not seasonally adjusted")
monthly_pchg %>% select(date, gasoline.unleaded.regular, gasoline.unleaded.midgrade,
gasoline.unleaded.premium) %>%
rename(Regular = gasoline.unleaded.regular,
Midgrade = gasoline.unleaded.midgrade,
Premium = gasoline.unleaded.premium) %>%
pivot_longer(cols = 2:4, names_to = "Component:",
values_to = "p_chg", values_drop_na = T) %>%
ggplot(aes(x = date, y = p_chg)) +
geom_line(aes(color = `Component:`), lwd = 1) +
geom_hline(yintercept = 0, color = "White") +
scale_y_continuous(labels = percent) +
scale_color_manual(values = c("#ff8181" ,"#bb969a", "#00578a")) +
theme_economist() +
theme(panel.grid.major = element_blank()) +
labs(x = NULL,
y = "Inflation Rate (%)",
title = "YoY Change in Gas Prices",
caption = "Not seasonally adjusted")
monthly_pchg %>%
select(date, food.at.home, food.away.from.home) %>%
rename(`Food at Home` = food.at.home, `Food From Outside` = food.away.from.home) %>%
pivot_longer(cols = 2:3, names_to = "Component:",
values_to = "p_chg", values_drop_na = T) %>%
ggplot(aes(x = date, y = p_chg)) +
geom_line(aes(color = `Component:`), lwd = 1) +
geom_hline(yintercept = 0, color = "White") +
scale_y_continuous(labels = percent) +
scale_color_manual(values = c("#bb969a", "#00578a")) +
theme_economist() +
theme(panel.grid.major = element_blank()) +
labs(x = NULL,
y = "Inflation Rate (%)",
title = "YoY Change in Food Prices",
subtitle = "Food at Home vs. Food From Outside",
caption = "Not seasonally adjusted")
monthly_pchg %>%
select(date, meats.poultry.fish.egg, fruits.vegetables,
cereals.bakery.products, dairy.related.products) %>%
rename(`Meat,Poultry,Fish,Eggs` = meats.poultry.fish.egg, `Fruits & Veggies` = fruits.vegetables,
`Cereal & Baked Goods` = cereals.bakery.products, Dairy = dairy.related.products) %>%
pivot_longer(cols = 2:5, names_to = "Component:",
values_to = "p_chg", values_drop_na = T) %>%
ggplot(aes(x = date, y = p_chg)) +
geom_line(aes(color = `Component:`), lwd = 1) +
geom_hline(yintercept = 0, color = "White") +
scale_y_continuous(labels = percent) +
scale_color_manual(values = c("#ff8181" ,"#bb969a", "#00578a", "#ff8c00")) +
theme_economist() +
theme(panel.grid.major = element_blank()) +
labs(x = NULL,
y = "Inflation Rate (%)",
title = "YoY Change in Food Prices",
subtitle = "Select Food Items",
caption = "Not seasonally adjusted")
monthly_pchg %>%
select(date, rent.of.primary.residence, owners.equivalent.rent.of.primary.residence) %>%
rename(Rent = rent.of.primary.residence,
Mortgage = owners.equivalent.rent.of.primary.residence) %>%
pivot_longer(cols = 2:3, names_to = "Component:",
values_to = "p_chg", values_drop_na = T) %>%
ggplot(aes(x = date, y = p_chg)) +
geom_line(aes(color = `Component:`), lwd = 1) +
geom_hline(yintercept = 0, color = "White") +
scale_y_continuous(labels = percent) +
scale_color_manual(values = c("#bb969a", "#00578a")) +
theme_economist() +
theme(panel.grid.major = element_blank()) +
labs(x = NULL,
y = "Inflation Rate (%)",
title = "YoY Change in Shelter Prices",
caption = "Not seasonally adjusted")
monthly_pchg %>%
select(date, new.vehicles, used.cars.trucks) %>%
rename(`New Vehicle` = new.vehicles,
`Used Vehicle` = used.cars.trucks) %>%
pivot_longer(cols = 2:3, names_to = "Component:",
values_to = "p_chg", values_drop_na = T) %>%
ggplot(aes(x = date, y = p_chg)) +
geom_line(aes(color = `Component:`), lwd = 1) +
geom_hline(yintercept = 0, color = "White") +
scale_y_continuous(labels = percent) +
scale_color_manual(values = c("#bb969a", "#00578a")) +
theme_economist() +
theme(panel.grid.major = element_blank()) +
labs(x = NULL,
y = "Inflation Rate (%)",
title = "YoY Change in Vehicle Prices",
caption = "Not seasonally adjusted")
In this section, I forecast headline inflation for the next 12 months using ARIMA time series models.
First, I convert the monthly headline inflation series to a time series object to allow for forecasting.
headline <-
monthly_pchg %>%
select(date, all.items) %>%
mutate(all.items = all.items*100) %>%
mutate(date = as.Date(date)) %>%
arrange(date) %>%
select(-date)
h_ts <-
headline %>%
ts(start = c(2004, 1), end = c(2022, 12), frequency = 12)
Take a quick look at the summary of the time series
summary(h_ts)
## all.items
## Min. :-1.100
## 1st Qu.: 1.475
## Median : 2.050
## Mean : 2.405
## 3rd Qu.: 3.400
## Max. : 6.700
A plot of the time series.
library(ggfortify)
autoplot(h_ts) +
theme_economist() +
labs(title = "Inflation Rate in NY-Metro Area",
x = "Month",
y = "Infaltion Rate (%)")
library(TSstudio)
ts_decompose(h_ts, type = "additive", showline = TRUE)
library(gridExtra)
library(forecast)
grid.arrange(
ggAcf(h_ts) + labs(title = "ACF of the Series"),
ggPacf(h_ts) + labs(title = "PACF of the Series"),
ncol = 2)
The ACF and PACF graphs show significant lags suggesting that the time series may not be stationary, and may require differencing. But before differencing, I use the Augment Dickey Fuller, Phillips Perron and KPSS tests to verify if the series is truly non-stationary.3
library(tseries)
adf.test(h_ts, k=2)
##
## Augmented Dickey-Fuller Test
##
## data: h_ts
## Dickey-Fuller = -2.3465, Lag order = 2, p-value = 0.4304
## alternative hypothesis: stationary
kpss.test(h_ts)
##
## KPSS Test for Level Stationarity
##
## data: h_ts
## KPSS Level = 0.6546, Truncation lag parameter = 4, p-value = 0.01767
pp.test(h_ts)
##
## Phillips-Perron Unit Root Test
##
## data: h_ts
## Dickey-Fuller Z(alpha) = -9.7606, Truncation lag parameter = 4, p-value
## = 0.5607
## alternative hypothesis: stationary
From above, all three tests agree that the series is non-stationary.
To make the series stationary, I take the first difference as shown below.
dh_ts <- diff(h_ts)
grid.arrange(
ggAcf(dh_ts) + labs(title = "ACF of the Series (Difference)"),
ggPacf(dh_ts) + labs(title = "PACF of the Series (Difference)"),
ncol = 2)
After that, I use the three test to verify stationarity of the series.
adf.test(dh_ts, k=2)
##
## Augmented Dickey-Fuller Test
##
## data: dh_ts
## Dickey-Fuller = -10.19, Lag order = 2, p-value = 0.01
## alternative hypothesis: stationary
kpss.test(dh_ts)
##
## KPSS Test for Level Stationarity
##
## data: dh_ts
## KPSS Level = 0.13676, Truncation lag parameter = 4, p-value = 0.1
pp.test(dh_ts)
##
## Phillips-Perron Unit Root Test
##
## data: dh_ts
## Dickey-Fuller Z(alpha) = -164.02, Truncation lag parameter = 4, p-value
## = 0.01
## alternative hypothesis: stationary
From the tests above, differencing the series makes the series stationary.
Partition the data into training and testing sets.
split_ts <- ts_split(h_ts, sample.out = 12)
train <- split_ts$train
test <- split_ts$test
To determine the ARIMA terms to include in the model, plot the diagnostics of the training set.
arima_diag(train)
From the diagnostics plots, I can manually (using try-and-error)
determine the ARIMA terms to include. However, I am going to use the
auto.arima
function in R to automatically determine the
lags to include.
auto_ARIMA <- auto.arima(train, seasonal = TRUE)
summary(auto_ARIMA)
## Series: train
## ARIMA(3,1,0)(0,0,2)[12]
##
## Coefficients:
## ar1 ar2 ar3 sma1 sma2
## 0.2591 0.0161 -0.1635 -0.8497 0.1172
## s.e. 0.0677 0.0705 0.0691 0.0750 0.0775
##
## sigma^2 = 0.1152: log likelihood = -75.65
## AIC=163.3 AICc=163.7 BIC=183.52
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set -0.01293795 0.3346637 0.2518327 NaN Inf 0.2099463 0.0005029017
The above suggests an ARIMA terms of 3,1,0 with seasonal ARIMA terms of 0,0,2.
Plot the diagnostics of the model to make sure there are no unit roots.
autoplot(auto_ARIMA)
The plot above shows that the model has no unit roots as all the roots are inside the unit circle.
Also, the residuals plot below shows no lags, which is a good thing.
check_res(auto_ARIMA)
In Sample Forecast
fcst_test <- forecast(auto_ARIMA, h = 12)
test_forecast(actual = h_ts, forecast.obj = fcst_test, test = test)
Check the accuracy of the model against the training set.
accuracy(fcst_test, test)
## ME RMSE MAE MPE MAPE MASE
## Training set -0.01293795 0.3346637 0.2518327 NaN Inf 0.2099463
## Test set 3.11170975 3.3416635 3.1117097 49.95008 49.95008 2.5941512
## ACF1 Theil's U
## Training set 0.0005029017 NA
## Test set 0.6697816550 8.012649
Fit an ARIMA model on the full data set.
fit.ARIMA <- auto.arima(h_ts, seasonal = TRUE)
summary(fit.ARIMA)
## Series: h_ts
## ARIMA(3,1,0)(0,0,1)[12]
##
## Coefficients:
## ar1 ar2 ar3 sma1
## 0.2321 0.0852 -0.1462 -0.7433
## s.e. 0.0657 0.0674 0.0669 0.0564
##
## sigma^2 = 0.1278: log likelihood = -91.51
## AIC=193.01 AICc=193.28 BIC=210.14
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 0.003540943 0.3536097 0.261896 NaN Inf 0.2034875 0.000593896
Now, check the diagnostics residuals of the model.
autoplot(fit.ARIMA)
check_res(fit.ARIMA)
Use the model to forecast inflation for the next 12 months.
forecast <- forecast(h_ts, model = fit.ARIMA, h = 12)
summary(forecast)
##
## Forecast method: ARIMA(3,1,0)(0,0,1)[12]
##
## Model Information:
## Series: object
## ARIMA(3,1,0)(0,0,1)[12]
##
## Coefficients:
## ar1 ar2 ar3 sma1
## 0.2321 0.0852 -0.1462 -0.7433
## s.e. 0.0000 0.0000 0.0000 0.0000
##
## sigma^2 = 0.1278: log likelihood = -91.51
## AIC=185.01 AICc=185.03 BIC=188.44
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 0.003540943 0.3536097 0.261896 NaN Inf 0.2034875 0.000593896
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Jan 2023 5.950319 5.492097 6.408542 5.2495284 6.651110
## Feb 2023 5.883115 5.155977 6.610252 4.7710533 6.995176
## Mar 2023 4.922274 3.961281 5.883268 3.4525615 6.391987
## Apr 2023 4.427260 3.302113 5.552407 2.7064967 6.148024
## May 2023 4.312164 3.053098 5.571230 2.3865886 6.237740
## Jun 2023 3.533484 2.160570 4.906398 1.4337929 5.633174
## Jul 2023 3.855999 2.377800 5.334198 1.5952880 6.116710
## Aug 2023 3.742073 2.165065 5.319082 1.3302464 6.153900
## Sep 2023 3.886025 2.215059 5.556991 1.3305029 6.441547
## Oct 2023 3.835487 2.075336 5.595638 1.1435684 6.527405
## Nov 2023 3.562700 1.717610 5.407790 0.7408778 6.384522
## Dec 2023 3.408501 1.482306 5.334696 0.4626405 6.354362
Plot the forecast with the actuals.
plot_forecast(forecast) %>%
layout(
title = "Actual & Forecasted Inflation Rates",
xaxis = list(title = ""),
yaxis = list(title = "Inflation Rate",
ticksuffix = "%")
)
Headline and Core Inflation
Driven by a 39 percent surge in energy prices, headline inflation in the NY-Metro Area peaked at 6.7 percent in June 2022. Since then, headline inflation has gradually declined each month, dropping to 5.9 percent as of November 2022. However, inflation accelerated to 6.3 percent in December 2022 - the highest jump in any December since at least 2005.
At 5.4 percent, core inflation hit a new high in recent times in December 2022. The December surge came on the heels of a three-month consecutive decline.
Headline Inflation Forecast
Headline inflation in the NY-Metro Area will fall from 6.3 percent in December 2022 to six percent in January 2023. Prices will continue to decline gradually each month after that, with headline inflation dropping to 3.4 percent by December that year. Nonetheless, inflation does not fall to the Federal Reserve’s target rate of two percent over the next 12 months, in which case, the Federal Reserve will persist with its interest rate hikes beyond this year.
See child 1.Rmd
file for the API used to
extract and transform the data↩︎
Since the BLS API only allows a maximum of 50 variables or items per API request, the download process is broken into two parts - first 50 variables and last 11 variables↩︎
Note that, the ADF and Phillips Perron tests are unit root tests with null hypothesis that “the series is not stationary or has is unit root.” The KPSS test, on the other hand, is a stationarity test, with the null hypothesis that “the series is stationary or does not have unit root↩︎