Chemba Ranganathan
November 2, 2016
This is a simple shiny application that uses the UN population data (1950-2015) and forecasts the population for the forecasting period and country selected by the user. The male and female population and combined or overall population are analyzed.
The arima method is used to forecast data with 80-95% confidence levels
Leaflet is used to display the map and plotly is used to draw the forecast plot.
Shiny Application Link : https://chemba.shinyapps.io/PopulationAnalysis/
When the application is loaded it has 3 panels
A world map from which you can select a country for forecasting data
An input panel in which you can enter the forecast period. By default the application predicts for 15 years (till 2030).
A tabbed output panel containing the plot for world population and the forecast output table.
Once the application loads, please do the following
Select the forecast period between 2020 and 2080. The default value is 2030
Select a country by clicking on the red marker icon in the map.
Note: Output panel is refreshed only on country selection and not on change in forecast period.
Output panel displays the plot and forecast data for the chosen country.
selectedCountryCode <- 840
selectedForecastYears <- 2020
dataAvailableYears <- 2015
totalPopulationForselectedCountry <-
totalPopulationEstimate[totalPopulationEstimate$CountryCode == selectedCountryCode, ]
years <-as.numeric(colnames(totalPopulationForselectedCountry[, 5:70]))
predictionYears <- seq(dataAvailableYears + 1,selectedForecastYears ,1)
## Since we are selecting only one row transpose the data set to do predictions
totalPopnTransposeData <-data.frame(t(totalPopulationForselectedCountry[, 5:70]))
totalPopnTransposeData <- cbind(totalPopnTransposeData, years)
## forecast using this data
forecastTotalPopnData <-forecast(auto.arima(totalPopnTransposeData[, 1]),
h = selectedForecastYears - dataAvailableYears,
level = c(80, 95))## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 67 324138.6 324096.0 324181.1 324073.5 324203.7
## 68 326546.6 326349.5 326743.7 326245.2 326848.0
## 69 328993.3 328450.4 329536.3 328163.0 329823.7
## 70 331459.9 330319.8 332600.0 329716.2 333203.5
## 71 333931.3 331910.8 335951.7 330841.2 337021.3