> #let's do the hsb ancova > hsbancdat = read.table(file="D:\\drr09\\stat209\\hsbancova", header = T) > summary(hsbancdat) school Intercept csesslp sector meanses > attach(hsbancdat) > tapply(Intercept, sector, summary) $C Min. 1st Qu. Median Mean 3rd Qu. Max. 7.336 13.200 14.470 14.200 15.900 19.720 $P Min. 1st Qu. Median Mean 3rd Qu. Max. 4.240 9.719 11.710 11.390 13.200 18.110 > tapply(csesslp, sector, summary) $C Min. 1st Qu. Median Mean 3rd Qu. Max. -2.0150 0.5698 1.5230 1.4680 2.4600 5.2580 $P Min. 1st Qu. Median Mean 3rd Qu. Max. -1.014 1.695 2.922 2.772 3.824 6.266 > #initial differences on covariate? > tapply(meanses, sector, summary) $C Min. 1st Qu. Median Mean 3rd Qu. Max. -0.7619 -0.1039 0.2388 0.1601 0.4346 0.8250 $P Min. 1st Qu. Median Mean 3rd Qu. Max. -1.19400 -0.40090 -0.09058 -0.13550 0.11370 0.68200 > #Cath higher on school-level SES > # do the ancova on school-level outcomes (level, slope) > hsbancdat$gr = 2 - as.numeric(sector) # code Cath = 1, Pub = 0 on sector > intancova = lm(Intercept ~ gr + meanses) > summary(intancova) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 12.1195 0.2026 59.807 < 2e-16 *** gr 1.2219 0.3169 3.855 0.000168 *** meanses 5.3874 0.3810 14.140 < 2e-16 *** --- Residual standard error: 1.859 on 157 degrees of freedom Multiple R-squared: 0.6489, Adjusted R-squared: 0.6444 F-statistic: 145.1 on 2 and 157 DF, p-value: < 2.2e-16 > # compare with hlm/lme coeffs gr vs 1.226 (.306) df 157 t = 4.00 > # compare with hlm/lme coeffs meanses vs 5.33 (.369) df 157 t = 14.4 > slpancova = lm(csesslp ~ gr + meanses) > summary(slpancova) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.8886 0.1600 18.049 < 2e-16 *** gr -1.5580 0.2503 -6.224 4.22e-09 *** meanses 0.8612 0.3009 2.862 0.00478 ** --- Residual standard error: 1.468 on 157 degrees of freedom Multiple R-squared: 0.1999, Adjusted R-squared: 0.1897 F-statistic: 19.61 on 2 and 157 DF, p-value: 2.492e-08 > # compare with hlm/lme coeffs gr vs -1.64 (.239) t = -6.85 > # compare with hlm/lme coeffs meanses vs 1.03 (.299) df 157 t = 3.48 > # look at comparing regressions; neither outcome refutes parallel regressions > intcnrl = lm(Intercept ~ gr + meanses + I(gr*meanses)) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 12.1825 0.2075 58.714 < 2e-16 *** gr 1.2487 0.3168 3.942 0.000122 *** meanses 5.8524 0.5139 11.388 < 2e-16 *** I(gr * meanses) -1.0261 0.7634 -1.344 0.180855 --- > slpcnrl = lm(csesslp ~ gr + meanses + I(gr*meanses)) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.9122 0.1646 17.692 < 2e-16 *** gr -1.5480 0.2513 -6.160 5.92e-09 *** meanses 1.0351 0.4077 2.539 0.0121 * I(gr * meanses) -0.3837 0.6056 -0.634 0.5272 ---