library(csodata)
library(tidyverse)
library(knitr)
library(kableExtra)
library(ggplot2)
library(lubridate)
library(ggrepel)
library(zoo)
library(sf)
library(tmap)
library(rgdal)
library(readxl)

#Load
CPM01 <- cso_get_data("CPM01") # Selected Sub Indices
CPM03 <- cso_get_data("CPM03") # Selected Sub Indices
CPM11 <- cso_get_data("CPM11") # Contributions to changes in the Consumer Price Index
CPM15 <- cso_get_data("CPM15") # Harmonised Index of Consumer Prices

#Long
CPM01_long <- CPM01 %>%
  pivot_longer(!1:2, names_to = "year_month")
CPM01<- CPM01_long
rm(CPM01_long)
CPM01$Year <-substr(CPM01$year_month,1,4)
CPM01$Month <- sub(".* ", "", CPM01$year_month)
CPM01$Month_NR <- as.integer(factor(CPM01$Month, levels=month.name))
CPM01$Date <- as.yearmon(paste(CPM01$Year, CPM01$Month_NR), "%Y %m")

CPM03_long <- CPM03 %>%
  pivot_longer(!1:2, names_to = "year_month")
CPM03<- CPM03_long
rm(CPM03_long)
CPM03$Year <-substr(CPM03$year_month,1,4)
CPM03$Month <- sub(".* ", "", CPM03$year_month)
CPM03$Month_NR <- as.integer(factor(CPM03$Month, levels=month.name))
CPM03$Date <- as.yearmon(paste(CPM03$Year, CPM03$Month_NR), "%Y %m")

CPM11_long <- CPM11 %>%
  pivot_longer(!1:2, names_to = "year_month")
CPM11<- CPM11_long
rm(CPM11_long)
CPM11$Year <-substr(CPM11$year_month,1,4)
CPM11$Month <- sub(".* ", "", CPM11$year_month)
CPM11$Month_NR <- as.integer(factor(CPM11$Month, levels=month.name))
CPM11$Date <- as.yearmon(paste(CPM11$Year, CPM11$Month_NR), "%Y %m")

CPM15_long <- CPM15 %>%
  pivot_longer(!1:2, names_to = "year_month")
CPM15<- CPM15_long
rm(CPM15_long)
CPM15$Year <-substr(CPM15$year_month,1,4)
CPM15$Month <- sub(".* ", "", CPM15$year_month)
CPM15$Month_NR <- as.integer(factor(CPM15$Month, levels=month.name))
CPM15$Date <- as.yearmon(paste(CPM15$Year, CPM15$Month_NR), "%Y %m")

# Translate/Merge Files
COICOP<- read_excel("/Users/charten/OneDrive - Glenveagh Properties/Research & Development/1. Analysis/COICOP.xlsx")
COICOPDIV <- COICOP %>%
  filter(`Level 1` == "1")
COICOP <- COICOPDIV
rm(COICOPDIV)

There are a number of Consumer Price Index datasets which are updated monthly by the CSO. https://data.cso.ie/ As of July 2022 there are two datasets described and plotted to some degree with two additional sets being added on the future releases from the CSO. See title and date for version, use links in table of contents to navigate.

# Subset for Analysis
## CPM01_1 = All Items, Percentage Change over 12 months for Consumer Price Index (%)
CPM01_1 <- CPM01%>%
  filter(Statistic == "Percentage Change over 12 months for Consumer Price Index (%)")%>%
  filter(Commodity.Group == "All items")
## CPM01_1A = All Items, Percentage Change over 12 months for Consumer Price Index (%)
CPM01_1A <- CPM01%>%
  filter(Statistic == "Percentage Change over 12 months for Consumer Price Index (%)")%>%
  filter(Commodity.Group == "All items")%>%
  filter(Year >= 2016)
## CPM01_1B = All Items, Consumer Price Index (Base Dec 2016=100)
CPM01_1B <- CPM01%>%
  filter(Statistic == "Percentage Change over 12 months for Consumer Price Index (%)")%>%
  filter(Commodity.Group == "All items")%>%
  filter(Year >= 2020)
