Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Exercises for the lecture

Institute for Statistics


Linear Models Daniel Ochieng
MZH, Room 7240
E-Mail: dochieng@uni-bremen.de
Summer Semester 2024

Exercise 01
th
Submission by Thursday, 11 April 2024, 8:30 a.m followed by a tutorial at the same time.
Handwritten/software solutions or electronically by e-mail to dochieng@uni-bremen.de.
Attempt the tasks in groups of at most three individuals.

1. Programming task I. This task is similar to the one at the end of the lecture slides.
Consider a linear regression model given by the equation:

y = 5x + 3 + ϵ,

where ϵ is a random error term following a standard normal distribution (i.e., ϵ ∼ N (0, 1)),
and X is a random variable following a Uniform distribution between 0 and 1 (i.e., X ∼
uniform(0, 1)). Assume a sample size of N = 30.
(a) Generate a dataset with 30 random values for x and corresponding values of y using
the given model equation.
(b) Fit a regression model to the generated dataset.
(c) Extract the fitted values and residuals from the regression model.
(d) Compute the variances of β̂0 and β̂1 , and the covariance between β̂0 and β̂1 .
2. Simple linear regression.
For this task, use the following data set which shows the number of recoveries from a certain
disease outbreak within a period of one year.

Month (i) 1 2 3 4 5 6 7 8 9 10 11 12

No. of recoveries (ni ) 1 2 3 1 4 9 18 23 31 20 25 37

(i) (a) Plot a scatter diagram of the data.


(b) What can you say about the relationship between the number of recoveries and the
months in the initial phase of the outbreak.
(ii) After consulting a statistician, the following model has proposed for this data

E[Ni ] = λi2 ,

where λ is the unknown parameter of interest. Two methods are proposed for estimating
this parameter.
(a) Prove that the least squares estimate is given by
P12 2
i ni
λ̂ = Pi=1
12 ,
4
i=1 i
P12
which is obtained by minimizing q = i=1 (ni − λi2 )2 .

1
(b) Prove that an alternative estimator which is a weighted least squares estimate is
given by P12
ni
λ̃ = Pi=1
12 ,
2
i=1 i
2 2
and is obtained by minimizing q ∗ = i=1 (ni −λi
P12 )
i2 .
P12 4 P12 2
(c) Given that i=1 i = 60, 710 and i=1 i = 650, calculate the values of λ̂ and λ̃
for the above data set.
(iii) To verify that the single parameter proposed for the data in part (ii) above is adequate
for the data, a two parameter model is now proposed which is given by

E[Ni ] = λiθ , i = 1, . . . , 12.

(a) A simple linear regression model E[Yi ] = α + βxi is used to estimate λ and θ where
Xi = log(i) and Yi = log(Ni ) and i = 1, . . . , 12. Give a mathematical relationship
between the regression parameters α and β to the parameters λ and θ.
(b) Suppose α̂ = −0.6112 and β̂ = 1.6008 with 0.4586 and 0.2525 as the standard
errors, respectively. Conduct an appropriate statistical test to verify that the model
proposed in (ii) above is appropriate.

3. Programming task II.


(a) Using the data set provided, fit a model with y as the response and x1 as the predictor.
Record the R2 and the residual standard error for this model.
(b) Now add x2 , x3 , x4 , x5 , x6 , x7 and x8 to this first model one at a time. For each of the
new models record the R2 and the residual standard error. Plot the trends in these two
statistics.
(c) Using the same data set, plot y against x1 . Fit the regressions of y on x1 and x1 on y.
At what points do the two lines meet?

You might also like