an introduction to anova in r
DESCRIPTION
An Introduction to ANOVA in R. Daniel FasoDerek Beaton Noah Sasson Hervé Abdi. An Introduction to ANOVA in R. Daniel FasoDerek Beaton Noah Sasson Hervé Abdi. An Introduction to ANOVA in R. Daniel Faso Derek Beaton Noah Sasson Hervé Abdi. An Introduction to ANOVA in R. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/1.jpg)
An Introduction to ANOVA in R.
Daniel Faso
Derek Beaton
Noah Sasson
Hervé Abdi
![Page 2: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/2.jpg)
An Introduction to ANOVA in R.
Daniel Faso
Derek Beaton
Noah Sasson
Hervé Abdi
![Page 3: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/3.jpg)
An Introduction to ANOVA in R.
Daniel Faso
Derek Beaton
Noah Sasson
Hervé Abdi
![Page 4: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/4.jpg)
An Introduction to ANOVA in R.
Daniel Faso
Derek Beaton
Noah Sasson
Hervé Abdi
![Page 5: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/5.jpg)
An Introduction to ANOVA in R.
Daniel Faso
Derek Beaton
Noah Sasson
Hervé AbdiJoseph Dunlop
![Page 6: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/6.jpg)
Outline
• We have a lot to talk about!
–What is, and why use R?
– All sorts of ANOVAs
• And (most) everything to go with them!
![Page 7: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/7.jpg)
Outline
• We have a lot to talk about!
–What is, and why use R?
– All sorts of ANOVAs
• And (most) everything to go with them!
![Page 8: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/8.jpg)
R
• Stats or Programming?
• Gratis vs. Libre?
![Page 9: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/9.jpg)
R
• Stats or Programming?
• Gratis vs. Libre?
![Page 10: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/10.jpg)
R
• Stats and Programming
• Gratis and Libre
![Page 11: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/11.jpg)
R
• Stats and Programming
– R is a language
– R is an environment
• Gratis and Libre
![Page 12: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/12.jpg)
R
• Stats and Programming
• Gratis and Libre
– Free (as in beer)
– Free (as in speech)
– No cost, no restrictions
![Page 13: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/13.jpg)
R Communities
• Several major ones:
– CRAN
– BioConductor
– R-Forge
![Page 14: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/14.jpg)
We promise!
![Page 15: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/15.jpg)
R Communities
• Community provides add-ons
– Called packages
–March, 2013: 4380 packages (CRAN)
– February, 2014: 5206 packages (CRAN)
![Page 16: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/16.jpg)
R is a language
• What if something doesn’t exist?
–Make it yourself!
– R is Turing Complete
![Page 17: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/17.jpg)
R as a language
• Syntax comes from S
– R syntax is a bit similar to Matlab
• But with some special features
specifically for “speaking stats”
![Page 18: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/18.jpg)
All sorts of interfaces
• R is ugly.
– And sometimes slow.
• But people are changing that!
– Remember: beer and speech!
![Page 19: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/19.jpg)
Yuck!
![Page 20: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/20.jpg)
Less yuck
![Page 21: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/21.jpg)
SPSS like
![Page 22: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/22.jpg)
SPSS like
![Page 23: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/23.jpg)
Matlab like
![Page 24: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/24.jpg)
And many more• RED
• TinnR
• RevoR
– A commercial version with free
academic license
• Which means it’s faster and comes with
support!
![Page 25: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/25.jpg)
Moving on
• For today, we’ll stick with regular
ugly R.
![Page 26: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/26.jpg)
Outline
• We have a lot to talk about!
–What is, and why use R?
– All sorts of ANOVAs
• And (most) everything to go with them!
![Page 27: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/27.jpg)
All sorts of ANOVAs
• S = Subjects
• A = independent variable A
• a = level of A
• S(A) = one factor between
• S x A = one factor within (repeated)
• y = Dependent Variables
![Page 28: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/28.jpg)
All sorts of ANOVAs
• S = Subjects
• A = independent variable A
• a = level of A
• S(A) = one factor between
• S x A = one factor within (repeated)
• y = Dependent Variables
![Page 29: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/29.jpg)
All sorts of ANOVAs
• S = Subjects
• A = independent variable A
• a = level of A
• S(A) = one factor between
• S x A = one factor within (repeated)
• y = Dependent Variables
![Page 30: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/30.jpg)
All sorts of ANOVAs
• S = Subjects
• A = independent variable A
• a = level of A
• S(A) = one factor between
• S x A = one factor within (repeated)
• y = Dependent Variables
![Page 31: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/31.jpg)
All sorts of ANOVAs
• S = Subjects
• A = independent variable A
• a = level of A
• S(A) = one factor between
• S x A = one factor within (repeated)
• y = Dependent Variables
![Page 32: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/32.jpg)
All sorts of ANOVAs
• S = Subjects
• A = independent variable A
• a = level of A
• S(A) = one factor between
• S x A = one factor within (repeated)
• y = Dependent Variables
![Page 33: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/33.jpg)
All sorts of ANOVAs
• S = Subjects
• A = independent variable A
• a = level of A
• S(A) = one factor between
• S x A = one factor within (repeated)
• y = Dependent Variables
![Page 34: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/34.jpg)
All sorts of ANOVAs
• S(A)
• S(A x B) – balanced and unbalanced
• S(A) x B – balanced and unbalanced
• S(A x B) x C
![Page 35: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/35.jpg)
All sorts of ANOVAs
• S(A)
• S(A x B) – balanced and unbalanced
• S(A) x B – balanced and unbalanced
• S(A x B) x C
![Page 36: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/36.jpg)
All sorts of ANOVAs
• S(A)
• S(A x B) – balanced and unbalanced
• S(A) x B – balanced and unbalanced
• S(A x B) x C
![Page 37: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/37.jpg)
All sorts of ANOVAs
• S(A)
• S(A x B) – balanced and unbalanced
• S(A) x B – balanced and unbalanced
• S(A x B) x C
![Page 38: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/38.jpg)
All sorts of ANOVAs
• S(A)
• S(A x B) – balanced and unbalanced
• S(A) x B – balanced and unbalanced
• S(A x B) x C
![Page 39: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/39.jpg)
Outline
• We have a lot to talk about!
–What is, and why use R?
– All sorts of ANOVAs
• And (most) everything to go with them!
![Page 40: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/40.jpg)
(Most) Everything
• Transforming data
• Plotting results
• Saving results
• Post hoc tests
• And (maybe) many more!
![Page 41: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/41.jpg)
(Most) Everything
• Transforming data
• Plotting results
• Saving results
• Post hoc tests
• And (maybe) many more!
![Page 42: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/42.jpg)
(Most) Everything
• Transforming data
• Plotting results
• Saving results
• Post hoc tests
• And (maybe) many more!
![Page 43: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/43.jpg)
(Most) Everything
• Transforming data
• Plotting results
• Saving results
• Post hoc tests
• And (maybe) many more!
![Page 44: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/44.jpg)
(Most) Everything
• Transforming data
• Plotting results
• Saving results
• Post hoc tests
• And (maybe) many more!
![Page 45: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/45.jpg)
Quick background
• Two important concepts:
– Variables
– Functions
• These are how R works
![Page 46: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/46.jpg)
Quick background
• Two important concepts:
– Variables
– Functions
• These are how R works
![Page 47: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/47.jpg)
Variables
• Called so because they can change
– But they only change when you make
them change
![Page 48: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/48.jpg)
Variables
• Look like this:
> save.this <- from.that
![Page 49: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/49.jpg)
Variables
• Look like this:
> save.this <- from.that
![Page 50: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/50.jpg)
Variables
• Look like this:
> save.this <- from.that
![Page 51: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/51.jpg)
Variables
• Look like this:
> save.this <- from.that
![Page 52: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/52.jpg)
Variables
• Look like this:
> save.this = from.that
![Page 53: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/53.jpg)
Variables
• Look like this:
> save.this <- from.that
![Page 54: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/54.jpg)
Quick background
• Two important concepts:
– Variables
– Functions
• These are how R works
![Page 55: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/55.jpg)
Quick background
• Two important concepts:
– Variables
– Functions
• These are how R works
![Page 56: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/56.jpg)
Functions
y = f(x) – Ew, math.
![Page 57: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/57.jpg)
Functions
• Same idea
![Page 58: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/58.jpg)
Functions
y = f(x)
![Page 59: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/59.jpg)
Functions
y = f(x)
![Page 60: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/60.jpg)
Stuff goes in
y = f(x)
![Page 61: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/61.jpg)
Magic
y = f(x)
![Page 62: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/62.jpg)
Save that magic!
y = f(x)
![Page 63: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/63.jpg)
R does the same thing
• Say f(x) is √x
![Page 64: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/64.jpg)
f(x)
• If x is 4
• f(x) is 2
![Page 65: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/65.jpg)
In R?
>sqrt
![Page 66: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/66.jpg)
In R?
>sqrt
– But we require ()
![Page 67: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/67.jpg)
In R?
>sqrt()
![Page 68: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/68.jpg)
But really…
>sqrt(4)
![Page 69: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/69.jpg)
But really…
>sqrt(4)
[1] 2
![Page 70: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/70.jpg)
Or…
![Page 71: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/71.jpg)
Or…
![Page 72: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/72.jpg)
Or…
![Page 73: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/73.jpg)
Phew.
![Page 74: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/74.jpg)
Oh…
• We still have to talk about ANOVAs!
![Page 75: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/75.jpg)
The real presentation!
• Some back and forth
![Page 76: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/76.jpg)
Some back and forth
• We need slides & R to show
everything today
– Follow along as best you can.
– If you get lost, we’ll try to help
![Page 77: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/77.jpg)
Basics of R
• How can I transition to R?
![Page 78: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/78.jpg)
See: very ugly.
![Page 79: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/79.jpg)
How to use R
![Page 80: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/80.jpg)
Some basics
• “Working directory”
–What it means
![Page 81: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/81.jpg)
getwd()
• get working directory – the folder you’re
currently in
![Page 82: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/82.jpg)
setwd()
• set working directory – the folder you
want to change to
![Page 83: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/83.jpg)
Let’s get & set!
![Page 84: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/84.jpg)
ls()
• Lists variables in R’s workspace
![Page 85: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/85.jpg)
ls()
• Lists variables in R’s workspace
![Page 86: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/86.jpg)
ls()
• Lists variables in R’s workspace
![Page 87: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/87.jpg)
Storing variables
• my.var <- 10 + 12
![Page 88: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/88.jpg)
R is a fancy calculator
![Page 89: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/89.jpg)
(Not) Storing variables
![Page 90: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/90.jpg)
(Not Yet) Storing variables
![Page 91: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/91.jpg)
ls()
• Lists variables in R’s workspace
![Page 92: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/92.jpg)
ls()
• Lists variables in R’s workspace
![Page 93: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/93.jpg)
(Now) Storing variables
• my.var <- 10 + 12
![Page 94: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/94.jpg)
Storing variables
• my.var <- 10 + 12
![Page 95: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/95.jpg)
Storing variables
• my.var <- 10 + 12
![Page 96: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/96.jpg)
ls()
• Lists variables in R’s workspace
![Page 97: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/97.jpg)
ls()
• Lists variables in R’s workspace
![Page 98: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/98.jpg)
ls()
• Lists variables in R’s workspace
![Page 99: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/99.jpg)
Storing variables
• my.var <- 10 + 12
–We’ll be doing this a lot
![Page 100: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/100.jpg)
rm()
• What about getting rid of everything?
– rm(list=ls())
• BE CAREFUL USING THIS!
![Page 101: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/101.jpg)
rm()
• What about getting rid of everything?
– rm(list=ls())
• BE CAREFUL USING THIS!
![Page 102: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/102.jpg)
Help!
• ?
• ??
![Page 103: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/103.jpg)
Help!
• ? – a.k.a Help
• ??
![Page 104: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/104.jpg)
Help!
• ? – a.k.a Help
• ?? – a.k.a Helpless
![Page 105: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/105.jpg)
Kidding!
• ? – if you know the name
• ?? – if you don’t!
![Page 106: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/106.jpg)
Quick example
• ?getwd
![Page 107: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/107.jpg)
![Page 108: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/108.jpg)
Quick example
• ??anova
![Page 109: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/109.jpg)
![Page 110: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/110.jpg)
Really stuck?
![Page 111: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/111.jpg)
Some basic reminders
• ANOVA aims to detect differences
between means
• Null hypothesis is when there is no
difference between means
![Page 112: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/112.jpg)
Dan’s turn!
• With code walk throughs
![Page 113: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/113.jpg)
Let’s begin!
• ?aov
![Page 114: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/114.jpg)
See code for S(A)
• Return here for plotting and post-hoc
with S(AxB)
![Page 115: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/115.jpg)
We’re back up here!
![Page 116: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/116.jpg)
We’re back up here!
?interaction.plot
![Page 117: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/117.jpg)
?interaction.plot
• What does it all mean?
![Page 118: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/118.jpg)
• ?interaction.plot
![Page 119: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/119.jpg)
![Page 120: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/120.jpg)
![Page 121: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/121.jpg)
![Page 122: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/122.jpg)
![Page 123: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/123.jpg)
![Page 124: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/124.jpg)
But what about the rest?
![Page 125: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/125.jpg)
![Page 126: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/126.jpg)
![Page 127: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/127.jpg)
![Page 128: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/128.jpg)
![Page 129: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/129.jpg)
![Page 130: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/130.jpg)
![Page 131: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/131.jpg)
![Page 132: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/132.jpg)
![Page 133: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/133.jpg)
![Page 134: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/134.jpg)
![Page 135: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/135.jpg)
![Page 136: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/136.jpg)
![Page 137: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/137.jpg)
![Page 138: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/138.jpg)
![Page 139: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/139.jpg)
![Page 140: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/140.jpg)
R vs. SPSS
![Page 141: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/141.jpg)
R vs. SPSS
![Page 142: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/142.jpg)
R vs. SPSS
![Page 143: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/143.jpg)
R vs. SPSS
![Page 144: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/144.jpg)
![Page 145: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/145.jpg)
![Page 146: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/146.jpg)
![Page 147: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/147.jpg)
![Page 148: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/148.jpg)
![Page 149: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/149.jpg)
![Page 150: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/150.jpg)
Derek’s turn!
![Page 151: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/151.jpg)
S(A)xB
• Partially repeated
![Page 152: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/152.jpg)
S(A)xB
• Partially repeated
– A is between
– B is within/repeated
![Page 153: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/153.jpg)
![Page 154: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/154.jpg)
![Page 155: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/155.jpg)
![Page 156: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/156.jpg)
![Page 157: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/157.jpg)
reshape()
![Page 158: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/158.jpg)
The data
![Page 159: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/159.jpg)
IDs
![Page 160: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/160.jpg)
Repeated Factor
![Page 161: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/161.jpg)
New DV name
![Page 162: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/162.jpg)
New Repeated IV level names
![Page 163: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/163.jpg)
New Repeated Factor Name
![Page 164: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/164.jpg)
Data shape
![Page 165: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/165.jpg)
Phew
• Again.
![Page 166: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/166.jpg)
We know this
![Page 167: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/167.jpg)
But not that!
![Page 168: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/168.jpg)
Together
![Page 169: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/169.jpg)
Output
![Page 170: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/170.jpg)
Output
![Page 171: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/171.jpg)
Output
![Page 172: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/172.jpg)
Output
![Page 173: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/173.jpg)
Output
![Page 174: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/174.jpg)
Output
![Page 175: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/175.jpg)
Output
![Page 176: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/176.jpg)
Same ol’ same ol’
![Page 177: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/177.jpg)
![Page 178: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/178.jpg)
Difficult ANOVAs
• What about when things get weird?
![Page 179: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/179.jpg)
So many options
• car
• lme
• ez
• lm + aov + drop1
![Page 180: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/180.jpg)
So many options
• car
• lme
• ez
• lm + aov + drop1
![Page 181: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/181.jpg)
Easier than
• The “easy” pipeline!
![Page 182: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/182.jpg)
Code!
• See the Complex_Pipeline
![Page 183: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/183.jpg)
What didn’t we cover?
• Really complex ANOVAs
– Had between and within, but what
about…
![Page 184: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/184.jpg)
Fixed and random?
• lm can help.
• lme (lme4) is better
• You’ll need a book or two!
– And something scary…
![Page 185: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/185.jpg)
The Score Model.
• Dun dun dun
• Yabs = u… + αa + βb + ss(a) + αβab +
βsbs(a) + ebs(a)
![Page 186: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/186.jpg)
Sums of Squares?
• We talked about 1 and 3
– There are others!
• Some packages allow this
– ez, car
![Page 187: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/187.jpg)
Contrasts!
• They’re easy
– But not really in R…
![Page 188: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/188.jpg)
Packages
• car
• ez
• multcomp
• contrasts
• So many…
![Page 189: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/189.jpg)
Chicken!
• Just do a regression with lm:
– res <- lm(y ~ my.contrast)
• You’ll have to do your own
corrections, though…
![Page 190: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/190.jpg)
Fancy testing methods?
• What if my data are weird?
– Non normal?
– Small sample size?
–HUGE sample size?
![Page 191: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/191.jpg)
Resampling
• If we’re ready…
– we can transition directly
• Else,
– The answer: bootstrap and permutation
![Page 192: An Introduction to ANOVA in R](https://reader035.vdocuments.us/reader035/viewer/2022062409/56814ecd550346895dbc6b13/html5/thumbnails/192.jpg)
Before we do
• Thanks!
• Questions?
– For now
• Comments, complaints, and suggestions
– But not until after the next workshop!
– Or around at the conference!