程序代写案例-D2L-Assignment 1
时间:2022-04-19
Assignment 1: Due before midnight on Saturday,
Feb 5th on D2L
January 25, 2022
The following table gives the variables to work with from the big STAR data set:
x y
1 freem frac s math score
2 hs frac own z math score
3 ed frac grd z math score
4 edi s elarts score
5 re asian frac s elarts score
6 sex frac female z elarts score
7 re hl fracs .5×math score+ .5× elarts score
8 age frac 75 older z .5×math score+ .5× elarts score
9 rev total d .25×math score+ .75× elarts score
0 te salary avg d .25×math score+ .75× elarts score
1. (25 points) Load the STAR data set into R and have a good look at the variables
in the data viewer. Select the x and y from the table above that correspond to
the 4th and 5th digits in your Ryerson student number respectively.1 Generate
a scatterplot in R of y against x and put the line of best fit through the scatter.
Take a screenshot (or multiple screenshots) of the results showing the (1) script
used to generate the scatter, (2) the code executed in the console, and (3) the
scatterplot itself.
2. (25 points) Using the same variables from (1), run a regression of y against x and
x2 and summarize the output of the regression (with the correct standard errors)
in the R console. Do these results suggest that the relationship between y and x
is non-linear? Explain.
3. (25 points) Now choose one other explanatory variable, either from the table of x
variables above or another variable of your choice from the STAR dataset (there
are many options). Call this new variable z. Run the regression of y on x, x2
1For example, if your Ryerson student number is 500945923, x is rev total d and y is elarts score.
1
and z. Interpret the coefficients from this regression and explain their economic
implications.
4. (25 points) Run the regression of y on x and then the regression of y on x and
z. Show the results from both regressions in the R console. What happens to
the coefficient on x when z is included compared to when z is omitted? Why
does (or doesn’t) the estimated coefficient of x change when z is included in
your regression? What does this imply about the potential endogeneity of x as
an independent variable?
2