The homework has a total of 40 points. The TAs will randomly pick one problem to grade
and this problem is worth 30 points (you will get 30 points if your answers are correct or
almost correct). The remaining 10 points will be graded on completion of this assignment.

There will be two separate submissions: one for your R code and one for your writeup.
Please submit both on Gradescope (more details for the submission of the R part are given
in “Applied questions”).

Please follow the policy stated in the syllabus about academic integrity.

The following questions involve reviewing exercises about expectations, conditional expectations,
biases and variances, and basic properties of Normal (also called Gaussian) distributions.ECON 178 WI 2021: Homework 1
Due: Feb 1, 2021 (by 12:30pm PT)
Instructions:
• The homework has a total of 40 points. The TAs will randomly pick one problem to grade
and this problem is worth 30 points (you will get 30 points if your answers are correct or
almost correct). The remaining 10 points will be graded on completion of this assignment.
• There will be two separate submissions: one for your R code and one for your writeup.
Please submit both on Gradescope (more details for the submission of the R part are given
in “Applied questions”).
• Please follow the policy stated in the syllabus about academic integrity.
• You must read, understand, agree and sign the integrity pledge
(https://academicintegrity.ucsd.edu/forms/form-pledge.html) before completing any assignment for ECON178. After you sign the pledge form, a receipt will be emailed to you. Please
include this receipt in the submission of your writeup (not the code) on Gradescope.
Conceptual questions
The following questions involve reviewing exercises about expectations, conditional expectations,
biases and variances, and basic properties of Normal (also called Gaussian) distributions.
Question 1
Suppose that we have a model yi = βxi + i (i = 1, …, n) where y = n1 ni=1 yi = 0, x =
and i is distributed normally with mean 0 and variance σ 2 ; that is, i ∼ N (0, σ 2 ).
P
Pn
i=1 xi
= 0,
(a) The OLS estimator for β minimizes the Sum of Squared Residuals:
β̂ = argminβ
n
hX
(yi − βxi )2
i
i=1
Take the first-order condition to show that
Pn
x i yi
β̂ = Pi=1
n
2 .
i=1 xi
(b) Show that
Pn
xi i
β̂ = β + Pi=1
n
2
i=1 xi
What is E[β̂ | β] and Var(β̂ | β)? Use this to show that, conditional on β, β̂ has the following
distribution:

σ2
β̂ | β ∼ N β, Pn
2 .
i=1 xi
1
2
(c) Suppose we believe that β is distributed normally with mean 0 and variance σλ ; that is,
2
β ∼ N (0, σλ ). Additionally assume that β is independent of i . Compute the mean and
variance of β̂. That is, what is E[β̂] and Var(β̂)?
(Hint you might find useful: E[w1 ] = E[E[w1 | w2 ]] and Var(w1 ) = E[Var(w1 | w2 )] +
Var(E[w1 | w2 ]) for any random variables w1 and w2 .)
(d) Since everything is normally distributed, it turns out that
E[β | β̂] = E[β] +
Cov(β, β̂)
Var(β̂)
· (β̂ − E[β̂]).
Let β̂ RR = E[β | β̂]. Compute Cov(β, β̂) and use the value of E[β] along with the values of
E[β̂], Cov(β, β̂), and Var(β̂) you have computed to show that
Pn
2
i=1 xi
2
i=1 xi +
β̂ RR = E[β | β̂] = Pn
λ
· β̂
(Hint: Cov(w1 , w2 ) = E[(w1 − E[w1 ])(w2 − E[w2 ])] and E[w1 w2 ] = E[w1 E[w2 | w1 ]] for any
random variables w1 and w2 )
(e) Does β̂ RR increase or decrease as λ increases? How does this relate to β being distributed
2
N (0, σλ )?
Question 2
Let us consider the linear regression model yi = β0 + β1 xi + ui (i = 1, …, n), which satisfies
Assumptions MLR.1 through MLR.5 (see Slide 7 in “Linear_regression_review” under “Modules”
on Canvas)1 . The xi s (i = 1, …, n) and β0 and β1 are nonrandom. The randomness comes from ui s
(i = 1, …, n) where var (ui ) = σ 2 . Let β̂0 and β̂1 be the usual OLS
are unbiased for
estimators
 (which


y1
1
 y

 1 
2 



 . 
 . 



β0 and β1 , respectively) obtained from running a regression of  ..  on  .. 
 (the intercept


 yn−1 


 1 
yn

x1
x2
..
.



column) and 


 xn−1




.




1
y1
y2
..
.



Suppose you also run a regression of 


 yn−1


x1
x2
..
.






 on 





 xn−1




 only



xn
yn
xn
(excluding the intercept column) to obtain another estimator β̃1 of β1 .
a) Give the expression
of β̃1 as a function of yi s and xi s (i = 1, …, n).

