Loading the package and making a dataframe from the Worldbank Data of the South Asian Countries
library(WDI)
library(pander)
X <- WDI(country = c('BD','IN','BT','NP','PK','LK','AF'),
indicator = c("SP.DYN.LE00.IN","SP.DYN.IMRT.IN", "NY.GDP.PCAP.PP.KD" ,
"SH.MED.BEDS.ZS","SH.MED.PHYS.ZS","SH.MED.NUMW.P3"),
start = 2000,end = 2019)
Removing the NA values and replacing the variable names
X <- X[complete.cases(X), ]
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
X <- rename_all(X,recode,SP.DYN.LE00.IN="LEB",
SP.DYN.IMRT.IN = "IMR",
NY.GDP.PCAP.PP.KD = "GDP",
SH.MED.BEDS.ZS="HB",
SH.MED.PHYS.ZS="PY",
SH.MED.NUMW.P3="NM")
# LEB = Life Expectancy at birth (total years)
# IMR = Infant Mortality Ratio(per 1000 live births)
# GDP = GDP per capita measured at 2017 international $
# HB = Hospital Beds per 1000 people
# PY = Physicians per 1000 people
# NM = Nurses and Midwives per 1000 people
pander(head(X))
| 7 |
AF |
Afghanistan |
2006 |
58.83 |
74.3 |
1408 |
0.4 |
0.1596 |
0.44 |
| 8 |
AF |
Afghanistan |
2007 |
59.38 |
71.7 |
1563 |
0.4 |
0.1743 |
0.4956 |
| 9 |
AF |
Afghanistan |
2008 |
59.93 |
69 |
1588 |
0.4 |
0.1744 |
0.4971 |
| 10 |
AF |
Afghanistan |
2009 |
60.48 |
66.5 |
1882 |
0.4 |
0.2126 |
0.6078 |
| 14 |
AF |
Afghanistan |
2013 |
62.52 |
57.2 |
2264 |
0.5 |
0.2846 |
0.2495 |
| 15 |
AF |
Afghanistan |
2014 |
62.97 |
55.2 |
2249 |
0.5 |
0.2983 |
0.1476 |
Regression life expectancy at birth on health infrastructure
fit1 <- lm (X$`LEB`
~ X$`HB`
+X$`PY`
+X$`NM`)
summary(fit1)
##
## Call:
## lm(formula = X$LEB ~ X$HB + X$PY + X$NM)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.9176 -1.7676 -0.5887 0.5407 6.4220
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 60.8470 1.4447 42.118 < 2e-16 ***
## X$HB 3.4878 0.7871 4.431 0.00014 ***
## X$PY 3.9854 2.3341 1.707 0.09921 .
## X$NM -0.3059 1.5911 -0.192 0.84899
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.981 on 27 degrees of freedom
## Multiple R-squared: 0.6247, Adjusted R-squared: 0.583
## F-statistic: 14.98 on 3 and 27 DF, p-value: 6.161e-06
library(broom)
tidy(fit1)
glance(fit1)
Regressing infant mortality rate on health infrastructure
fit2 <- lm (X$`IMR`
~ X$`HB`
+X$`PY`
+X$`NM`)
summary(fit2)
##
## Call:
## lm(formula = X$IMR ~ X$HB + X$PY + X$NM)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.5693 -4.0172 0.5575 8.1405 23.0249
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 61.509 6.850 8.979 1.36e-09 ***
## X$HB -16.230 3.732 -4.349 0.000175 ***
## X$PY 21.445 11.068 1.938 0.063197 .
## X$NM -6.180 7.545 -0.819 0.419901
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 14.13 on 27 degrees of freedom
## Multiple R-squared: 0.6604, Adjusted R-squared: 0.6227
## F-statistic: 17.5 on 3 and 27 DF, p-value: 1.64e-06
tidy(fit2)
glance(fit2)
Regressing GDP Per Capita on health infrastructure
fit3 <- lm (X$`GDP`
~ X$`HB`
+X$`PY`
+X$`NM`)
summary(fit3)
##
## Call:
## lm(formula = X$GDP ~ X$HB + X$PY + X$NM)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1434.0 -353.5 -68.4 150.8 4472.4
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 715.0 514.9 1.389 0.17633
## X$HB 1761.5 280.5 6.279 1.02e-06 ***
## X$PY 2387.5 831.9 2.870 0.00789 **
## X$NM 230.5 567.1 0.407 0.68757
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1062 on 27 degrees of freedom
## Multiple R-squared: 0.8007, Adjusted R-squared: 0.7785
## F-statistic: 36.15 on 3 and 27 DF, p-value: 1.346e-09
tidy(fit3)
glance(fit3)
Pearson Correlation Table
library(picante)
## Loading required package: ape
## Loading required package: vegan
## Loading required package: permute
## Loading required package: lattice
## This is vegan 2.5-6
## Loading required package: nlme
##
## Attaching package: 'nlme'
## The following object is masked from 'package:dplyr':
##
## collapse
X[1:3] <- NULL
pearson <- cor.table(X,cor.method = "pearson",cor.type = "standard")
panderOptions("table.style", "grid")
pander(pearson$r)
| LEB |
1 |
-0.8841 |
0.788 |
0.7643 |
0.2983 |
0.5615 |
| IMR |
-0.8841 |
1 |
-0.6789 |
-0.7808 |
0.1021 |
-0.6091 |
| GDP |
0.788 |
-0.6789 |
1 |
0.857 |
0.3645 |
0.6738 |
| HB |
0.7643 |
-0.7808 |
0.857 |
1 |
0.1306 |
0.7277 |
| PY |
0.2983 |
0.1021 |
0.3645 |
0.1306 |
1 |
0.1978 |
| NM |
0.5615 |
-0.6091 |
0.6738 |
0.7277 |
0.1978 |
1 |
Spearman Correlation Table
spearman <- cor.table(X,cor.method = "spearman",cor.type ="standard")
pander(spearman$r)
| LEB |
1 |
-0.8089 |
0.7802 |
0.5996 |
0.3206 |
0.3794 |
| IMR |
-0.8089 |
1 |
-0.4694 |
-0.4447 |
0.1488 |
-0.3367 |
| GDP |
0.7802 |
-0.4694 |
1 |
0.7815 |
0.6101 |
0.5153 |
| HB |
0.5996 |
-0.4447 |
0.7815 |
1 |
0.3573 |
0.5097 |
| PY |
0.3206 |
0.1488 |
0.6101 |
0.3573 |
1 |
0.2125 |
| NM |
0.3794 |
-0.3367 |
0.5153 |
0.5097 |
0.2125 |
1 |