To be solved at home before the exercise session.
Show that if in simple linear regression both the explanatory variable \(x\) and the response \(y\) have been marginally standardized such that \(\bar{x} = 0, s_x = 1\) and \(\bar{y} = 0, s_y = 1\), then the estimated least squares regression model is simply, \[ \hat{y}_i = \hat{\rho}(x, y) x_i. \] That is, the regression coefficient of \(x\) equals the sample correlation between \(x\) and \(y\).
The cars
data give the speeds of cars (speed
, in mph) and the corresponding distances taken to stop (dist
, in feet). The below shows the model summary of a simple linear regression model fit using speed
as an explanatory variable and dist
as a response. Interpret the model results.
cars_lm <- lm(dist ~ speed, data = cars)
summary(cars_lm)
##
## Call:
## lm(formula = dist ~ speed, data = cars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -29.069 -9.525 -2.272 9.215 43.201
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -17.5791 6.7584 -2.601 0.0123 *
## speed 3.9324 0.4155 9.464 1.49e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 15.38 on 48 degrees of freedom
## Multiple R-squared: 0.6511, Adjusted R-squared: 0.6438
## F-statistic: 89.57 on 1 and 48 DF, p-value: 1.49e-12
plot(dist ~ speed, data = cars)
abline(cars_lm)
To be solved at the exercise session.
data_children.txt
contains data on children’s ages (age
, in months) and heights (height
, in centimeters). Investigate whether there is a linear relationship between the two variables.
read.table
.age
and height
.height
as a response variable.age
and the \(R^2\)-value of the model.data_tobacco.txt
contains data on cigarette consumption and lung cancer incidences from 11 different countries. The variable consumption
describes the yearly consumption of cigarettes per capita in 1930 and the variable incidence
tells the lung cancer incidence rates per 100 000 people in 1950. (Recall exercise 7.2)
read.table
.consumption
and incidence
.incidence
as a response variable.consumption
.