The attached who.csv dataset contains real-world data from 2008. The variables included follow. Country: name of the country LifeExp: average life expectancy for the country in years InfantSurvival: proportion of those surviving to one year or more Under5Survival: proportion of those surviving to five years or more TBFree: proportion of the population without TB. PropMD: proportion of the population who are MDs PropRN: proportion of the population who are RNs PersExp: mean personal expenditures on healthcare in US dollars at average exchange rate GovtExp: mean government expenditures per capita on healthcare, US dollars at average exchange rate TotExp: sum of personal and government expenditures.
df = read.csv('who.csv', header = TRUE)
head(df)
## Country LifeExp InfantSurvival Under5Survival TBFree
## 1 Afghanistan 42 0.835 0.743 0.99769
## 2 Albania 71 0.985 0.983 0.99974
## 3 Algeria 71 0.967 0.962 0.99944
## 4 Andorra 82 0.997 0.996 0.99983
## 5 Angola 41 0.846 0.740 0.99656
## 6 Antigua and Barbuda 73 0.990 0.989 0.99991
## PropMD PropRN PersExp GovtExp TotExp
## 1 0.000228841 0.000572294 20 92 112
## 2 0.001143127 0.004614439 169 3128 3297
## 3 0.001060478 0.002091362 108 5184 5292
## 4 0.003297297 0.003500000 2589 169725 172314
## 5 0.000070400 0.001146162 36 1620 1656
## 6 0.000142857 0.002773810 503 12543 13046
attach(df)
cor(LifeExp, TotExp)
## [1] 0.5076339
plot(TotExp, LifeExp, xlab='TotalExpenditure', ylab='LifeExpectancy', main='scatterplot', col=2)
abline(lm(LifeExp~TotExp), col=1)
exp.lm = lm(LifeExp~TotExp)
exp.lm
##
## Call:
## lm(formula = LifeExp ~ TotExp)
##
## Coefficients:
## (Intercept) TotExp
## 6.475e+01 6.297e-05
Linear Regression Model : Life Expentancy = 64.75 + .000063 * Total Expenditure The negative y intercept is an indication that any expenditure below 65 would lead to a negative life expectancy. The model is thus unrealistic.
Provide and interpret the F statistics, R^2, standard error,and p-values only. Discuss whether the assumptions of simple linear regression met.
summary(exp.lm)
##
## Call:
## lm(formula = LifeExp ~ TotExp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -24.764 -4.778 3.154 7.116 13.292
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.475e+01 7.535e-01 85.933 < 2e-16 ***
## TotExp 6.297e-05 7.795e-06 8.079 7.71e-14 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 9.371 on 188 degrees of freedom
## Multiple R-squared: 0.2577, Adjusted R-squared: 0.2537
## F-statistic: 65.26 on 1 and 188 DF, p-value: 7.714e-14
Multiple R-squared: 0.2577, Adjusted R-squared: 0.2537 - The low R-squared value tells us that our model only explains around 25% of the response variable.
Residual standard error: 9.371 on 188 degrees of freedom tells us the SE is somewhat high (about 10 man/woman years). This means that some the sample data points are significantly off the fitted line and that countries that contribute significantly less in healthcare expenditure than what the model would predict, have nonetheless sustain a life expecgtancy that is significantly higher than expected.
F-statistic: 65.26 on 1 and 188 DF, p-value: 7.714e-14 - the p-value of the model is very low which means we can confindetly reject the null hypothesis. “Total Expenditure DOES NOT contribute to a country’s Life Expentancy”
LifeExp2 = LifeExp^4.6
TotExp2 = TotExp^0.06
cor(LifeExp2,TotExp2)
## [1] 0.8542642
plot(TotExp2, LifeExp2, xlab = 'TotalExpenditure', ylab='LifeExpentancy', main='scatterplot', col=1)
abline(lm(LifeExp2~TotExp2), col=2)
exp2.lm = lm(LifeExp2~TotExp2)
exp2.lm
##
## Call:
## lm(formula = LifeExp2 ~ TotExp2)
##
## Coefficients:
## (Intercept) TotExp2
## -736527909 620060216
Linear Regression Model : Life Expectancy^4.6 = -736527909 + 620060216 * Total Expenditure^0.06
The regression line for the transformed model is better since the data points are more closely clustterred around the regression line.
summary(exp2.lm)
##
## Call:
## lm(formula = LifeExp2 ~ TotExp2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -308616089 -53978977 13697187 59139231 211951764
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -736527910 46817945 -15.73 <2e-16 ***
## TotExp2 620060216 27518940 22.53 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 90490000 on 188 degrees of freedom
## Multiple R-squared: 0.7298, Adjusted R-squared: 0.7283
## F-statistic: 507.7 on 1 and 188 DF, p-value: < 2.2e-16
Multiple R-squared: 0.7298, Adjusted R-squared: 0.7283 R-squared value of close to 73% means that the response variable explains the model’s variability around the mean 75% of the time.
Residual standard error: 90,490,000 on 188 degrees of freedom is suprising high even when we consider the exponential increase to the life Expentancy by 4.6. Nevertheless due to the exponentioal increase in these values, the SE should also be expected to increase exponentially.
F-statistic: 507.7 on 1 and 188 DF, p-value: < 2.2e-16 - the p-value of the model is very low which means we can reject the null hypothesis “Total Expenditure^0.06 does not contribute to a country’s Life Expentancy^4.6”. Its evident that the variable does contribute in a greater way when compared to the initial model.
LifeExp_46 = -736527909 + 620060216 * (1.5)
LifeExp_15 = exp(log(LifeExp_46)/4.6)
LifeExp_15
## [1] 63.31153
LifeExp_46 = -736527909 + 620060216 * (2.5)
LifeExp_25 = exp(log(LifeExp_46)/4.6)
LifeExp_25
## [1] 86.50645
LifeExp = b0+b1 x PropMd + b2 x TotExp +b3 x PropMD x TotExp
MUL.lm = lm(LifeExp~TotExp + PropMD + PropMD * TotExp)
MUL.lm
##
## Call:
## lm(formula = LifeExp ~ TotExp + PropMD + PropMD * TotExp)
##
## Coefficients:
## (Intercept) TotExp PropMD TotExp:PropMD
## 6.277e+01 7.233e-05 1.497e+03 -6.026e-03
Life Expentancy Mu_Reg = 62.8 + .000072 Total Expenditure + 1,497 PropMD + .006 (Total Expenditrure)(PropMD)
summary(MUL.lm)
##
## Call:
## lm(formula = LifeExp ~ TotExp + PropMD + PropMD * TotExp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -27.320 -4.132 2.098 6.540 13.074
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.277e+01 7.956e-01 78.899 < 2e-16 ***
## TotExp 7.233e-05 8.982e-06 8.053 9.39e-14 ***
## PropMD 1.497e+03 2.788e+02 5.371 2.32e-07 ***
## TotExp:PropMD -6.026e-03 1.472e-03 -4.093 6.35e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.765 on 186 degrees of freedom
## Multiple R-squared: 0.3574, Adjusted R-squared: 0.3471
## F-statistic: 34.49 on 3 and 186 DF, p-value: < 2.2e-16
Multiple R-squared: 0.3574, Adjusted R-squared: 0.3471 . This is not a good model since the adjuster R-Sqrd is too low at only 35%. The response variables in this model account for only ~35% of the variability.
Residual standard error: 8.765 on 186 degrees of freedom - The residual SE is significant at 8.765 since the data points are on average off by 8.765 and thus the model is not a good fit to its corresponding data points.
F-statistic: 34.49 on 3 and 186 DF, p-value: < 2.2e-16 the F-statistic shows that the p-value is very low meaning that we can reject the null hypothesis and confidently state that the response variables contribute to the true value of the dependent variable.
LifeExp_MR = 62.8 + .000072 * 14 + 1497 * 0.03 + .006 * 14 * 0.03
LifeExp_MR
## [1] 107.7135
By reducing the proportion of expenditure and increasing the no of doctors, the model predicts an increase in the life expectancy to 107. It is unrelaistic to increase the number of doctors without a corresponding increase on expenditure since the no of doctors is not independent of expenditure. The model forecast is thus unrealistic.