Overview

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.

library(data.table)

df <- fread("who.csv")

Exercise 1

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.

plot(df$TotExp, df$LifeExp, xlab = "Total Expenditures", ylab = "Life Expectancy")

lm_mod <- lm(LifeExp ~ TotExp, data = df)
summary(lm_mod)
## 
## Call:
## lm(formula = LifeExp ~ TotExp, data = df)
## 
## 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 model above estimates the F statistics to be statistically significant since its p-value is less than 0.05. The R-squared ins 0.2577 which means that the model is able to explain 25% of the variance in the data.

The standard error for the explanatory variable is withing the range of 5-10 times smaller than the coefficient and the p-value is very small suggests that the TotExp is a significant predictor of LifeExp.


Exercise 2

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 r 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?”

df_2 <- df
df_2$LifeExp <- df$LifeExp^4.6
df_2$TotExp <- df$TotExp^0.06

plot(df_2$TotExp, df_2$LifeExp)

mod_2 <- lm(LifeExp ~ TotExp, data = df_2)
summary(mod_2)
## 
## Call:
## lm(formula = LifeExp ~ TotExp, data = df_2)
## 
## 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 ***
## TotExp       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

All the p-values are very small which suggests that it is statistically significant. The standard error of TotExp is 22 times smaller than the coefficient meaning that there is low variability in the estimate of TotExp. Then, the R-squared is 0.729 which explains 72% of the variability of the data.


Exercise 3

Using the results from 3, forecast life expectancy when TotExp^.06 =1.5. Then forecast life expectancy when TotExp^.06=2.5.

From model 2 where the varibles were transformed,

\[ LifeExp = -736527910 + 620060216(TotExp) \]

# when
TotExp = 1.5
LifeExp = -736527910 + 620060216 * (TotExp)
LifeExp
## [1] 193562414
TotExp = 2.5
LifeExp = -736527910 + 620060216 * (TotExp)
LifeExp
## [1] 813622630

Exercise 4

Build the following multiple regression model and interpret the F Statistics, R^2, standard error, and p-values. How good is the model? \(LifeExp = b_0+b_1 x PropMd + b_2 x TotExp +b_3 x PropMD x TotExp\)

model_3 <- lm(LifeExp ~ PropMD + TotExp + PropMD + (PropMD * TotExp), data = df)
summary(model_3)
## 
## Call:
## lm(formula = LifeExp ~ PropMD + TotExp + PropMD + (PropMD * TotExp), 
##     data = df)
## 
## 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

All the p-values are very small which suggests that it is statistically significant. R-squared is relatively low compared to model 2 which was at 0.7 and this is at 0.3. The t values are largest enough except for the PropMD * TotExp meaning that this predictor variable has a negative relation to the target variable but is still statistically significant. ***

Exercise 5

Forecast LifeExp when PropMD=.03 and TotExp = 14. Does this forecast seem realistic? Why or why not?

model_4 <- lm(LifeExp ~ PropMD + TotExp, data = df)
summary(model_4)
## 
## Call:
## lm(formula = LifeExp ~ PropMD + TotExp, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -23.996  -4.880   3.042   6.958  13.415 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 6.397e+01  7.706e-01  83.012  < 2e-16 ***
## PropMD      6.508e+02  1.946e+02   3.344 0.000998 ***
## TotExp      5.378e-05  8.074e-06   6.661 2.95e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.127 on 187 degrees of freedom
## Multiple R-squared:  0.2996, Adjusted R-squared:  0.2921 
## F-statistic: 39.99 on 2 and 187 DF,  p-value: 3.479e-15

we get this equation, \[ LifeExp = 63.97 + PropMD(650.8) + TotExp(0.00005378) \] so when PropMD=.03 and TotExp = 14, we get

LifeExp <- 63.97 + (0.03) * (650.8) + (14) * (5.378e-05)
LifeExp
## [1] 83.49475

It seems realistic that people will have life expectancy of 83.4 years.