├── .gitignore ├── Analzying-Inflation-Rates-Worldwide.Rproj ├── Inflation-Rates ├── inflation.xls ├── rsconnect │ └── shinyapps.io │ │ └── anishsingh │ │ └── Inflation-Rates.dcf ├── server.R ├── ui.R └── www │ └── custom.css ├── LICENSE ├── Plots └── Inf-India.png ├── README.md ├── inflation.xls └── inflation_analysis.Rmd /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | *.html 6 | -------------------------------------------------------------------------------- /Analzying-Inflation-Rates-Worldwide.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /Inflation-Rates/inflation.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anishsingh20/Time-series-analysis-of-Inflation-rates-using-ShinyDashboard/cb2dfdcfba0773b6a46c4ce428df1a48a710dda6/Inflation-Rates/inflation.xls -------------------------------------------------------------------------------- /Inflation-Rates/rsconnect/shinyapps.io/anishsingh/Inflation-Rates.dcf: -------------------------------------------------------------------------------- 1 | name: Inflation-Rates 2 | title: Inflation-Rates 3 | username: 4 | account: anishsingh 5 | server: shinyapps.io 6 | hostUrl: https://api.shinyapps.io/v1 7 | appId: 229918 8 | bundleId: 1048859 9 | url: https://anishsingh.shinyapps.io/Inflation-Rates/ 10 | when: 1509140491.67823 11 | asMultiple: FALSE 12 | asStatic: FALSE 13 | -------------------------------------------------------------------------------- /Inflation-Rates/server.R: -------------------------------------------------------------------------------- 1 | require(shinydashboard) 2 | require(ggplot2) 3 | require(dplyr) 4 | require(highcharter) #to plot amazing time series plots 5 | library(readxl) 6 | require(tidyr) 7 | 8 | 9 | 10 | 11 | inflation <- read_excel("inflation.xls") 12 | 13 | 14 | year<-c(1980:2022) #making a vector consisting of all years 15 | year<-as.character(year)#converting to character type to use in gather() 16 | 17 | 18 | inf<-inflation %>% gather(year,key = "Year",value="InflationRate") 19 | inf<-na.omit(inf) #omitting NA values 20 | 21 | names(inf)<-c("region","year","inflation") 22 | 23 | inf$year<-as.integer(inf$year) 24 | 25 | India<-filter(inf,region=="India") 26 | India$inflation<-as.numeric(India$inflation) 27 | India$year<-as.numeric(India$year) 28 | 29 | China<-filter(inf,region=="China, People's Republic of") 30 | Ger<-filter(inf,region=="Germany") 31 | Japan<-filter(inf,region=="Japan") 32 | US<-filter(inf,region=="United States") 33 | EU<-filter(inf,region=="European Union") 34 | UK<-filter(inf,region=="United Kingdom") 35 | Fr<-filter(inf,region=="France") 36 | uae<-filter(inf,region=="United Arab Emirates") 37 | 38 | 39 | 40 | 41 | 42 | server <- function(input, output) { 43 | 44 | 45 | output$hcontainer <- renderHighchart ({ 46 | 47 | #if(input$country==inf$region) 48 | #{ 49 | df<-inf %>% filter(region==input$country)#making is the dataframe of the country 50 | 51 | df$inflation<-as.numeric(df$inflation) 52 | df$year<-as.numeric(df$year) 53 | 54 | #plotting the data 55 | hchart(df, "line",color="#DC270C",hcaes(x=year,y=inflation)) %>% 56 | 57 | hc_exporting(enabled = TRUE) %>% 58 | hc_tooltip(crosshairs = TRUE, backgroundColor = "#FCFFC5", 59 | shared = TRUE, borderWidth = 2) %>% 60 | hc_title(text="Time series plot of Inflation Rates",align="center") %>% 61 | hc_subtitle(text="Data Source: IMF",align="center") %>% 62 | hc_add_theme(hc_theme_elementary()) 63 | #to add 3-d effects 64 | #hc_chart(type = "column", 65 | #options3d = list(enabled = TRUE, beta = 15, alpha = 15)) 66 | 67 | 68 | 69 | 70 | 71 | }) 72 | 73 | 74 | output$hc2<-renderHighchart({ 75 | 76 | highchart() %>% 77 | hc_xAxis(categories=inf$year) %>% 78 | hc_add_series(name = "India", data = India$inflation) %>% 79 | hc_add_series(name = "USA", data = US$inflation) %>% 80 | hc_add_series(name = "UK", data = UK$inflation) %>% 81 | hc_add_series(name = "China", data = China$inflation) %>% 82 | hc_add_series(name = "Germany", data = Ger$inflation) %>% 83 | hc_add_series(name="Japan",data=Japan$inflation) %>% 84 | #to add colors 85 | hc_colors(c("red","blue","green","purple","darkpink","orange")) %>% 86 | hc_add_theme(hc_theme_elementary()) 87 | 88 | 89 | 90 | 91 | 92 | }) 93 | 94 | output$hc3<-renderHighchart({ 95 | 96 | union<-inf %>% filter(region==input$region) 97 | union$year<-as.numeric(union$year) 98 | union$inflation<-as.numeric(union$inflation) 99 | 100 | #plotting 101 | hchart(union,hcaes(x=year,y=inflation),type="area",color="#2B1F97") %>% 102 | hc_exporting(enabled = TRUE) %>% 103 | hc_tooltip(crosshairs = TRUE, backgroundColor = "#FCFFC5", 104 | shared = TRUE, borderWidth = 2) %>% 105 | hc_title(text="Time series plot of Inflation Rates for Economic Unions",align="center") %>% 106 | hc_subtitle(text="Data Source: IMF",align="center") %>% 107 | hc_add_theme(hc_theme_elementary()) 108 | 109 | 110 | 111 | 112 | }) 113 | 114 | output$hc4<-renderHighchart({ 115 | world<-inf %>% filter(region=="World") 116 | world$year<-as.numeric(world$year) 117 | world$inflation<-as.numeric(world$inflation) 118 | #plotting the plot 119 | hchart(world,hcaes(x=year,y=inflation),type="area",color="#B915A3") %>% 120 | hc_exporting(enabled = TRUE) %>% 121 | hc_tooltip(crosshairs = TRUE, backgroundColor = "#FCFFC5", 122 | shared = TRUE, borderWidth = 2) %>% 123 | hc_title(text="Time series plot of Inflation Rates for World",align="center") %>% 124 | hc_subtitle(text="Data Source: IMF",align="center") %>% 125 | hc_add_theme(hc_theme_elementary()) 126 | 127 | }) 128 | 129 | 130 | 131 | } 132 | -------------------------------------------------------------------------------- /Inflation-Rates/ui.R: -------------------------------------------------------------------------------- 1 | library(shinydashboard) 2 | require(shiny) 3 | require(highcharter) 4 | #layout of the dashboard 5 | 6 | #defining character vectors for select inputs 7 | country<-c("India","United States","Mexico","Canada","China, People's Republic of","Japan","Russian Federation","Germany","United Kingdom","European Union", 8 | "ASEAN-5","New Zealand","Australia","Netherlands","Luxembourg", 9 | "France","Qatar","United Arab Emirates","Saudi Arabia") 10 | 11 | unions<-c("Major advanced economies (G7)","European Union","Emerging and Developing Europe","ASEAN-5","Commonwealth of Independent States", 12 | "Emerging and Developing Asia","Latin America and the Caribbean", 13 | "Middle East, North Africa, Afghanistan, and Pakistan") 14 | 15 | dashboardPage( 16 | #defines header 17 | skin = "red", 18 | dashboardHeader( 19 | title="Inflation Rates" , 20 | dropdownMenu() 21 | ), 22 | 23 | 24 | #defines sidebar 25 | dashboardSidebar( 26 | sidebarMenu( 27 | menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), 28 | menuItem("About", tabName = "about", icon = icon("th")), 29 | menuItem("Trade Unions",tabName="unions",icon=icon("signal")), 30 | menuItem("World",tabName="world",icon=icon("globe")) 31 | 32 | ) 33 | ), 34 | 35 | 36 | #defines bodys 37 | dashboardBody( 38 | tags$head( 39 | tags$link(rel = "stylesheet", type = "text/css", href = "custom.css") 40 | ), 41 | 42 | tabItems( 43 | 44 | #First TAB Menu-Dashboard 45 | tabItem(tabName = "dashboard", 46 | 47 | fluidRow( 48 | 49 | 50 | column(12, 51 | 52 | box(selectInput("country",label="Select Country",choices=country),width = 12) 53 | 54 | ),#end column 55 | 56 | #box for plotting the time series plot 57 | column(12, 58 | 59 | box( 60 | 61 | highchartOutput("hcontainer"), 62 | 63 | 64 | 65 | width="12") #end box2 66 | 67 | ), #end column 68 | hr(), 69 | h4("Relative inflation rates time series plot",align="center"), 70 | br(), 71 | column(12, 72 | 73 | box( 74 | highchartOutput("hc2"),width=12 75 | 76 | ) ) 77 | 78 | ),#end row 79 | h4("Made with love from", strong("Anish Singh Walia")), 80 | a("R code for this project",target="_blank",href="https://github.com/anishsingh20/Analzying-Inflation-Rates-Worldwide") 81 | ), 82 | 83 | 84 | 85 | #second tab menu- ABOUT 86 | tabItem(tabName="about", 87 | 88 | h2("What is Inflation ?",style="text-align:center"), 89 | br(), 90 | br(), 91 | box(width=12,height="400px", 92 | p(style="font-size:20px",strong("Inflation"),"rates are the general rate at which price of the goods and services 93 | within a particular economy are rising and the purchasing power of the currency 94 | is declining due to the highly priced goods. High inflation is definately not good for an economy 95 | because it will always reduce the value for money.In genral central banks of an ecomony tries to and work towards reducing 96 | the inflation rate and avoiding deflation."), 97 | 98 | 99 | 100 | 101 | p(style="font-size:20px",strong("Deflation"), "is opposite of inflation. Delfation occurs when the inflation rates become negetive or are below 0. Deflation is more harmful and dangerous for an economy because it means that the prices of goods and services are going to decrease. Now this sounds amazing for consumers like us. But what actually happens is that the demand of goods and services have declined over a long term of time. 102 | This directly indicates that a recession is on its way. This brings job losses , declining wages and a big hit to the stock portfolio. Deflation slows economy's growth. As prices fall , people defer(postpone) purchases in hope of a better lower price deal. Due to this companies and firms have to cut 103 | down the cost of their goods and products which directly affects the wages of the employees which have to be lowered.") 104 | 105 | ) 106 | 107 | ), 108 | 109 | tabItem(tabName = "unions", 110 | 111 | h3("Time series of Inflation rates of Economic trade unions",align="center") , 112 | 113 | fluidRow( 114 | 115 | 116 | column(12, 117 | 118 | box(selectInput("region",label="Select Economic Region",choices=unions),width = 12) 119 | 120 | ), 121 | 122 | box( 123 | highchartOutput("hc3"), 124 | width=12) 125 | 126 | )# end row 127 | ), 128 | tabItem(tabName = "world", 129 | 130 | h3("World's Inflation Rates",align="center") , 131 | 132 | box( 133 | highchartOutput("hc4"), 134 | width=12) 135 | 136 | ) 137 | )#end tabitems 138 | 139 | 140 | )#end body 141 | 142 | )#end dashboard -------------------------------------------------------------------------------- /Inflation-Rates/www/custom.css: -------------------------------------------------------------------------------- 1 | div { 2 | font-family: times, Times New Roman, times-roman, georgia, serif; 3 | color: #444; 4 | font-size: 15px; 5 | font-weight:bold; 6 | } 7 | 8 | div > p { 9 | font-family:times-roman; 10 | font-weight:lighter; 11 | 12 | } 13 | .main-header .logo { 14 | font-family: times, Times New Roman, times-roman, georgia, serif; 15 | color: #444; 16 | font-size:28px; 17 | line-height: 44px; 18 | letter-spacing: -2px; 19 | font-weight: bold; 20 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Plots/Inf-India.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anishsingh20/Time-series-analysis-of-Inflation-rates-using-ShinyDashboard/cb2dfdcfba0773b6a46c4ce428df1a48a710dda6/Plots/Inf-India.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Analzying-Inflation-Rates-Worldwide-using-ShinyDashboard 2 | 3 | This project aims at studying and analyzing the inflation rates of countries and major economic unions globally. The dataset is a public dataset downloaded from International Monetary Fund(IMF) which consists of the inflation rates of countries from 1980 to 2017 and the projected inflation rates of the countries till 2022. 4 | 5 | After basic descriptive and exploratory data analysis, I have made a __Shiny Dashboard__ in R to visualize the inflation rates of countries, economic trade unions as well as world. Link to the deployed app is added below. 6 | 7 | Link to the app--https://anishwalia20.shinyapps.io/AnalysisofInflationRates/ 8 | 9 | 10 | The folder __Inflation-Rates__ contains the dashboard's code and its implementation in R. For visualizing I have used __'highcharter'__ package which is an amazing package to make beautiful and amazing plots in R for web apps and dashboards.The syntax for 'highcharter' is similar to 'ggplot2' syntax. 11 | 12 | More details about the package can be found at this link- http://jkunst.com/highcharter/ . 13 | 14 | 15 | 16 | ### What is Inflation rate? 17 | 18 | Inflation rates are the general rate at which price of the goods and services within a particular economy are rising and the __purchasing power__ of the currency is declining due to the highly priced goods. High inflation is definately not good for an economy because it will always reduce the value for money. In general central banks of an ecomony tries to and work towards reducing the inflation rate and avoiding __deflation__. Very high inflation rates will devalue the country's currency and will result in further depreciation of currency's exchange value. 19 | 20 | Say for example India's current inflation rate is 10%, this means that the __INR(indian rupees)__ has depreciated by 10% against any other foreign currency. This greatly affects the payments received by the exporting bodies, import prices of goods etc. _*Imported goods usually gets costlier and exported goods will get cheaper when the nations's currency is weaker and is depreciating against any other nation's whose currency is stronger and appreciating*_. 21 | 22 | __Deflation__ is opposite of inflation. Deflation occurs when the inflation rates become negetive or are below 0. Deflation is more harmful and dangerous for an economy because it means that the prices of goods and services are going to decrease. Now this sounds amazing for consumers like us. But what actually happens is that the demand of goods and services have declined over a long term of time which has lead to over-production og goods and services. Deflation is more evil then inflation. Deflation causes unemployment, loss of jobs, decline in money wages, decreasing exxpenditure and decreasing demands of goods. This results in losses for business owners and Producers in the economy. It causes decrease in National Income, employment, and output. This directly indicates that a __recession__ is on its way. This brings job losses , declining wages and a big hit to the stock portfolio. Deflation slows economy's growth and causes stagnation of economic acivities. It is a time of depression for all businesses and producers. As prices fall , people defer(postpone) purchases in hope of a better lower price deal. Due to this companies and firms have to cut down the cost of their goods and products which directly affects the wages of the employees which have to be lowered. 23 | 24 | 25 | ------ 26 | 27 | ### Inflation Rates of India over time 28 | 29 | ![github plot](https://github.com/anishsingh20/Analzying-Inflation-Rates-Worldwide/blob/master/Plots/Inf-India.png) 30 | 31 | 32 | -------------------------------------------------------------------------------- /inflation.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anishsingh20/Time-series-analysis-of-Inflation-rates-using-ShinyDashboard/cb2dfdcfba0773b6a46c4ce428df1a48a710dda6/inflation.xls -------------------------------------------------------------------------------- /inflation_analysis.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Analyzing Global Inflation Rates" 3 | output: html_notebook 4 | --- 5 | 6 | #### This project will aim at analyzing the inflation rates globally and countrywise over time from 1980 onwards. 7 | 8 | Loading the required packages 9 | ```{r} 10 | require(ggplot2) 11 | require(dplyr) 12 | require(tidyr) 13 | 14 | ``` 15 | 16 | Reading the datset. 17 | 18 | ```{r} 19 | library(readxl) 20 | inflation <- read_excel("F:/PROJECTS/Datasets/IMF/inflation.xls") 21 | View(inflation) 22 | 23 | 24 | ``` 25 | Starting with some data processing and transformations as well as cleaning. 26 | 27 | ```{r} 28 | head(inflation) 29 | 30 | ``` 31 | 32 | The data set is quiet wide. So I will gather the dataset and make Year as a seaparate column and the inflation rates of each year separate for easy analysis and visualization of data. 33 | 34 | ```{r} 35 | #using gather() function from tidyr 36 | 37 | year<-c(1980:2022) #making a vector consisting of all years 38 | year<-as.character(year)#converting to character type to use in gather() 39 | 40 | #new dataframe which is in long format 41 | inf<-inflation %>% gather(year,key = "Year",value="InflationRate") 42 | inf<-na.omit(inf) #omitting NA values 43 | 44 | names(inf)<-c("region","year","inflation") 45 | 46 | inf$year<-as.integer(inf$year) 47 | 48 | ``` 49 | 50 | Now what we can do is easily filter the data for specific countries and make a separate data frame for them and analyze their inflation rates over time specifically and perform time series analysis. 51 | 52 | --------------- 53 | 54 | 55 | ### Inflation Rates in India 56 | 57 | Generating a data frame for India and other major emerging and developed economies. 58 | 59 | ```{r} 60 | 61 | changeType<-function(df,x) 62 | { 63 | 64 | df[,x]<-as.integer(df[,x]) 65 | } 66 | 67 | India<-filter(inf,region=="India") 68 | India$inflation<-as.numeric(India$inflation) 69 | India$year<-as.numeric(India$year) 70 | 71 | China<-filter(inf,region=="China, People's Republic of") 72 | China[1,3]<-0 73 | 74 | 75 | Ger<-filter(inf,region=="Germany") 76 | changeType(Ger,3) 77 | 78 | 79 | Japan<-filter(inf,region=="Japan") 80 | changeType(Japan,year,inflationRate) 81 | 82 | US<-filter(inf,region=="United States") 83 | EU<-filter(inf,region=="European Union") 84 | UK<-filter(inf,region=="United Kingdom") 85 | Fr<-filter(inf,region=="France") 86 | uae<-filter(inf,region=="United Arab Emirates") 87 | 88 | 89 | theme_set(theme_bw() ) 90 | ggplot(aes(x=year,y=inflation),data=India) + 91 | geom_point(size=2,color="orange") + 92 | geom_line(color="orange") + 93 | scale_x_continuous(limits=c(1980,2017),breaks=seq(1980,2017,5)) + 94 | labs(x="Year",y="Inflation Rates",title="Time series of Inflation Rates for India") 95 | 96 | #hchart(India, "line", hcaes(x = year, y = inflation)) 97 | 98 | 99 | 100 | 101 | ``` 102 | 103 | 104 | First let's build a small R function to easily plot time series plots for visualizing the inflation rates over time. 105 | 106 | ```{r} 107 | #making a ggplot function to plot timer series plots 108 | tsplot<-function(df,year,rate,pcol,lcol,title) { 109 | 110 | 111 | ggplot(aes(x = year,y= rate),data=df) + 112 | geom_point(size=2,color=pcol) + 113 | geom_line(color=lcol) + 114 | scale_x_continuous(limits=c(1980,2017),breaks=seq(1980,2017,5)) + 115 | labs(title=title) 116 | 117 | } 118 | 119 | ``` 120 | 121 | The function above takes a data set as argument folllowed by x-axis attribute , y-axis attribute and then the other plotting variables i.e point and line color and title. 122 | 123 | 124 | 125 | ------------ 126 | 127 | ### Analyzing Inflation rates in Euro region-EU economic integration 128 | 129 | ```{r} 130 | EU$inflation<-as.numeric(EU$inflation) 131 | tsplot(EU,EU$year,EU$inflation,"#908B0A","#908B0A","Inflation Rates for EU region") 132 | 133 | 134 | ``` 135 | 136 | 137 | 138 | ### Analyzing Inflation Rates in USA 139 | 140 | Checking inflation rates for United states of America over time. 141 | 142 | 143 | ```{r} 144 | 145 | US$inflation<-as.numeric(US$inflation) 146 | theme_set(theme_bw()) 147 | tsplot(US,US$year,US$inflation,"purple","brown","Inflation Rates for USA over time") 148 | 149 | ``` 150 | In the above plot we can observe that the *inflation* for year __2009 is negetive__ and negetive inflation is also called __deflation__ which is more harmful for an economy than inflation. It is negetive due to that fact that in 2008-2009 their economy faced a __recession__. High deflation rates signify that the economy is under recession i.e demand of goods have gone down significantly, resulting in very low price of goods. Layoffs in jobs and decrease in wages of employees, high unemployment etc are some examples of how recession affects an economy. 151 | 152 | 153 | -------------------- 154 | 155 | ### Analyzing Inflation rates for German Economy 156 | 157 | ```{r} 158 | Ger$inflation<-as.numeric(Ger$inflation) 159 | theme_set(theme_bw()) 160 | tsplot(Ger,Ger$year,Ger$inflation,"purple","purple","Inflation Rates of Germany") 161 | 162 | ``` 163 | 164 | ----------------- 165 | 166 | ### United Kingdom 167 | 168 | ```{r} 169 | UK$inflation<-as.numeric(UK$inflation) 170 | tsplot(UK,UK$year,UK$inflation,"#54A50D","#54A50D","Inflation Rates for United Kingdom") 171 | 172 | ``` 173 | 174 | 175 | ----------- 176 | 177 | ### France 178 | 179 | 180 | ```{r} 181 | Fr$inflation<-as.numeric(Fr$inflation) 182 | theme_set(theme_bw()) 183 | tsplot(Fr,Fr$year,Fr$inflation,"#FD5D01","#FD5D01","Inlfation rates for France") 184 | 185 | ``` 186 | 187 | 188 | 189 | ---------------- 190 | 191 | 192 | ### China 193 | 194 | 195 | ```{r} 196 | China$inflation<-as.numeric(China$inflation) 197 | theme_set(theme_bw()) 198 | tsplot(China,China$year,China$inflation,"#078CE5","#078CE5","Inflation Rates for China") 199 | 200 | ``` 201 | We can notice that China had very high inflation rates initially,before 1997. High inflation can be caused by an increase in demand for goods relative to supply. When more people fight over fewer goods, the price increases. It is just as true for an entire country as it is for a car on eBay. We have seen an increase in the inflation rate, in part, because countries like China and India, which had virtually no industrial base a few generations ago, have billions of citizens poised to enter the middle class in the coming years 202 | 203 | Then it has negetive inflation rates for years 1998-1999, 2002, 2009 i.e had high deflation. 204 | 205 | 206 | ------------- 207 | 208 | ### UAE 209 | 210 | ```{r} 211 | uae$inflation<-as.numeric(uae$inflation) 212 | tsplot(uae,uae$year,uae$inflation,"#0A2E90","#0A2E90","Inflation Rates for UAE") 213 | 214 | 215 | ``` 216 | 217 | 218 | ---------------- 219 | 220 | 221 | ### Plotting the comparative Time series plot 222 | 223 | We will use the package __highcharter__. 224 | 225 | ```{r} 226 | require(highcharter) 227 | 228 | hc <- highchart() %>% 229 | hc_xAxis(title="Year",inf$year) %>% 230 | hc_add_series(name = "India", data = India$inflation) %>% 231 | hc_add_series(name = "USA", data = US$inflation) %>% 232 | hc_add_series(name = "UK", data = UK$inflation) %>% 233 | hc_add_series(name = "China", data = China$inflation) %>% 234 | hc_add_series(name = "Ger", data = Ger$inflation) %>% 235 | hc_yAxis(title="Inflation Rates ")%>% 236 | #to add colors 237 | hc_colors(c("red","blue","green","purple","yellow")) 238 | 239 | hc 240 | 241 | ``` 242 | 243 | --------------------------------------------------------------------------------