* * CHAPTER 4 * Page 118 * open data ch04-08_schools.xls data(format=xls,org=columns) 1 420 dist_cod enrl_tot teachers calw_pct meal_pct computer testscr $ comp_stu expn_stu str avginc el_pct read_scr math_scr * scatter(vlabel="Test Score",hlabel="Student Teacher Ratio",$ footer="Figure 4.2 Scatterplot of Test Score vs Student-Teacher Ratio",style=dots) # str testscr * * STATISTICS with the FRACTILES option will compute a standard set of fractiles * in addition to the mean, variance and higher moment statistics. * stats(fractiles) str stats(fractiles) testscr * * A little fancier way of doing this using REPORT. The STATS(FRACTILES) doesn't * produce the 40 and 60%-iles, so those are done using the %FRACTILES function. * report(action=define,hlabels=||"","Average","Std Dev","10%","25%","40%","50%","60%","75%","90%"||) stats(fractiles) str compute f4060=%fractiles(str,||.40,.60||) report(row=new,atcol=1) "Student-Teacher Ratio" %mean sqrt(%variance) $ %fract10 %fract25 f4060(1) %median f4060(2) %fract75 %fract90 stats(fractiles) testscr compute f4060=%fractiles(testscr,||.40,.60||) report(row=new,atcol=1) "Test Score" %mean sqrt(%variance) $ %fract10 %fract25 f4060(1) %median f4060(2) %fract75 %fract90 report(action=format,picture="*.#") report(action=show) * * LINREG is the instruction which does linear regressions. The dependent variable * is listed on the first line; the explanatory variables on the second following * the #. The ROBUSTERRORS option is used for computing the large sample * distribution described on page 133. * linreg(robusterrors) testscr # constant str * * Redo the scatter plot with the regression line included * scatter(vlabel="Test Score",hlabel="Student Teacher Ratio",lines=%beta,$ footer="Figure 4.3 Estimated Regression Line for the California Data",style=dots) # str testscr * * Compute the 95% confidence interval for slope coefficient. The coefficient is * %beta(2) (2 because it's the second coefficient in the regression) and the * standard error is in %stderrs(2). * disp "95% Confidence Interval" %beta(2)-1.96*%stderrs(2) "to" %beta(2)+1.96*%stderrs(2) * * Dummy variable regressor. str<20 evaluates to 1 if str is less than 20 and to 0 * if it isn't. * set d = str<20 linreg(robust) testscr # constant d disp "95% Confidence Interval" %beta(2)-1.96*%stderrs(2) "to" %beta(2)+1.96*%stderrs(2)