b) Derive E β̃1 in terms of β0 , β1 , and xi s. Show that β̃1 is unbiased for β1 when β0 = 0. If
β0 6= 0, when will β̃1 be unbiased for β1 ?
c) Derive Var β̃1 , the variance of β̃1 , in terms of σ 2 and xi s (i = 1, …, n).
1
The model is a simple special case of the general multiple regression model in “Linear_regression_review”.
Solving this question does not require knowledge about matrix operations.
2
d) Show that Var β̃1

is no greater than Var β̂1 ; that is, Var β̃1

you have Var β̃1 = Var β̂1 ? (Hint you might find useful: use
Pn

2
i=1 xi

≤ Var β̂1 . When do

Pn
i=1 (xi
− x̄)2 where
P
x̄ = n1 ni=1 xi .)
e) Choosing between β̂1 and β̃1 leads to a tradeoff between the bias and variance. Comment on
this tradeoff.
Question 3
Let v̂ be an estimator of the truth v. Show that E (v̂ − v)2 = Var (v̂) + [Bias (v̂)]2 where Bias (v̂) =
E (v̂) − v. (Hint: The randomness comes from v̂ only and v is nonrandom).
Applied questions (with the use of R)
For this question you will be asked to use tools from R for coding.
Installation
• To install R, please see https://www.r-project.org/.
• Once you install R, please install also R Studio https://rstudio.com/products/rstudio/
download/.
• You will need to use R Studio to solve the problem set.
Download
from Canvas ⇒ Assignments
• data_ps1.csv;
• template_ps1.R .
Submission
• Open the template_ps1.R file that we provided on Canvas ⇒ Assignments.
• All your solutions and code need to be saved in a single file named
template_ps1_YOURFIRSTANDLASTNAME.R file. Please use the template_ps1.R provided in Canvas to structure your answers.
• Any file that is not an .R will not be accepted, and the grade for this exercise
will be zero.
• Please submit your code on Gradescope.
• Please follow the policy stated in the syllabus about academic integrity.
Useful readings
In addition to the lectures provided by the instructor and the TAs, you might find the following
readings useful:
• Chapter 2.3 and 3.6 in the textbook ”An introduction to statistical learning with applications
in R”.
3
Question 4
We want to predict which variables are the most correlated with the balance in a bank account. To
do so we use the credit data set (Dua, D. and Graff, C., 2019, UCI Machine Learning Repository)
available on Canvas ⇒ Assignments.
1. Download the dataset from Canvas and open it using the command “read.csv”.
2. Open the data and report how many columns and rows the dataset has;
3. See the names of the variables (see online the command “names”);
4. Run a linear regression with Balance as a function of Income using the command “lm”;
5. Report the summary of your results (see online the command “summary”)
7. Plot a scatter plot of the regression (Hint: use abline() to draw the regression line)
8. Write down the interpretation of the coefficients as a comment in your .R script (Hint: see
template file).
Please write all your answer and code in template_ps1.R file and submit that file on Gradescope
as described in the “Submission” section.
4

Purchase answer to see full
attachment




Why Choose Us

  • 100% non-plagiarized Papers
  • 24/7 /365 Service Available
  • Affordable Prices
  • Any Paper, Urgency, and Subject
  • Will complete your papers in 6 hours
  • On-time Delivery
  • Money-back and Privacy guarantees
  • Unlimited Amendments upon request
  • Satisfaction guarantee

How it Works

  • Click on the “Place Order” tab at the top menu or “Order Now” icon at the bottom and a new page will appear with an order form to be filled.
  • Fill in your paper’s requirements in the "PAPER DETAILS" section.
  • Fill in your paper’s academic level, deadline, and the required number of pages from the drop-down menus.
  • Click “CREATE ACCOUNT & SIGN IN” to enter your registration details and get an account with us for record-keeping and then, click on “PROCEED TO CHECKOUT” at the bottom of the page.
  • From there, the payment sections will show, follow the guided payment process and your order will be available for our writing team to work on it.