We use the dataset "MASchools" in the package "AER". The dataset contains information on test performance, school characteristics and student demographic backgrounds for school districts in Massachusetts (MA). In this exercise, we shall use R-functions in the packages "estimatr", "car" and "ggplot2". Whenever you need to compute standard errors, the type of standard error should be "HC1"or equivalently "stata".

MATLAB: An Introduction with Applications
6th Edition
ISBN:9781119256830
Author:Amos Gilat
Publisher:Amos Gilat
Chapter1: Starting With Matlab
Section: Chapter Questions
Problem 1P
icon
Related questions
Question

We use the dataset "MASchools" in the package "AER". The dataset contains information on test performance, school characteristics and student demographic backgrounds for school districts in Massachusetts (MA). In this exercise, we shall use R-functions in the packages "estimatr", "car" and "ggplot2". Whenever you need to compute standard errors, the type of standard error should be "HC1"or equivalently "stata".

The R-code below is supposed to generate a graph similar to Figure 9.1 of Stock and Watson (the left graph on page 19 of Lecture Slides 7) with the three estimated regression functions. However, when you implement it, you find that the resulting graph has a problem.

Choose the wrong statement about the code and/or the generated diagram.

a. The resulting graph shows the data points.

b. The error can be fixed by changing the location of one of the '+' symbols in the code.

c. The unknown expression y ~ poly(x,3) causes the error.

d. The and y in the formula of geom_smooth are defined as the two arguments in aes( , ) on the first line of code.

e. When the error is fixed, two regression lines have the same colour.

 

fig2
geom_point(alpha
labs(title
<- ggplot(MASchools, aes(income,score4) ) +
.75, size
1.5, color
"Test Scores vs District Income for MA data",
"cyan4") +
X =
"District income", y = "Test Score")
+
theme(axis.title
plot.title
element_text(family
element_text(hjust
"serif"),
0.5, family
"bold", size
"serif",
face
10)) +
geom_smooth(data
MASchools,
method
"violetred3") +
"Im", se =
MASchools,
FALSE, size = 0.75, color
%3D
%3D
geom_smooth(data
FALSE,
"Im", se =
y ~ poly(x,3),
method
formula
size
0.75, color ="dodgerblue3") +
MASchools,
geom_smooth(data
method
FALSE,
"Im", se =
formula = y ~ log(x),
%3D
size
0.75, color ="dodgerblue3")
print(fig2)
Transcribed Image Text:fig2 geom_point(alpha labs(title <- ggplot(MASchools, aes(income,score4) ) + .75, size 1.5, color "Test Scores vs District Income for MA data", "cyan4") + X = "District income", y = "Test Score") + theme(axis.title plot.title element_text(family element_text(hjust "serif"), 0.5, family "bold", size "serif", face 10)) + geom_smooth(data MASchools, method "violetred3") + "Im", se = MASchools, FALSE, size = 0.75, color %3D %3D geom_smooth(data FALSE, "Im", se = y ~ poly(x,3), method formula size 0.75, color ="dodgerblue3") + MASchools, geom_smooth(data method FALSE, "Im", se = formula = y ~ log(x), %3D size 0.75, color ="dodgerblue3") print(fig2)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
MATLAB: An Introduction with Applications
MATLAB: An Introduction with Applications
Statistics
ISBN:
9781119256830
Author:
Amos Gilat
Publisher:
John Wiley & Sons Inc
Probability and Statistics for Engineering and th…
Probability and Statistics for Engineering and th…
Statistics
ISBN:
9781305251809
Author:
Jay L. Devore
Publisher:
Cengage Learning
Statistics for The Behavioral Sciences (MindTap C…
Statistics for The Behavioral Sciences (MindTap C…
Statistics
ISBN:
9781305504912
Author:
Frederick J Gravetter, Larry B. Wallnau
Publisher:
Cengage Learning
Elementary Statistics: Picturing the World (7th E…
Elementary Statistics: Picturing the World (7th E…
Statistics
ISBN:
9780134683416
Author:
Ron Larson, Betsy Farber
Publisher:
PEARSON
The Basic Practice of Statistics
The Basic Practice of Statistics
Statistics
ISBN:
9781319042578
Author:
David S. Moore, William I. Notz, Michael A. Fligner
Publisher:
W. H. Freeman
Introduction to the Practice of Statistics
Introduction to the Practice of Statistics
Statistics
ISBN:
9781319013387
Author:
David S. Moore, George P. McCabe, Bruce A. Craig
Publisher:
W. H. Freeman