July 30, 2019
Instructor: Andy Hong, PhD
Lead Urban Health Scientist
The George Institute for Global Health
University of Oxford
Statistical Learning | Machine Learning |
---|---|
|
|
# Simple regression
m1 = lm(data = gapminder, lifeExp ~ income)
summary(m1)
# Call:
# lm(formula = lifeExp ~ income, data = gapminder)
#
# Residuals:
# Min 1Q Median 3Q Max
# -18.032 -3.948 1.314 4.217 9.300
#
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) 67.70194625 0.54603278 123.99 <0.0000000000000002 ***
# income 0.00025963 0.00002118 12.26 <0.0000000000000002 ***
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Residual standard error: 5.522 on 185 degrees of freedom
# Multiple R-squared: 0.4482, Adjusted R-squared: 0.4452
# F-statistic: 150.3 on 1 and 185 DF, p-value: < 0.00000000000000022
# Multiple regression
m2 = lm(data = gapminder, lifeExp ~ income + population)
summary(m2)
# Call:
# lm(formula = lifeExp ~ income + population, data = gapminder)
#
# Residuals:
# Min 1Q Median 3Q Max
# -17.939 -3.903 1.410 4.129 9.379
#
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) 67.602268543445 0.560501264567 120.610 <0.0000000000000002 ***
# income 0.000260247911 0.000021214915 12.267 <0.0000000000000002 ***
# population 0.000000002244 0.000000002797 0.802 0.423
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Residual standard error: 5.528 on 184 degrees of freedom
# Multiple R-squared: 0.4501, Adjusted R-squared: 0.4441
# F-statistic: 75.31 on 2 and 184 DF, p-value: < 0.00000000000000022