1 / 38

Nested and Paired recap

Nested and Paired recap. Nested and Paired sampling. When you have sampled one thing many times. Why? To handle pseudoreplication. or To reduce noise. Nested vs Paired tests. Nested A fixed factor above a random factor Paired A fixed factor within a random factor

huslu
Télécharger la présentation

Nested and Paired recap

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Nested and Paired recap

  2. Nested and Paired sampling • When you have sampled one thing many times. • Why? • To handle pseudoreplication. • or • To reduce noise.

  3. Nested vs Paired tests • Nested • A fixed factor above a random factor • Paired • A fixed factor within a random factor • Both are examples of mixed models.

  4. Nested recrap p = 0.00039

  5. Nested recrap

  6. Nested recap p = 0.11

  7. Nested recap p = 0.11

  8. Test Nested designs • By hand. Calculate means.Make an ordinary anova or regression on those means. • With anova over nestingthing variance aov(y~x+Error(nestingthing))

  9. Anova on oakmeans summary(aov(oakmeansY~oakhabitatsX)) Df Sum Sq Mean Sq F value Pr(>F) oakhabitatsX 1 38.920 38.920 2.8344 0.1095 Residuals 18 247.165 13.731

  10. Nested Anova with Error summary(aov(oaktwig~habitat+Error(oak))) Error: oak Df Sum Sq Mean Sq F value Pr(>F) habitat 1 389.21 389.21 2.8344 0.1095 Residuals 18 2471.65 137.31 Error: Within Df Sum Sq Mean Sq F value Pr(>F) Residuals 180 3454.5 19.2

  11. Linear Mixed Model with lmer mixoak<-lmer(oaktwig~habitat+(1|oak)) summary(mixoak) Random effects: Groups Name Variance Std.Dev. oak (Intercept) 11.812 3.4369 Residual 19.192 4.3808 Number of obs: 200, groups: oak, 20 Fixed effects: Estimate Std. Error t value (Intercept) 13.530 1.172 11.547 habitatopen 2.790 1.657 1.684

  12. Linear Mixed Model with lmer mixoak<-lmer(oaktwig~habitat+(1|oak)) summary(mixoak) Random effects: Groups Name Variance Std.Dev. oak (Intercept) 11.812 3.4369 Residual 19.192 4.3808 Number of obs: 200, groups: oak, 20 Fixed effects: Estimate Std. Error t value (Intercept) 13.530 1.172 11.547 habitatopen 2.790 1.657 1.684  38 %  62 %

  13. Paired recap

  14. Paired recap

  15. Paired recap p = 0.0050

  16. Paired recap p = 0.0017

  17. Test Paired designs • By hand. Calculate differences.Test if the differences differ from zero. a) Permutation b) 1-sample t-test • With a paired t-test. • With anova over pairingthing variance aov(y~x+Error(pairingthing))

  18. One sample t-test t.test(diffr) One Sample t-test t = -3.6876, df = 18, p-value = 0.001685 alternative hypothesis: true mean is not equal to 0 mean of x -5.868421

  19. Paired t-test t.test(groupA,groupB,paired=T) Paired t-test data: groupA and groupB t = -3.6876, df = 18, p-value = 0.001685 alternative hypothesis: true difference in means is not equal to 0 mean of the differences -5.868421

  20. Paired Anova with Error summary(aov(shoot.cm~catkin.YN+Error(birch))) Error: birch Df Sum Sq Mean Sq F value Pr(>F) Residuals 18 852.41 47.36 Error: Within Df Sum Sq Mean Sq F value Pr(>F) Catkin.YN 1 327.16 327.16 13.598 0.001685 ** Residuals 18 433.06 24.06

  21. Non-Paired Anova summary(aov(shoot.cm~catkin.YN)) Df Sum Sq Mean Sq F value Pr(>F) catkin.YN 1 327.16 327.16 9.1623 0.004544 ** Residuals 36 1285.47 35.71

  22. Paired Anova with Error summary(aov(shoot.cm~catkin.YN+Error(birch))) Error: birch Df Sum Sq Mean Sq F value Pr(>F) Residuals 18 852.41 47.36 Error: Within Df Sum Sq Mean Sq F value Pr(>F) Catkin.YN 1 327.16 327.16 13.598 0.001685 ** Residuals 18 433.06 24.06

  23. Nested Anova with Error summary(aov(oaktwig~habitat+Error(oak))) Error: oak Df Sum Sq Mean Sq F value Pr(>F) habitat 1 389.21 389.21 2.8344 0.1095 Residuals 18 2471.65 137.31 Error: Within Df Sum Sq Mean Sq F value Pr(>F) Residuals 180 3454.5 19.2

  24. Nested vs Paired tests • Nested • A fixed factor above a random factor • Paired • A fixed factor within a random factor • Both are examples of mixed models.

  25. How was the oakdata faked?

  26. How was the oakdata faked? habitat<-factor(rep(c("forest","open"),each=100))

  27. How was the oakdata faked? habitat<-factor(rep(c("forest","open"),each=100)) oak<-rep(1:20,each=10)

  28. How was the oakdata faked? habitat<-factor(rep(c("forest","open"),each=100)) oak<-rep(1:20,each=10) oak<-paste("O",oak,sep="")

  29. How was the oakdata faked? habitat<-factor(rep(c("forest","open"),each=100)) oak<-rep(1:20,each=10) oak<-paste("O",oak,sep="") oak<-factor(oak)

  30. How was the oakdata faked? habitat<-factor(rep(c("forest","open"),each=100)) oak<-rep(1:20,each=10) oak<-paste("O",oak,sep="") oak<-factor(oak) oaktwig<-c(rep(rnorm(10,12,3),each=10), rep(rnorm(10,15,3),each=10))

  31. How was the oakdata faked? habitat<-factor(rep(c("forest","open"),each=100)) oak<-rep(1:20,each=10) oak<-paste("O",oak,sep="") oak<-factor(oak) oaktwig<-c(rep(rnorm(10,12,3),each=10), rep(rnorm(10,15,3),each=10)) oaktwig<-oaktwig+rnorm(200,0,5)

  32. How was the oakdata faked? habitat<-factor(rep(c("forest","open"),each=100)) oak<-rep(1:20,each=10) oak<-paste("O",oak,sep="") oak<-factor(oak) oaktwig<-c(rep(rnorm(10,12,3),each=10), rep(rnorm(10,15,3),each=10)) oaktwig<-oaktwig+rnorm(200,0,5) oaktwig<-ifelse(oaktwig<1,1,oaktwig)

  33. How was the oakdata faked? habitat<-factor(rep(c("forest","open"),each=100)) oak<-rep(1:20,each=10) oak<-paste("O",oak,sep="") oak<-factor(oak) oaktwig<-c(rep(rnorm(10,12,3),each=10), rep(rnorm(10,15,3),each=10)) oaktwig<-oaktwig+rnorm(200,0,5) oaktwig<-ifelse(oaktwig<1,1,oaktwig) oakdata<-data.frame(habitat,oak,oaktwig)

  34. How was the oakdata faked? habitat<-factor(rep(c("forest","open"),each=100)) oak<-rep(1:20,each=10) oak<-paste("O",oak,sep="") oak<-factor(oak) oaktwig<-c(rep(rnorm(10,12,3),each=10), rep(rnorm(10,15,3),each=10)) oaktwig<-oaktwig+rnorm(200,0,5) oaktwig<-ifelse(oaktwig<1,1,oaktwig) oakdata<-data.frame(habitat,oak,oaktwig) write.xls(oakdata,"oakdata.xls") write.table(oakdata,file="clipboard",sep="\t",quote=F)

  35. Tomorrows mission… • You should fake data (first in Excel), so: • What is your response variable? • What is your explanatory variables? • Are they categorical or continuous? • Bring two graphs on paper! • One with your hypothesised relationships. • One with non-significant effects. • Then we will do power analyses.

  36. Break?

More Related