## CPM01_2 = All Items, Consumer Price Index (Base Dec 2016=100)
CPM01_2 <- CPM01%>%
  filter(Statistic == "Consumer Price Index (Base Dec 2016=100)")%>%
  filter(Commodity.Group == "All items")%>%
  filter(Year >= 1997)
## CPM01_2A = All Items, Consumer Price Index (Base Dec 2016=100)
CPM01_2A <- CPM01%>%
  filter(Statistic == "Consumer Price Index (Base Dec 2016=100)")%>%
  filter(Commodity.Group == "All items")%>%
  filter(Year >= 2020)


## CPM03_1 = Percentage Change over 12 months for Consumer Price Index (%)
CPM03_1 <- CPM03%>%
  filter(Statistic == "Percentage Change over 12 months for Consumer Price Index (%)")%>%
  filter(Selected.Sub.Indices == "Energy Products" |Selected.Sub.Indices == "CPI excluding Energy Products" |Selected.Sub.Indices == "Mortgage Interest")
## CPM03_2 = Consumer Price Index (Base Dec 2016=100) >= 2016
CPM03_2 <- CPM03%>%
  filter(Statistic == "Percentage Change over 12 months for Consumer Price Index (%)")%>%
  filter(Selected.Sub.Indices == "Energy Products" |Selected.Sub.Indices == "CPI excluding Energy Products" |Selected.Sub.Indices == "Mortgage Interest")%>%
    filter(Year >= 2016)

Headline & Summary

CPM01_tail_2 <- tail(CPM01_1,1)
CPM01_tail_2_lag <-head(tail(CPM01_1,2),1)

The headline inflation for June is 9.1%. This represents a 1.3 percentage change from May which was 7.8%.

CPM01_trim <- subset(CPM01_1, select = -c(Statistic, year_month, Month, Year, Month_NR))
CPM01_tail1 <- kable(tail(CPM01_trim), caption = "Percentage Change over 12 months")
CPM01_tail1 %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = F) %>%
  row_spec(6, bold = T)%>%
  pack_rows("Latest Period", 6, 6, color="#1b5545")
Percentage Change over 12 months
Commodity.Group value Date
All items 5.0 Jan 2022
All items 5.6 Feb 2022
All items 6.7 Mar 2022
All items 7.0 Apr 2022
All items 7.8 May 2022
Latest Period
All items 9.1 Jun 2022
rm(CPM01_trim)
colour_set <- ifelse(CPM01_1B$value < 0,"#CC0000","#007589")
FigCPM01_1B <- ggplot(data=CPM01_1B,aes(x=Date,y=value))+
  geom_col(fill= colour_set, alpha = 0.5)+
  labs(title = "CPI - CSO: CPM01", subtitle = "2020 to Date")+
  xlab("Year-Month")+
  ylab("Percentage Change over 12 months")+
  theme(panel.border = element_rect(linetype = 1, fill = NA))+
  geom_text(data=CPM01_1B,aes(label = value, 
            vjust= ifelse(value >=0,0.25,0.5),
            hjust= ifelse(value >=0,-0.25,1)),
            size = 2, 
            angle = 90)
FigCPM01_1B

FigCPM01_2A<- ggplot(data=CPM01_2A,aes(x=Date,y=value))+
  geom_line(size = 1.15, linetype=1, alpha = 0.6, colour = "#946627")+
  geom_hline(aes(yintercept=100), 
             colour= "#404040",
             linetype = 1)+
   labs(title = "CPI - CSO: CPM01", subtitle = "1997 to Date")+
  xlab("Year-Month")+
  ylab("Consumer Price Index (Base Dec 2016=100)")+
  theme(panel.border = element_rect(linetype = 1, fill = NA))


FigCPM01_2A


Analysis

FigCPM01_2 <- ggplot(data=CPM01_2,aes(x=Date,y=value))+
  geom_line(size = 1.15, linetype=1, alpha = 0.6, colour = "#946627")+
  geom_hline(aes(yintercept=100), 
             colour= "#404040",
             linetype = 1)+
  labs(title = "CPI - CSO: CPM01", subtitle = "2016 to Date")+
  xlab("Year-Month")+
  ylab("Consumer Price Index (Base Dec 2016=100)")+
  theme(panel.border = element_rect(linetype = 1, fill = NA))
FigCPM01_2

