DOC PREVIEW
UW-Madison STAT 572 - Analysis of Covariance

This preview shows page 1 out of 4 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

The Big PictureAnalysis of CovarianceCase StudyBirds and BatsF Tests and Sums of SquaresBig PictureAnalysis of CovarianceBret LargetDepartments of Botany and of StatisticsUniversity of Wisconsin—MadisonFebruary 27, 2007Statistics 572 (Spring 2007) Analysis of Covariance March 1, 2007 1 / 16The Big Picture Analysis of CovarianceThe Big PictureAnalysis of covariance is the term given to the special case of a linearmodel where there are a mix of categorical and quantitativeexplanatory variables.With a single categorical and a single quantitative explanatoryvariable, the analysis consists of fitting separate lines to each group.A model fit without an interaction term assumes that the slopes for allgroups are identical, but that the intercepts are potentially different.A model with an interaction term allows for both different slopes andintercepts for each group.The fitted model when interactions are included is identical to fittingseparate regression lines.However, inference can differ when fitting a single model as comparedto fitting separate regression models for each group because errorestimates are shared across models.Statistics 572 (Spring 2007) Analysis of Covariance March 1, 2007 2 / 16Case Study Birds and BatsBirds and BatsBirds and bats must expend considerable energy to fly.Some bats use echolocation in flight which also requires energy.Other bats eat fruit and do not have the ability to echolocate.Scientists studied energy use of several sp ecies of birds and bats toexamine the relationship between mass and energy expenditure duringflight to see if echolocating bats had a higher cost.Variables are mass (grams), type (factor with levels bird, eBat, andnBat, latter two for echolocating and non-echolocating), and theresponse energy (Watts).Statistics 572 (Spring 2007) Analysis of Covariance March 1, 2007 3 / 16Case Study Birds and BatsData> bats = read.table("bats.txt", header = T)> batsspecies mass type energy1 PteropusGouldi 779.0 nBat 43.702 PteropusPoliocephalus 628.0 nBat 34.803 HypsignathusMonstrosus 258.0 nBat 23.304 EidolonHelvum 315.0 nBat 22.405 MeliphagaVirescens 24.3 bird 2.466 MelipsittacusUndulatus 35.0 bird 3.937 SturmisVulgaris 72.8 bird 9.158 FalcoSpaverius 120.0 bird 13.809 FalcoTinnunculus 213.0 bird 14.6010 CorvusOssifragus 275.0 bird 22.8011 LarusAtricilla 370.0 bird 26.2012 ColumbaLivia 384.0 bird 25.9013 ColumbaLivia 442.0 bird 29.5014 ColumbaLivia 412.0 bird 43.7015 ColumbaLivia 330.0 bird 34.0016 CorvusCrytoleucos 480.0 bird 27.8017 PhyllostomasHastatus 93.0 eBat 8.8318 PlecotusAuritus 8.0 eBat 1.3519 PipistrellusPipistrellus 6.7 eBat 1.1220 PlecotusAuritus 7.7 eBat 1.02Notice that both mass andenergy span different orders ofmagnitude.The two bat types are quitedifferent in mass.Birds fill the gap.Each observation corresponds toa single study.Some studies are on the samespecies.Statistics 572 (Spring 2007) Analysis of Covariance March 1, 2007 4 / 16Case Study Birds and BatsScatterplot> attach(bats)> pch.b = unclass(type)> col.b = unclass(type) + 1> plot(energy ~ mass, pch = pch.b, col = col.b, cex = 1.5)> legend(0, 40, levels(type), pch = 1:3, col = 2:4)●●●●●●●●●●●●0 200 400 600 8000 10 20 30 40massenergy●birdeBatnBatStatistics 572 (Spring 2007) Analysis of Covariance March 1, 2007 5 / 16Case Study Birds and BatsTransformed Data> bats0.form = formula(log(energy) ~ log(mass))> plot(bats0.form, pch = pch.b, col = col.b, cex = 1.5)> legend(2, 4, levels(type), pch = 1:3, col = 2:4)Log transformation of bothvariables leads to data thatbetter fitslinear modelassumptions.●●●●●●●●●●●●2 3 4 5 60 1 2 3log(mass)log(energy)●birdeBatnBatStatistics 572 (Spring 2007) Analysis of Covariance March 1, 2007 6 / 16Case Study Birds and BatsNull Model (without type)> bats0.lm = lm(log(energy) ~ log(mass))> summary(bats0.lm)$coefficientsEstimate Std. Error t value Pr(>|t|)(Intercept) -1.4682584 0.1371618 -10.70457 3.101143e-09log(mass) 0.8086098 0.0268400 30.12704 7.440291e-17> anova(bats0.lm)Analysis of Variance TableResponse: log(energy)Df Sum Sq Mean Sq F value Pr(>F)log(mass) 1 29.3919 29.3919 907.64 < 2.2e-16 ***Residuals 18 0.5829 0.0324---Signif. codes: 0'***'0.001'**'0.01'*'0.05'.'0.1' '1Fitted model has a single slopeand intercept.Statistics 572 (Spring 2007) Analysis of Covariance March 1, 2007 7 / 16Case Study Birds and BatsNull Model Plots> par(mfrow = c(2, 2))> plot(bats0.lm)The residual plot indicatespotential minor heterskedasticityand non-linearity, primarily dueto the two bird studies withhighest energy.No highly influential points.Adequate fit.0 1 2 3 4−0.2 0.0 0.2 0.4Fitted valuesResiduals●●●●●●●●●●●●●●●●●●●●Residuals vs Fitted14158●●●●●●●●●●●●●●●●●●●●−2 −1 0 1 2−1 0 1 2Theoretical QuantilesStandardized residualsNormal Q−Q141580 1 2 3 40.0 0.5 1.0 1.5Fitted valuesStandardized residuals●●●●●●●●●●●●●●●●●●●●Scale−Location141580.00 0.10 0.20−1 0 1 2LeverageStandardized residuals●●●●●●●●●●●●●●●●●●●●Cook's distance0.51Residuals vs Leverage142015Statistics 572 (Spring 2007) Analysis of Covariance March 1, 2007 8 / 16Case Study Birds and BatsNull Model Plots> plot(bats0.lm, which = 1, pch = pch.b, col = col.b)> abline(h = 0)Here is how to add plottingcharacters and color to aresidual plot.0 1 2 3 4−0.2 −0.1 0.0 0.1 0.2 0.3 0.4Fitted valuesResiduals●●●●●●●●●●●●lm(log(energy) ~ log(mass))Residuals vs Fitted14158Statistics 572 (Spring 2007) Analysis of Covariance March 1, 2007 9 / 16Case Study Birds and BatsModel with type> bats1.lm = lm(log(energy) ~ log(mass) + type)> summary(bats1.lm)$coefficientsEstimate Std. Error t value Pr(>|t|)(Intercept) -1.47409828 0.23901543 -6.1673771 1.352481e-05log(mass) 0.81495749 0.04454143 18.2966182 3.757576e-12typeeBat -0.02359824 0.15760050 -0.1497345 8.828453e-01typenBat -0.10226192 0.11418264 -0.8955995 3.837430e-01> anova(bats1.lm)Analysis of Variance TableResponse: log(energy)Df Sum Sq Mean Sq F value Pr(>F)log(mass) 1 29.3919 29.3919 849.9108 2.691e-15 ***type 2 0.0296 0.0148 0.4276 0.6593Residuals 16 0.5533 0.0346---Signif. codes: 0'***'0.001'**'0.01'*'0.05'.'0.1' '1> cf1 = coef(bats1.lm)> int1.bird = cf1[1]> int1.eBat = cf1[1] + cf1[3]> int1.nBat = cf1[1] + cf1[4]Fitted model has a single slope,but different intercept for eachtype.Adding multiple intercepts doesnot


View Full Document

UW-Madison STAT 572 - Analysis of Covariance

Download Analysis of Covariance
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Analysis of Covariance and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Analysis of Covariance 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?