# Libraries
library(gridExtra)
library(ggplot2)
library(cowplot)
library(ggstatsplot)
library(rstantools)
library(dplyr)
library(imputeTS)
library(corrplot)
# Loading The Data
df <- read.csv('~/Desktop/data_5060.csv')
attach(df)summary(df)## Year Urban_pop_growth GDP_per_capita GDP_current_Mil
## Min. :1960 Min. :2.306 Min. : 82.19 Min. : 37030
## 1st Qu.:1975 1st Qu.:2.610 1st Qu.: 160.33 1st Qu.: 99263
## Median :1990 Median :2.940 Median : 328.69 Median : 283752
## Mean :1990 Mean :2.989 Mean : 553.14 Mean : 625800
## 3rd Qu.:2004 3rd Qu.:3.221 3rd Qu.: 649.55 3rd Qu.: 736957
## Max. :2019 Max. :3.955 Max. :2099.60 Max. :2868929
## NA's :1
## Pop_density cpi Inflation_annual_percent Pop_growth
## Min. :154.6 Min. : 2.527 Min. :-7.634 Min. :1.015
## 1st Qu.:213.2 1st Qu.: 7.543 1st Qu.: 4.284 1st Qu.:1.598
## Median :296.7 Median : 22.004 Median : 7.119 Median :2.032
## Mean :300.9 Mean : 45.137 Mean : 7.515 Mean :1.880
## 3rd Qu.:387.5 3rd Qu.: 64.026 3rd Qu.:10.231 3rd Qu.:2.239
## Max. :454.9 Max. :180.436 Max. :28.599 Max. :2.332
## NA's :1
## Manufact_value_added hfce GDP_.growth
## Min. : 26009 Min. : 32358 Min. :-5.238
## 1st Qu.: 133660 1st Qu.: 76923 1st Qu.: 3.812
## Median : 894991 Median : 194425 Median : 5.713
## Mean : 4869886 Mean : 379532 Mean : 5.228
## 3rd Qu.: 5232714 3rd Qu.: 428030 3rd Qu.: 7.501
## Max. :27755868 Max. :1729560 Max. : 9.628
## NA's :1
str(df)## 'data.frame': 60 obs. of 11 variables:
## $ Year : int 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 ...
## $ Urban_pop_growth : num NA 2.6 3.06 3.08 3.1 ...
## $ GDP_per_capita : num 82.2 85.4 89.9 101.1 115.5 ...
## $ GDP_current_Mil : num 37030 39232 42161 48422 56480 ...
## $ Pop_density : num 155 158 161 164 168 ...
## $ cpi : num 2.53 2.57 2.66 2.74 3.11 ...
## $ Inflation_annual_percent: num 1.78 1.7 3.63 2.95 13.36 ...
## $ Pop_growth : num NA 2 2.03 2.06 2.07 ...
## $ Manufact_value_added : num 26009 28684 31849 36322 39942 ...
## $ hfce : num 32358 33836 35635 39563 46575 ...
## $ GDP_.growth : num NA 3.72 2.93 5.99 7.45 ...
df <- na_mean(df)sc1 = ggplot(data = df, aes(x =Pop_growth, y = GDP_.growth)) + geom_point() + geom_smooth(method = lm, fill="blue", color="blue", se = FALSE) + xlab("population growth") + ylab("GDP per capita") + ggtitle("Pop_growth ~ gdp_growth")
sc2 = ggplot(data = df, aes(x = Pop_growth, y = Inflation_annual_percent)) + geom_point() + geom_smooth(method = lm, fill="blue", color="blue", se = FALSE) + xlab("population growth") + ylab("Inflation") + ggtitle("pop_growth ~ inflation")
sc3 = ggplot(data = df, aes(x =Urban_pop_growth, y = cpi)) + geom_point() + geom_smooth(method = lm, fill="blue", color="red", se = FALSE) + xlab("urban population growth") + ylab("gdp per capita") + ggtitle("pop_growth ~ CPI")
plot_grid(sc1, sc2,sc3)####Correlation Plot: To visualoze the corrrelation among variables in the dataset.
M <- cor(df)
corrplot(M, method = "circle")lm2 <- lm(Pop_growth~cpi+Inflation_annual_percent+GDP_.growth, data=df)
summary(lm2)##
## Call:
## lm(formula = Pop_growth ~ cpi + Inflation_annual_percent + GDP_.growth,
## data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.29942 -0.09621 -0.01344 0.08959 0.19278
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.2159296 0.0412764 53.685 <2e-16 ***
## cpi -0.0077105 0.0003341 -23.077 <2e-16 ***
## Inflation_annual_percent 0.0050783 0.0031663 1.604 0.114
## GDP_.growth -0.0048934 0.0057704 -0.848 0.400
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1204 on 56 degrees of freedom
## Multiple R-squared: 0.9183, Adjusted R-squared: 0.9139
## F-statistic: 209.9 on 3 and 56 DF, p-value: < 2.2e-16
Interpretation
\[ Y = 2.21 - 0.0077(CPI) + 0.005(Inflation annual percent) - 0.004(GDP Growth) \]