FigCPM03_2 <- ggplot(data=CPM03_2, aes(x=Date, y=value, group=Selected.Sub.Indices, colour=Selected.Sub.Indices))+
  scale_colour_manual(values=c("#0389bb", "#0c122f", "#88b66c"))+
  labs(title = "CPI - CSO: CPM03", subtitle = "2016 to Date, selected sub indicies")+
  xlab("Year-Month")+
  ylab("Consumer Price Index (Base Dec 2016=100)")+
  geom_line(size = 1.05, linetype=1, alpha = 0.85)+
  geom_hline(aes(yintercept=0), 
             colour= "#404040",
             linetype = 1)+
  theme(axis.text.x = element_text(angle=0))+
  theme(legend.position="bottom")+
  theme(axis.text = element_text(size = rel(1)))+
  theme(plot.title=(element_text(vjust =2)))+
  theme(panel.border = element_rect(linetype = 1, fill = NA))

FigCPM03_2

FigCPM03_1 <- ggplot(data=CPM03_1, aes(x=Date, y=value, group=Selected.Sub.Indices, colour=Selected.Sub.Indices))+
  scale_colour_manual(values=c("#0389bb", "#0c122f", "#88b66c"))+
  labs(title = "CPI - CSO: CPM03", subtitle = "Historical Series, selected sub indicies")+
  xlab("Year-Month")+
  ylab("Percentage change year on year")+
  geom_line(size = 1.05, linetype=1, alpha = 0.85)+
  geom_hline(aes(yintercept=0), 
             colour= "#404040",
             linetype = 1)+
  theme(axis.text.x = element_text(angle=0))+
  theme(legend.position="bottom")+
  theme(axis.text = element_text(size = rel(1)))+
  theme(plot.title=(element_text(vjust =2)))+
  theme(panel.border = element_rect(linetype = 1, fill = NA))

FigCPM03_1


Appendix

Display Arrays

CPM01

distinct(data.frame(CPM01$Statistic))
##                                                 CPM01.Statistic
## 1                      Consumer Price Index (Base Dec 2016=100)
## 2                      Consumer Price Index (Base Dec 2011=100)
## 3                      Consumer Price Index (Base Dec 2006=100)
## 4                      Consumer Price Index (Base Dec 2001=100)
## 5                      Consumer Price Index (Base Nov 1996=100)
## 6   Percentage Change over 1 month for Consumer Price Index (%)
## 7 Percentage Change over 12 months for Consumer Price Index (%)
distinct(data.frame(CPM01$Commodity.Group))
##                                                 CPM01.Commodity.Group
## 1                                                           All items
## 2                                    Food and non-alcoholic beverages
## 3                                     Alcoholic beverages and tobacco
## 4                                               Clothing and footwear
## 5                    Housing, water, electricity, gas and other fuels
## 6  Furnishings, household equipment and routine household maintenance
## 7                                                              Health
## 8                                                           Transport
## 9                                                      Communications
## 10                                             Recreation and culture
## 11                                                          Education
## 12                                             Restaurants and hotels
## 13                                   Miscellaneous goods and services

CPM03

distinct(data.frame(CPM03$Statistic))
##                                                 CPM03.Statistic
## 1                      Consumer Price Index (Base Dec 2016=100)
## 2                      Consumer Price Index (Base Dec 2011=100)
## 3                      Consumer Price Index (Base Dec 2006=100)
## 4                      Consumer Price Index (Base Dec 2001=100)
## 5                      Consumer Price Index (Base Nov 1996=100)
## 6   Percentage Change over 1 month for Consumer Price Index (%)
## 7 Percentage Change over 12 months for Consumer Price Index (%)
distinct(data.frame(CPM03$Selected.Sub.Indices))
##                                CPM03.Selected.Sub.Indices
## 1                                                 Alcohol
## 2                                                 Tobacco
## 3                                   CPI excluding Tobacco
## 4                                   CPI excluding Housing
## 5                         CPI excluding Mortgage Interest
## 6                           CPI excluding Energy Products
## 7                                         Energy Products
## 8                                                   Goods
## 9               CPI excluding Energy and Unprocessed Food
## 10                   Services excluding Mortgage Interest
## 11                                      Mortgage Interest
## 12                                               Services
## 13 CPI excluding Mortgage Interest and Local Property Tax
## 14                            Utilities and Local Charges

