ST3131
Tutorial 1
1. We have a dataset [Link] that contains information on seven European countries regarding two
continuous variables:
X = the price of alcohol relative to take-home pay, the explanatory random variable.
Y = cirrhosis deaths per 100,000 of populations, the response variable.
2
Write code (R/Python) to answer these questions.
(a) Plot Y versus X and comment on the relationship, using the scatter plot.
2
(b) Fit a simple linear regression model, and write down the tted equation.
(c) Estimate the mean cirrhosis of deaths for a country with relative price of alcohol equal to 0.05
using the tted model in 1b.
2. Consider the 3 datasets contained in three_dataset.csv where X1 is the regressor and Y 1, Y 2, Y 3
are the three possible responses. The scatter plots are given below.
(a) Using R/Python, let Y 1, Y 2, Y 3 be the responses and X1 be the regressor, form the three linear
models, and verify that the three tted models are about the same.
(b) Verify that the three tted model have the same R = 0.67.
2
(c) Produce the scatter plots for these 3 data sets (as given in Figure 2). Would you consider the
above regression models to be equally valid for these data sets?
3. Our dataset [Link] contains y the prices for vintage bottles of port (a kind of wine)
and x their age (in years) of each bottle. Use it to answer the questions that follow.
(a) Inspect the scatter plot and comment on the relationship between the response (price) and the
explanatory variable (age).
(b) Consider variable z = ln(y). Create a scatter plot of z against x and give your comments.
(c) Write R/Python code to form two simple linear regression models: Model M1 is y ∼ x, model M2
is z ∼ x. Write the equation for each tted model.
(d) Report R of each model.
2
1
ST3131
4. A data set is collected with n observations, (x , y ), ..., (x , y ). A simple linear model y = β + β x + ϵ
is tted using the data set above by OLS method. The equation of the tted model is derived as given
1 1 n n 0 1
below
ŷ = β̂0 + β̂1 x
where β̂ and β̂ are the estimators of β and β by OLS method. Prove that:
0 1 0 1
(a) P
P n
y =i
P
ŷ , or equivalently
n
i
P
e = 0 where e = y − ŷ , i = 1, ...n.
n
i=1 i i i i
(b) P x e = 0.
i=1 i=1
n
i i
(c) ŷ e = 0.
i=1
n
i=1 i i