. use "D:\Courses\grad econometrics\homework\VOTE1.DTA" . ***Always describe your data first to understand the variables . des Contains data from D:\Courses\grad econometrics\homework\VOTE1.DTA obs: 173 vars: 10 25 Jun 1999 14:07 size: 5,190 (99.9% of memory free) ------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------- state str2 %9s state postal code district byte %3.0f congressional district democA byte %3.2f =1 if A is democrat voteA byte %5.2f percent vote for A expendA float %8.2f camp. expends. by A, $1000s expendB float %8.2f camp. expends. by B, $1000s prtystrA byte %5.2f % vote for president lexpendA float %9.0g log(expendA) lexpendB float %9.0g log(expendB) shareA float %5.2f 100*(expendA/(expendA+expendB)) ------------------------------------------------------------------------------- Sorted by: . sum Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- state | 0 district | 173 8.83815 8.768823 1 42 democA | 173 .5549133 .498418 0 1 voteA | 173 50.50289 16.78476 16 84 expendA | 173 310.611 280.9854 .302 1470.674 -------------+-------------------------------------------------------- expendB | 173 305.0885 306.2783 .93 1548.193 prtystrA | 173 49.75723 9.98365 22 71 lexpendA | 173 5.025556 1.601602 -1.197328 7.293476 lexpendB | 173 4.944369 1.571143 -.0725707 7.344844 shareA | 173 51.07654 33.48358 .094635 99.495 . **Also check summary statistics--no obvious errors . **Estimate OLS model . reg voteA prtystrA democA lexpendA lexpendB Source | SS df MS Number of obs = 173 -------------+------------------------------ F( 4, 168) = 169.23 Model | 38822.1774 4 9705.54436 Prob > F = 0.0000 Residual | 9635.07113 168 57.3516139 R-squared = 0.8012 -------------+------------------------------ Adj R-squared = 0.7964 Total | 48457.2486 172 281.728189 Root MSE = 7.5731 ------------------------------------------------------------------------------ voteA | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- prtystrA | .2519176 .0712925 3.53 0.001 .1111729 .3926623 democA | 3.792943 1.40652 2.70 0.008 1.016213 6.569674 lexpendA | 5.779294 .3918197 14.75 0.000 5.00577 6.552819 lexpendB | -6.237836 .3974596 -15.69 0.000 -7.022495 -5.453178 _cons | 37.66142 4.736036 7.95 0.000 28.3116 47.01123 ------------------------------------------------------------------------------ . bpagan prtystrA democA lexpendA lexpendB Breusch-Pagan LM statistic: 9.91949 Chi-sq( 4) P-value = .0418 . **Above is the canned routine for a more general BP test. Compute it by hand as follows . predict errors, resid . gen errorsq = errors^2 . reg errorsq prtystrA democA lexpendA lexpendB Source | SS df MS Number of obs = 173 -------------+------------------------------ F( 4, 168) = 2.33 Model | 61537.0914 4 15384.2728 Prob > F = 0.0581 Residual | 1109198.65 168 6602.37289 R-squared = 0.0526 -------------+------------------------------ Adj R-squared = 0.0300 Total | 1170735.74 172 6806.60313 Root MSE = 81.255 ------------------------------------------------------------------------------ errorsq | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- prtystrA | -.299264 .7649294 -0.39 0.696 -1.809376 1.210848 democA | 15.61921 15.09117 1.03 0.302 -14.17356 45.41198 lexpendA | -10.30573 4.204008 -2.45 0.015 -18.60522 -2.006238 lexpendB | -.0514053 4.26452 -0.01 0.990 -8.470358 8.367547 _cons | 113.9635 50.81503 2.24 0.026 13.6452 214.2817 ------------------------------------------------------------------------------ . display 173*.0526 9.0998 . display 1-chi2(4,9.0998) .05865279 . **So the p-value for this version of the test is close to 5%--borderline heterosked. . **Compute the White test for heterosked: . reg voteA prtystrA democA lexpendA lexpendB Source | SS df MS Number of obs = 173 -------------+------------------------------ F( 4, 168) = 169.23 Model | 38822.1774 4 9705.54436 Prob > F = 0.0000 Residual | 9635.07113 168 57.3516139 R-squared = 0.8012 -------------+------------------------------ Adj R-squared = 0.7964 Total | 48457.2486 172 281.728189 Root MSE = 7.5731 ------------------------------------------------------------------------------ voteA | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- prtystrA | .2519176 .0712925 3.53 0.001 .1111729 .3926623 democA | 3.792943 1.40652 2.70 0.008 1.016213 6.569674 lexpendA | 5.779294 .3918197 14.75 0.000 5.00577 6.552819 lexpendB | -6.237836 .3974596 -15.69 0.000 -7.022495 -5.453178 _cons | 37.66142 4.736036 7.95 0.000 28.3116 47.01123 ------------------------------------------------------------------------------ . predict yhat (option xb assumed; fitted values) . gen yhatsq = yhat^2 . reg errorsq yhat yhatsq Source | SS df MS Number of obs = 173 -------------+------------------------------ F( 2, 170) = 2.79 Model | 37152.5553 2 18576.2776 Prob > F = 0.0645 Residual | 1133583.18 170 6668.13637 R-squared = 0.0317 -------------+------------------------------ Adj R-squared = 0.0203 Total | 1170735.74 172 6806.60313 Root MSE = 81.659 ------------------------------------------------------------------------------ errorsq | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- yhat | -4.263681 2.166534 -1.97 0.051 -8.540455 .0130928 yhatsq | .0357354 .0212419 1.68 0.094 -.0061964 .0776672 _cons | 171.8584 53.14213 3.23 0.001 66.95494 276.7619 ------------------------------------------------------------------------------ . display 173*.0317 5.4841 . display 1-chi2(2,5.4841) .06443811 . ***This makes somewhat less likely to reject the null of homosekdasticity than the BP te > st . ***Still have a pvalue of less than 10%, so worth running with robust standard errors . reg voteA prtystrA democA lexpendA lexpendB, robust Linear regression Number of obs = 173 F( 4, 168) = 164.20 Prob > F = 0.0000 R-squared = 0.8012 Root MSE = 7.5731 ------------------------------------------------------------------------------ | Robust voteA | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- prtystrA | .2519176 .0660631 3.81 0.000 .1214969 .3823383 democA | 3.792943 1.452168 2.61 0.010 .9260957 6.659791 lexpendA | 5.779294 .533142 10.84 0.000 4.726773 6.831815 lexpendB | -6.237836 .3561583 -17.51 0.000 -6.940959 -5.534714 _cons | 37.66142 4.41894 8.52 0.000 28.93761 46.38522 ------------------------------------------------------------------------------ . ***For part b, we show that regressing the errors on the indep vars gives and R2 of zero > : . reg errors prtystrA democA lexpendA lexpendB Source | SS df MS Number of obs = 173 -------------+------------------------------ F( 4, 168) = 0.00 Model | 0 4 0 Prob > F = 1.0000 Residual | 9635.07121 168 57.3516143 R-squared = 0.0000 -------------+------------------------------ Adj R-squared = -0.0238 Total | 9635.07121 172 56.0178559 Root MSE = 7.5731 ------------------------------------------------------------------------------ errors | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- prtystrA | -4.12e-09 .0712925 -0.00 1.000 -.1407447 .1407447 democA | -6.78e-08 1.40652 -0.00 1.000 -2.776731 2.77673 lexpendA | 2.74e-08 .3918197 0.00 1.000 -.7735247 .7735247 lexpendB | -4.13e-09 .3974596 -0.00 1.000 -.7846588 .7846588 _cons | 1.22e-07 4.736036 0.00 1.000 -9.349811 9.349811 ------------------------------------------------------------------------------ . **Why is that? B/C OLS chooses the Betas so that the errors and the x's are uncorrelate > d