CPM11

distinct(data.frame(CPM11$Statistic))
##                                               CPM11.Statistic
## 1   Contributions to overall CPI percentage change in 1 month
## 2  Contributions to overall CPI percentage change in 3 months
## 3 Contributions to overall CPI percentage change in 12 months
distinct(data.frame(CPM11$COICOP.Group))
##                                                    CPM11.COICOP.Group
## 1                                                           All Items
## 2                                    Food and Non-Alcoholic Beverages
## 3                                     Alcoholic Beverages and Tobacco
## 4                                               Clothing and Footwear
## 5                    Housing, Water, Electricity, Gas and Other Fuels
## 6  Furnishings, Household Equipment and Routine Household Maintenance
## 7                                                              Health
## 8                                                           Transport
## 9                                                      Communications
## 10                                             Recreation and Culture
## 11                                                          Education
## 12                                             Restaurants and Hotels
## 13                                   Miscellaneous Goods and Services
## 14                                                              Goods
## 15                                                           Services
## 16                                                    Energy Products
## 17                                                            Tobacco
## 18                                                  Mortgage Interest
distinct(data.frame(COICOP$`Commodity Group`))
##                                                          COICOP..Commodity.Group.
## 1                          Alcoholic beverages, tobacco and narcotics (COICOP 02)
## 2                                                      All-items HICP (COICOP 00)
## 3                                               Clothing and footwear (COICOP 03)
## 4                                                      Communications (COICOP 08)
## 5                                                           Education (COICOP 10)
## 6                                    Food and non-alcoholic beverages (COICOP 01)
## 7  Furnishings, household equipment and routine household maintenance (COICOP 05)
## 8                                                              Health (COICOP 06)
## 9                    Housing, water, electricity, gas and other fuels (COICOP 04)
## 10                                   Miscellaneous goods and services (COICOP 12)
## 11                                             Recreation and culture (COICOP 09)
## 12                                             Restaurants and hotels (COICOP 11)
## 13                                                          Transport (COICOP 07)

CPM15

