Professional Documents
Culture Documents
Exercise - 01 - Machine Learning
Exercise - 01 - Machine Learning
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
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
(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.