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.
Provide a scatterplot of \(LifeExp\) ~ \(TotExp\), and run simple linear regression. Do not transform the variables. Provide and interpret the F statistics, R^2, standard error ,and p-values only. Discuss whether the assumptions of simple linear regression met.
who <- read.csv("who.csv", sep = ',')
ggplot(who, aes(x = TotExp, y = LifeExp)) + geom_point() + geom_smooth(method = lm, se=F)
lete.lm <- lm(LifeExp ~ TotExp, data = who)
summary(lete.lm)
##
## Call:
## lm(formula = LifeExp ~ TotExp, data = who)
##
## 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
The F-statistic, which is relatively large at 65.26, give a clear indication that there is a relationship between Total Expenditure and Life Expectancy. As for the standard error, the actual Life Expectancy can deviate from the true regression line by approximately 15.3795867 on average. According to the R^2, the model only accounts for 25.77% of the variance while the p-value is very small making the model significant.
Raise life expectancy to the 4.6 power (i.e., \(LifeExp^{4.6}\)). Raise total expenditures to the 0.06 power (nearly a log transform, \(TotExp^{.06}\)). Plot \(LifeExp^{4.6}\) as a function of \(TotExp^{.06}\), and re-run the simple regression model using the transformed variables. Provide and interpret the F statistics, R^2, standard error, and p-values. Which model is “better?”
LifeExp2 <- who$LifeExp^4.6
TotExp2 <- who$TotExp^0.06
lete_df <- as.data.frame(cbind(LifeExp2, TotExp2))
ggplot(lete_df, aes(x = TotExp2, y = LifeExp2)) + geom_point() + geom_smooth(method = lm, se=F)
lete2.lm <- lm(LifeExp2 ~ TotExp2, lete_df)
summary(lete2.lm)
##
## Call:
## lm(formula = LifeExp2 ~ TotExp2, data = lete_df)
##
## 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
The F-statisticis very much larger at 507.7, give a clear indication of a stronger relationship between the two variables. As for the standard error, the actual Life Expectancy can deviate from the true regression line by approximately 90490000 on average. This is very high. According to the R^2, the model explains the 72.98% of the variance in Life Expectancy which is much better than the previous model. The p-value is smaller which makes the model even more significant.
Using the results from 2, forecast life expectancy when \(TotExp^{.06} =1.5\). Then forecast life expectancy when \(TotExp^{.06}=2.5\).
From the second model, the formula is \(LifeExp = -736527910 + 620060216 \times TotExp\)
# Data has to be tramsformed
lifeexp1 <- -736527910 + 620060216 * 1.5
lifeexp1 ^ (1/4.6)
## [1] 63.31153
lifeexp2 <- -736527910 + 620060216 * 2.5
lifeexp2 ^ (1/4.6)
## [1] 86.50645
Build the following multiple regression model and interpret the F Statistics, R^2, standard error, and p-values. How good is the model?
\[LifeExp = b0 + b1 \times PropMd + b2 \times TotExp + b3 \times PropMD \times TotExp\]
lm3 <- lm(LifeExp ~ PropMD + TotExp + PropMD * TotExp, data = who)
summary(lm3)
##
## Call:
## lm(formula = LifeExp ~ PropMD + TotExp + PropMD * TotExp, data = who)
##
## 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 ***
## PropMD 1.497e+03 2.788e+02 5.371 2.32e-07 ***
## TotExp 7.233e-05 8.982e-06 8.053 9.39e-14 ***
## PropMD:TotExp -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
Forecast \(LifeExp\) when \(PropMD =.03\) and \(TotExp = 14\). Does this forecast seem realistic? Why or why not?
62.77 + (1497 * 0.03) + (0.00007233 * 14) - (0.006026 * (0.03 * 14))
## [1] 107.6785
No, this model is not realistic considering the age being 107 years. Based on the second model we saw that as Total Expenditure increases, so does Life Expectancy. 107 with 14 makes it seem impossible.