distinct(data.frame(CPM15$Statistic))
##                                   CPM15.Statistic
## 1                                         EU HICP
## 2                  Monthly rate of change in HICP
## 3                   Annual rate of change in HICP
## 4          Moving 12 months average index in HICP
## 5 Moving 12 months average rate of change in HICP
distinct(data.frame(CPM15$Commodity.Group))
##                                                                                                    CPM15.Commodity.Group
## 1                                                                                             All-items HICP (COICOP 00)
## 2                                                                           Food and non-alcoholic beverages (COICOP 01)
## 3                                                                                                     Food (COICOP 01.1)
## 4                                                                                      Bread and cereals (COICOP 01.1.1)
## 5                                                                                                   Meat (COICOP 01.1.2)
## 6                                                                                       Fish and seafood (COICOP 01.1.3)
## 7                                                                                  Milk, cheese and eggs (COICOP 01.1.4)
## 8                                                                                          Oils and fats (COICOP 01.1.5)
## 9                                                                                                  Fruit (COICOP 01.1.6)
## 10                                                                                            Vegetables (COICOP 01.1.7)
## 11                                                        Sugar, jam, honey, chocolate and confectionery (COICOP 01.1.8)
## 12                                                                                  Food products n.e.c. (COICOP 01.1.9)
## 13                                                                                 Non-alcoholic beverages (COICOP 01.2)
## 14                                                                                 Coffee, tea and cocoa (COICOP 01.2.1)
## 15                                               Mineral waters, soft drinks, fruit and vegetable juices (COICOP 01.2.2)
## 16                                                                Alcoholic beverages, tobacco and narcotics (COICOP 02)
## 17                                                                                     Alcoholic beverages (COICOP 02.1)
## 18                                                                                               Spirits (COICOP 02.1.1)
## 19                                                                                                  Wine (COICOP 02.1.2)
## 20                                                                                                  Beer (COICOP 02.1.3)
## 21                                                                                                 Tobacco (COICOP 02.2)
## 22                                                                                     Clothing and footwear (COICOP 03)
## 23                                                                                                Clothing (COICOP 03.1)
## 24                                                                                    Clothing materials (COICOP 03.1.1)
## 25                                                                                              Garments (COICOP 03.1.2)
## 26                                                   Other articles of clothing and clothing accessories (COICOP 03.1.3)
## 27                                                                 Cleaning, repair and hire of clothing (COICOP 03.1.4)
## 28                                                                                                Footwear (COICOP 03.2)
## 29                                                          Housing, water, electricity, gas and other fuels (COICOP 04)
## 30                                                                              Actual rentals for housing (COICOP 04.1)
## 31                                                                  Maintenance and repair of the dwelling (COICOP 04.3)
## 32                                              Materials for the maintenance and repair of the dwelling (COICOP 04.3.1)
## 33                                               Services for the maintenance and repair of the dwelling (COICOP 04.3.2)
## 34                                        Water supply and miscellaneous services relating to the dwelling (COICOP 04.4)
## 35                                                                                          Water supply (COICOP 04.4.1)
## 36                                                                                     Refuse collection (COICOP 04.4.2)
## 37                                                                                   Sewerage collection (COICOP 04.4.3)
## 38                                                        Other services relating to the dwelling n.e.c. (COICOP 04.4.4)
## 39                                                                        Electricity, gas and other fuels (COICOP 04.5)
## 40                                                                                           Electricity (COICOP 04.5.1)
## 41                                                                                                   Gas (COICOP 04.5.2)
## 42                                                                                          Liquid fuels (COICOP 04.5.3)
## 43                                                                                           Solid fuels (COICOP 04.5.4)
## 44                                                                                           Heat energy (COICOP 04.5.5)
## 45                                        Furnishings, household equipment and routine household maintenance (COICOP 05)
## 46                                            Furniture and furnishings, carpets and other floor coverings (COICOP 05.1)
## 47                                                                             Furniture and furnishings (COICOP 05.1.1)
## 48                                                                     Carpets and other floor coverings (COICOP 05.1.2)
## 49                                                  Repair of furniture, furnishings and floor coverings (COICOP 05.1.3)
## 50                                                                                      Household textiles (COICOP 05.2)
## 51                                                                                    Household appliances (COICOP 05.3)
## 52          Major household appliances whether electric or not and small electric household appliances (COICOP 05.3.1_2)
## 53                                                                        Repair of household appliances (COICOP 05.3.3)
## 54                                                             Glassware, tableware and household utensils (COICOP 05.4)
## 55                                                                Tools and equipment for house and garden (COICOP 05.5)
## 56                                                    Goods and services for routine household maintenance (COICOP 05.6)
## 57                                                                           Non-durable household goods (COICOP 05.6.1)
## 58                                                              Domestic services and household services (COICOP 05.6.2)
## 59                                                                                                    Health (COICOP 06)
## 60                                                              Medical products, appliances and equipment (COICOP 06.1)
## 61                                                                               Pharmaceutical products (COICOP 06.1.1)
## 62                                        Other medical products, therapeutic appliances and equipment (COICOP 06.1.2_3)
## 63                                                                                    Out-patient services (COICOP 06.2)
## 64                                                           Medical services and paramedical services (COICOP 06.2.1_3)
## 65                                                                                       Dental services (COICOP 06.2.2)
## 66                                                                                       Hospital services (COICOP 06.3)
## 67                                                                                                 Transport (COICOP 07)
## 68                                                                                    Purchase of vehicles (COICOP 07.1)
## 69                                                                                            Motor cars (COICOP 07.1.1)
## 70                                                  Motor cycles, bicycles and animal drawn vehicles (COICOP 07.1.2_3_4)
## 71                                                               Operation of personal transport equipment (COICOP 07.2)
## 72                                          Spare parts and accessories for personal transport equipment (COICOP 07.2.1)
## 73                                                 Fuels and lubricants for personal transport equipment (COICOP 07.2.2)
## 74                                                Maintenance and repair of personal transport equipment (COICOP 07.2.3)
## 75                                             Other services in respect of personal transport equipment (COICOP 07.2.4)
## 76                                                                                      Transport services (COICOP 07.3)
## 77                                                                        Passenger transport by railway (COICOP 07.3.1)
## 78                                                                           Passenger transport by road (COICOP 07.3.2)
## 79                                                                            Passenger transport by air (COICOP 07.3.3)
## 80                                                        Passenger transport by sea and inland waterway (COICOP 07.3.4)
## 81                                                                          Combined passenger transport (COICOP 07.3.5)
## 82                                                                    Other purchased transport services (COICOP 07.3.6)
## 83                                                                                            Communications (COICOP 08)
## 84                                                                                         Postal services (COICOP 08.1)
## 85                                                          Telephone and telefax equipment and services (COICOP 08.2_3)
## 86                                                                                    Recreation and culture (COICOP 09)
## 87                                         Audio-visual, photographic and information processing equipment (COICOP 09.1)
## 88                          Equipment for the reception, recording and reproduction of sound and picture (COICOP 09.1.1)
## 89                                    Photographic and cinematographic equipment and optical instruments (COICOP 09.1.2)
## 90                                                                      Information processing equipment (COICOP 09.1.3)
## 91                                                                                       Recording media (COICOP 09.1.4)
## 92                             Repair of audio-visual, photographic and information processing equipment (COICOP 09.1.5)
## 93                                                         Other major durables for recreation and culture (COICOP 09.2)
## 94                      Major durables for indoor and outdoor recreation including musical instruments (COICOP 09.2.1_2)
## 95                             Maintenance and repair of other major durables for recreation and culture (COICOP 09.2.3)
## 96                                                Other recreational items and equipment, gardens and pets (COICOP 09.3)
## 97                                                                               Games, toys and hobbies (COICOP 09.3.1)
## 98                                                  Equipment for sport, camping and open-air recreation (COICOP 09.3.2)
## 99                                                                           Gardens, plants and flowers (COICOP 09.3.3)
## 100                                  Pets and related products; veterinary and other services for pets (COICOP 09.3.4_5)
## 101                                                                     Recreational and cultural services (COICOP 09.4)
## 102                                                                   Recreational and sporting services (COICOP 09.4.1)
## 103                                                                                    Cultural services (COICOP 09.4.2)
## 104                                                                       Newspapers, books and stationery (COICOP 09.5)
## 105                                                                                                Books (COICOP 09.5.1)
## 106                                                                           Newspapers and periodicals (COICOP 09.5.2)
## 107                                     Miscellaneous printed matter; stationery and drawing materials (COICOP 09.5.3_4)
## 108                                                                                       Package holidays (COICOP 09.6)
## 109                                                                                                Education (COICOP 10)
## 110                                                                                   Restaurants and hotels (COICOP 11)
## 111                                                                                      Catering services (COICOP 11.1)
## 112                                                                      Restaurants, cafes and the like (COICOP 11.1.1)
## 113                                                                                             Canteens (COICOP 11.1.2)
## 114                                                                                 Accommodation services (COICOP 11.2)
## 115                                                                         Miscellaneous goods and services (COICOP 12)
## 116                                                                                          Personal care (COICOP 12.1)
## 117                                             Hairdressing salons and personal grooming establishments (COICOP 12.1.1)
## 118 Electrical appliances for personal care; other appliances, articles and products for personal care (COICOP 12.1.2_3)
## 119                                                                                Personal effects n.e.c. (COICOP 12.3)
## 120                                                                        Jewellery, clocks and watches (COICOP 12.3.1)
## 121                                                                               Other personal effects (COICOP 12.3.2)
## 122                                                                                      Social protection (COICOP 12.4)
## 123                                                                                              Insurance (COICOP 12.5)
## 124                                                                Insurance connected with the dwelling (COICOP 12.5.2)
## 125                                                                      Insurance connected with health (COICOP 12.5.3)
## 126                                                                   Insurance connected with transport (COICOP 12.5.4)
## 127                                                                                      Other insurance (COICOP 12.5.5)
## 128                                                                              Financial services n.e.c. (COICOP 12.6)
## 129                                                                                  Other services n.e.c. (COICOP 12.7)
## 130                                                                                                     Unprocessed food
## 131                                                                                          Non-energy industrial goods
## 132                                                                                                               Energy
## 133                                                                                          Energy and unprocessed food
## 134                                                                                      HICP All items excluding energy
## 135                                                                 HICP All items excluding energy and unprocessed food
## 136                                            HICP All items excluding housing, water, electricity, gas and other fuels