ECON61001 Econometric Methods Ekaterina Kazak Computer Tutorial 2, page 1 of 1 University of Manchester
The purpose of this session is to introduce you to the OLS estimator and its theoretical properties.
Statistical properties of OLS
a) Simulate a bivariate linear regression model:
yi = 1 − 3xi + ui, (1)
where u ∼ N(0,0.25), x ∼ N(5,16) and n = 500. Plot a scatter plot of y against x and the histogram for y.
b) Create a function which computes the sum of squared residuals as a function of intercept and slope parameter α0 and α1. Create a 3D visualization with the help of plotly package, which plots the sum of squared residuals surface for a range of parameters α0, α1 ∈ [−30, 30]. Zoom in the plot and find the minimum of RSS.
c) Plot a partial derivative ∂RSS fixing α1 = −3 next to a plot of partial derivative ∂RSS fixing ∂α0 ∂α1
α0 = 1. For each plot find the intersection point with a horizontal zero line. Interpret the plot.
d) Write a function which solves a bivariate OLS problem for a given (y,x) sample. Simulate the distribution of OLS parameters over a 1000 datasets, identical to the one defined in a). Draw the histograms of simulated βˆ0 and βˆ1 next to each other.
e) Examine how does the variance of OLS estimates changes with the change in σu2.
Exercises to solve at home
Consider Proposition 2.1 from the lecture notes. Define a simple linear regression
yi = βxi + ui, (2) where i = 1, …, 1000, u ∼ N (0, 100), x ∼ N (5, 100). Consider two estimators for the slope parameter:
ˆ ni=1 xiyi ̃ y ̄ β=nx2 β=x ̄
i=1 i
f) Simulate a 1000 draws from a bivariate model defined in (2).
g) Plot the histograms of βˆ and β ̃ over these draws next to each other.
h) On each histogram plot the vertical red line at the true parameter value β.
i) Which estimator, βˆ or β ̃ is more efficient and why?
j) Compare your results with the homework answers which will be available on Blackboard on Friday.