程序代写代做代考 graph ECON61001 Econometric Methods Ekaterina Kazak Computer Tutorial 3, page 1 of 3 University of Manchester

ECON61001 Econometric Methods Ekaterina Kazak Computer Tutorial 3, page 1 of 3 University of Manchester
The purpose of this session is to introduce you to the OLS inference and restricted least squares estimator. The code from the previous tutorial will be useful, keep it open.
Size and power properties of statistical tests
Simulate a bivariate linear regression model:
yi = 1 − 3xi + ui, (1)
where u ∼ N(0,0.25), x ∼ N(5,16) and n = 500.
a) Examine the size properties of the two-sided test for the slope coefficient:
• Simulate the null rejection probability for a two-sided test H0 : β = −3 over a 1000 simulation draws.
• How does the sample size affect the Type I error? Plot the empirical null rejection proba- bility over a grid of sample sizes n = 100, …, 5000.
• How does the number of simulation draws, or Monte Carlo iterations, influences the pre- cision of the empirical size? Using the function cumsum plot the empirical size of the test against the number of simulations mc = 10, …, 10000.
• How does the error term variance influence the Type I error? Plot the empirical null rejection probability over a grid of σu2 = 0.1, …, 10 for n = 1000.
b) Plot
coefficient for a model defined in (1) with σu2 = 10.
power curves for n = 500 and n = 1000 (on one graph) of the two-sided test for the slope
Restricted least squares
Consider a bivariate linear regression model:
yi = 1 − 3xi + ui, (1)
where u ∼ N(0,0.25), x ∼ N(5,16) and n = 500.
a) Use your code from the previous tutorial to 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 ∈ [−6, 6].
b) On the 3D surface mark the parameter combinations which satisfy the restriction β0 + β1 = 0. 1
c) Create a function which estimates a bivariate restricted least squares problem with the restriction of the form Rβ = r. Use it to estimate the slope and the intercept which satisfy the restriction β0 + β1 = 0. Compare it with the estimates which satisfy the restriction β0 + β1 = −2 and β0 + β1 = 9.
1
It might be useful to pre-install install.packages(“pracma”, repos=”http://R-Forge.R-project.org”).

ECON61001 Econometric Methods Ekaterina Kazak Computer Tutorial 3, page 2 of 3 University of Manchester
Exercises to solve at home
OLS Inference I
We look at the dataset in attend.csv again, containing the following variables:
Variable Definition
termgpa
priGPA
ACT
attend
soph
GPA performance measure for term, between 0 (worst) and 4 (best) Note: “Pass” corresponds to gpa = 1.0
cumulative GPA prior to term
ACT score (university entrance test)
percent classes attended
= 1 if student is a sophomore (2nd-year), = 0 else
Consider two linear regression models
termgpai = α + βattend attendi + εi. (1)
termgpai = α + βattend attendi + βACT ACTi + βpriGPA priGPAi + εi. (2)
a) Based on model (2), test on a 95% confidence level the hypothesis that an increase in the
attendance rate of 10% increases the performance by 0.2.
b) Test both models (1) and (2) for statistical significance.
c) You surmise that 2 βattend = βACT in model (2). Test this hypothesis.2 Interpret.
d) What attendance rate would you predict for a first-year student with termgpa of 3.5, given her average performance in previous courses (priGPA) was one grade below average, but her ACT score was average?
e) Based on predictions from model (2), compare the performance of an individual with attendance rate of 90% and priGPA of 2.5 with the performance of an individual with 10% lower attendance rate, but a priGPA of 3.5, given ACT is at the mean for both individuals.
f) Compute the SST, SSR, SSE and R2 for both models (1) and (2). Interpret.
g) Which of the models (1) and (2) would you choose based on the adjusted R2? Why should you
not use the R2 to choose the model?
h) Draw a scatterplot of termgpa against attend. Add a regression line based on model (1). Also
add a regression line based on model (2), given that all other regressors are at the mean.
Compare your results with the homework answers which will be available on Blackboard on Friday.
2 Use the function linearHypothesis of the package car. First install the package car under ’Packages’ in the lower right window, then load the package in the script via the line library(car).

ECON61001 Econometric Methods Ekaterina Kazak Computer Tutorial 3, page 3 of 3 University of Manchester
OLS Inference II
An economist is analysing house prices using the data in the Wooldridge dataset hprice13. She is relating the logarithm of house prices (this variables is called lprice in the R data set) to some characteristics of the house using the following multiple regression model:
log(price) = β0 + β1bdrms + β2sqrft + u
where sqrft is the size of the house in square feet and bdrms is the number of bedrooms in the house while price is the price of the house in thousands of dollars. Regress this model in R and use the output to test the following hypotheses at the 5% significance level:
a) H0 :β1 =0vsH1 :β1 ̸=0 b) H0 :β2 =0vsH1 :β2 >0
c) H0 :β1 =0.05vsH1 :β1 ̸=0.05
d) H0 :β2 =0.0005vsH1 :β2 <0.0005 In each case be clear about the interpretation of the null and alternative hypotheses. Also make sure you write down an appropriate rejection rule. How would you use the p-values produced by R to do (i)? Can you use R’s p-values to do any of the other tests? Compare your results with the homework answers which will be available on Blackboard on Friday. 3 in order to use the library(wooldridge), make sure you have installed the package install.packages("wooldridge"). The data can be uploaded with data("hprice1"). Use help(hprice1) to get data description.