Presentation is loading. Please wait.

Presentation is loading. Please wait.

Metrics Lab Econometric Problems Lab. Import the Macro data from Excel and use first row as variable names Time set the year variable by typing “tsset.

Similar presentations


Presentation on theme: "Metrics Lab Econometric Problems Lab. Import the Macro data from Excel and use first row as variable names Time set the year variable by typing “tsset."— Presentation transcript:

1 Metrics Lab Econometric Problems Lab

2 Import the Macro data from Excel and use first row as variable names Time set the year variable by typing “tsset year” into the command window. STATA now knows that is a time series data allowing operators such as lag and lead to work Run a basic OLS regression using personal consumption as the dependent variable. “regress personalconsumption gdp disposableincome unemploymentrate year” Import Data and Run Basic Regression

3 To generate the residuals in stata type the command: “predict resid, r”  This tells STATA that you are generating a new variable, naming it resid, and you want it to equal the error terms from the model. Your residuals will appear in your data editor STATA-Generating Residuals

4 To generate the fitted values, type: “predict yhat, xb”  This tells STATA that you want to generate a new variable named yhat where it equals the predicted values of the model. Your fitted values will appear in your data editor STATA-Generating Fitted Values

5 To plot your residuals against your fitted values type “scatter yhat resid” You may also use “plot yhat resid” to have you results appear in the results window. In a new window, you’ll see the scatter plot. Plotting Residuals and Fitted Values

6 Residuals Vs. Predicted Values

7 Regress with Squared Residuals

8 Heteroskedasticity Heteroskedasticity occurs when the error variance has non- constant variance. Error variance definition: the portion of the variance in a set of scores that is due to extraneous variables and measurement error. Can someone explain me the difference between errors and residuals? The variance of the observed value of the dependent variable around the regression line is non-constant.

9 Difference between Errors and Residuals The error (or disturbance) of an observed value is the deviation of the observed value from the (unobservable) true value of a quantity of interest (for example, a population mean) Ex. The difference between the height of each man in the sample and the unobservable population mean The residual of an observed value is the difference between the observed value and the estimated value of the quantity of interest (for example, a sample mean). Ex. The difference between the height of each man in the sample and the observable sample mean

10 To determine if you have heteroskedasticity you’ll want to run either a White test or the Breusch-Pagan/Cook- Weisberg test for heteroskedasticity. To run the Breusch-Pagan test, type “estat hettest” directly after running your regression. STATA- Detecting Heteroskedasticity Compare the chi-square statistic to a table. The high p-value indicates that heteroskedasticity is not a problem here.

11 Breusch-Pagan/Cook-Weisberg Test It tests whether the estimated variance of the residuals from a regression are dependent on the values of the independent variables. In that case, heteroskedasticity is present. The Breusch–Pagan test tests for conditional heteroskedasticity. It is a chi-squared test: the test statistic is n χ 2 with k degrees of freedom. It tests the null hypothesis of homoskedasticity. If the Chi Squared value is significant with p-value below an appropriate threshold (e.g. p<0.05) then the null hypothesis of homoskedasticity is rejected and heteroskedasticity assumed. If the errors have constant variance, the errors are called homoscedastic

12 To conduct a white test, type “imtest, white” directly following your regression. White Test

13 It’s similar to the Breusch-Pagan test, but the White test allows the independent variable to have a nonlinear and interactive effect on the error variance. Skewness Kurtosis

14 To determine non-normality of error terms, or skewness, you want to run a JB test. The command for the skewness test is “sktest resid” where resid is the name of your residuals STATA-Detecting Skewness If the number is bigger than 5.99 (Chi-square with 2 df at the 5 % level) your error terms are not normally distributed and you have a problem.

15 JB test continued Alternatively you can install the JB test into stata using the command: “ssc install jb” After installation you can run the jb test using the command: “jb res” where res is the name of the variable with the residual values from your regression

16 You may also wish to see a histogram of the residuals. Command: “histogram resid” –the histogram will appear in a new window. Plotting Residuals

17 To detect multicollinearity in STATA you will want to create a correlation matrix. Command: “Correl varlist” STATA-Detecting Multicollinearity rho’s of o.5 or greater should give you concern.

18 To detect autocorrelation, you will want to run a Durbin-Watson test. Command: “estat dwatson” (remember that you must have time- set your data to run a durbin watson test—tsset VarName) Or “dwstat” after you have generated a time variable and set it as a time series—”gen time = _n”  ”tsset time” STATA-Detecting Autocorrelation Compare the d-statistic to a durbin-watson table in order to determine your dl and du (I’ve included a table on the next slide)

19 Durbin-Watson Table ( α =0.05)

20 If d 4-d L treat as a problem (RED) If d L <d<d U or 4-d U <d<4-d L then inconclusive (YELLOW) If d U <d<4-d U treat as no problem (GREEN) Two-tailed test 20 dLdL dUdU 20 4 4-d U 4-d L + exists- exists ? ? No +No -

21 Newey-West To run your regression with Newey corrected SE: Command: Newey dependvar independvars, lag(#)

22 Questions? Stop by the lab or email with questions


Download ppt "Metrics Lab Econometric Problems Lab. Import the Macro data from Excel and use first row as variable names Time set the year variable by typing “tsset."

Similar presentations


Ads by Google