ANCOVA and its Advantages in Experimental Design

analysis of covariance ancova glm2 n.w
1 / 29
Embed
Share

Explore the rationale behind using Analysis of Covariance (ANCOVA) in research studies, the benefits it offers in controlling extraneous variables, and practical examples of its application using the Viagra study. Learn the importance of partitioning variance, interpreting main effects, and ensuring homogeneity of regression slopes for effective data analysis.

  • ANCOVA
  • Experimental Design
  • Extraneous Variables
  • Variance Partitioning
  • Viagra Study

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Analysis of Covariance, ANCOVA (GLM2) Prof. Andy Field Slide 1

  2. Aims When and why do we use ANCOVA? Partitioning variance Carrying out ANCOVA using R Interpretation Main effects Covariates Slide 2

  3. When and Why To test for differences between group means when we know that an extraneous variable affects the outcome variable Used to control known extraneous variables Slide 3

  4. Advantages of ANCOVA Reduces error variance By explaining some of the unexplained variance (SSR) the error variance in the model can be reduced. Greater experimental control By controlling known extraneous variables, we gain greater insight into the effect of the predictor variable(s). Slide 4

  5. Variance SST Total Variance In The Data SSM SSR Improvement Due to the Model Error in Model Covariate SSR Slide 5

  6. An Example We will use the Viagra example (from the book). There are several possible confounding variables e.g. partner s libido, medication. We can conduct the same study but measure partner s libido over the same time period following the dose of Viagra. Outcome (or DV) = participant s libido Predictor (or IV) = dose of Viagra (placebo, low, high) Covariate = partner s libido Slide 6

  7. Relationships between the IV and Covariate

  8. Homogeneity of Regression Slopes

  9. Slide 9

  10. Slide 10

  11. Boxplots of the Viagra data Slide 11

  12. Are the Predictor Variable and Covariate Independent? We can test this by running an ANOVA with partnerLibido as the outcome and dose as the predictor.

  13. Fitting an ANCOVA model To create an ANCOVA model we can use the aov() function. Remember that to add a predictor, we simply write + variableName into the model. So, in Chapter 10 our ANOVA model was: viagraModel<-aov(libido ~ dose, data = viagraData) To add the predictor partnerLibido, we could simply change the model to this: viagraModel<-aov(libido ~ dose + partnerLibido, data = viagraData) Slide 13

  14. Fitting an ANCOVA Model We need to think about the order of our predictors! The reason is that when R computes the fit of the model it uses Type I, or sequential, sums of squares by default. This means that any predictor entered into the model is evaluated after predictors before it in the model. An alternative (adopted by many statistics packages) is to use Type III sums of squares.

  15. Contrasts Contrast 1: Compare the placebo group to all doses of Viagra. Contrast 2: Compare the high and low doses: contrasts(viagraData$dose)<-cbind(c(-2,1,1), c(0,-1,1)) To run the ANCOVA (with Type III sums of squares) we would execute: contrasts(viagraData$dose)<-cbind(c(-2,1,1), c(0,-1,1)) viagraModel<-aov(libido ~ partnerLibido + dose, data = viagraData) Anova(viagraModel, type="III") The first line sets the contrasts for dose, the second line creates the ANCOVA model, and the third line prints the model summary with Type III sums of squares.

  16. The Main ANCOVA Model Slide 16

  17. Planned Contrasts in ANCOVA The overall ANCOVA does not tell us which means differ, so to break down the overall effect of dose we need to look at the contrasts that we specified before we created the ANCOVA model: summary.lm(viagraModel)

  18. Planned Contrasts in ANCOVA

  19. The Covariate Slide 19

  20. Post hoc tests in ANCOVA Because we want to test differences between the adjusted means, we can use only the glht() function. As such, we are limited to using Tukey or Dunnett s post hoc tests: postHocs<-glht(viagraModel, linfct = mcp(dose = "Tukey")) summary(postHocs) confint(postHocs)

  21. Plots in ANCOVA Residuals vs Fitted Residuals vs Fitted 18 18 4 4 29 29 2 2 Residuals Residuals 0 0 -2 -2 19 19 -4 -4 3 4 5 6 3 4 5 6 Fitted values aov(libido ~ partnerLibido + dose) Fitted values aov(libido ~ partnerLibido + dose) Plots of an ANCOVA model

  22. When the Covariate Is Not Included

  23. Robust ANCOVA Looking at the effect that wearing a cloak of invisibility has on people s tendency for mischief: We recorded how many mischievous acts everyone conducted in the first 3 weeks (mischief1). After 3weeks we told about half of the sample (N = 34) that we were switching the cameras off so that no one would be able to see what they were getting up to The remainder (N = 46) were given a cloak of invisibility. We recorded the number of mischievous acts over the next 3 weeks (mischief2). The variable cloak records whether or not a person was given a cloak (cloak = 2) or not (cloak = 1).

  24. Boxplots Boxplots of the invisibility data

  25. Getting the Data into the Right Format for Robust ANCOVA Covariate Outcome covGrp1 dvGrp1 cloak mischief1 mischief2 1 No Cloak 4 11 2 No Cloak 5 7 3 No Cloak 8 8 4 No Cloak 6 7 5 No Cloak 6 10 6 No Cloak 4 7 27 No Cloak 4 9 28 No Cloak 4 9 29 No Cloak 4 11 30 No Cloak 1 9 31 No Cloak 3 8 32 No Cloak 3 6 33 No Cloak 5 12 34 No Cloak 4 10 35 Cloak 1 10 36 Cloak 7 10 37 Cloak 7 9 38 Cloak 6 12 39 Cloak 9 11 75 Cloak 4 13 76 Cloak 7 9 77 Cloak 2 10 78 Cloak 3 8 79 Cloak 6 10 80 Cloak 0 10 Group? 1 Group? 2 covGrp2 dvGrp2

  26. Conducting Robust ANCOVA ancova(covGrp1, dvGrp1, covGrp2, dvGrp2) ancboot(covGrp1, dvGrp1, covGrp2, dvGrp2, nboot = 2000)

  27. Output

  28. Robust ANCOVA Plot + + 12 + + + + + + + + + + 10 + + + + + + + Y + + + + + 8 + + + + + + + + + + 6 0 2 4 6 8 10 X Plot of baseline mischievousness (X) against post-cloak mischievousness (Y) from the ancova() function

Related


More Related Content