Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Econ 410 Practice Problems

Day 7

Yesterday we saw that SLR.1 through SLR.4 were sufficient conditions for unbiasedness. Today we proved the Gauss-Markov Theorem, which tells us that when assumptions SLR.1 through SLR.5 are satisfied, this is sufficient to conclude that OLS is the best linear unbiased estimator (BLUE). So we now have two key results:

● SLR.1 - SLR.4 ÷ OLS estimators of β0  and β1  are unbiased

● SLR.1 - SLR.5 ÷ OLS estimators of β0  and β1  are BLUE (Gauss-Markov Theorem)

In addition to the basic commands you reviewed in yesterday’s Stata video, you’ll need a few more advanced commands to complete this week’s problem sets.

When I ask you to conduct analysis in Stata, I always begin with instructions on how to load the relevant data into Stata. As an example, try loading the auto.dta dataset into Stata using the following command:

use http://www.stata-press.com/data/r14/auto.dta ,  clear

While the  above  command contains  a  URL, note that it isn’t meant to  be  clicked on  or otherwise opened with a web browser. Instead, it should be typed as a command into Stata (or, to save time, you can copy and paste it into the Stata command window).

Next, when working on the problem sets in Stata, you’ll want to make sure your name appears in the Results window.   So if your name doesn’t appear in the header, use the display command to write your name to the log.  For example, assuming you happen to be

Justin Bieber, you would type the following command:

display  "Justin  Bieber"

Use the describe command to determine which variable in this dataset contains Price” and which contains Trunk space in cubic feet”:

describe

Use the correlate command to obtain the correlation coefficient between price and trunk space:

correlate price  trunk

Use the regress command to run a regression of price on trunk space (this syntax means price should be the dependent variable while trunk should be the explanatory variable, so the order of variables in the following command matters):

regress price  trunk

Exercise  1:  In the Stata output from the regression you just ran, identify the following items: OLS estimates of the slope and intercept, SSE, SSR, SST, n, and R2

Some commands in Stata can only be used after estimating a model such as a regression – these are referred to as post-estimation commands. Perhaps the most useful is the predict command, which creates a new variable containing the predicted value for every observation:

predict pricehat

Note that the predict command is followed by the name you wish to give this new variable that contains the predicted values I have chosen to call the variable pricehat.   Note that, using the residual option, it’s also possible to have the predict command store the residuals for each observation:

predict uhat,  residuals

where here I have chosen to call the variable containing the residuals uhat. To get a better understanding of what these commands have done, take a look at the contents of some key variables in the rst ten observations of the dataset:

list price  trunk pricehat uhat  in  1/10

So why might it be useful to have the predicted values or the residuals stored as a vari- able?  One major reason is that they enable you to generate graphs and conduct regression diagnostics. For example, try out the following command:

scatter price  trunk  | |  line pricehat  trunk

The rst half of this command should be familiar, since it simply produces a scatter plot of price on trunk:

scatter price  trunk

The second command produces a line graph of the tted values on trunk, which generates a graph of the estimated regression line:

line pricehat  trunk

Putting these two commands on the same line separated with a double pipe (||), as we did initially, tells Stata to combine the two graphs, so we end up with a graph of the regression line overlaid on top of the actual data.

One thing you’ll be need to do this week is to create variables using the generate command.

As an example, the following command creates a variable containing the natural log of price: generate  lnprice=ln(price)

We can now use this new variable to run a log-linear model of price on trunk space: regress  lnprice  trunk

Exercise 2: Interpret the slope parameter from this last regression.

Exercise 3: Suppose you prefer a linear-linear model of price on trunk space, but you wish to change the units of price (currently in dollars).  Generate a new variable that contains the price of each car in thousands of dollars, then use this variable to run a regression of price (in thousands of dollars) on trunk space. Finally, produce a graph that shows both the regression line and the data.

Exercise 4: Now regress price on trunk space and displacement. In other words, estimate the following model:

price = β0 + β1trunk + β2 displacement + u

That should be everything you need to know for this week! If you run into any problems in Stata, feel free to e-mail me for help or try posting the problem to Piazza. (Either way, if you’re getting an error, remember to include a quick screenshot of the command you typed and the resulting error message.)