Review of yesterday

# Review of yesterday

## Review of yesterday

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
##### Presentation Transcript

1. Review of yesterday

2. Mini-reports • Do check the example file. • Name the file appropriately. • Give a suitable informative title. • Write short introduction with own words. • Focus on biology • Write the result as statements (backup with t,p,n). (how non-sign?) • Use two significance digits. • Interpret the results in the discussion (biologically, not statistically).

3. Consider • Use cex, cex.lab, cex.axis! • Cred to Peter who found the cex.names. • Use ?barplot to get help.

4. 16 14 12 10 8 6 4 Red ants Black ants Logistic regression 2  2 tables Categoric 1.0 Melica 0.8 0.6 Prob. of choosing Melica 0.4 0.2 0.0 Response variable Luzula 4.5 5.5 6.5 7.5 Ant size Regression Anova t-test Continuous - - Seed size Continuous Categoric Explanatory variable

5. You now can test a lot! • Most cases with: • 1 response • 1 explanatory • Today: • Summarize • Add some more technical issues • Tomorrow: • 2 explanatory variables

6. Binomial test

7. Binomial test binom.test(18,20) Exact binomial test data: 18 and 20 number of successes = 18, number of trials = 20, p-value = 0.0004025 alternative hypothesis: true probability of success is not equal to 0.5 95 percent confidence interval: 0.6830173 0.9876515 sample estimates: probability of success 0.9

8. 2x2 Fisher Test

9. 2x2 Fisher Test fisher.test(naildata) Fisher's Exact Test for Count Data data: naildata p-value = 0.5006

10. Logistic regression

11. Logistic regression mod.glm<-glm(Y.N~Length,binomial) anova(mod.glm,test=”Chi”) Df Deviance Resid. Df Resid. Dev P(>|Chi|) NULL 46 64.109 Length 1 1.855 45 62.254 0.173

12. Regression Ash seeds

13. Regression mod.reg<-lm(falltime~seedlength) summary(mod.reg) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.55923 0.65656 2.375 0.024 * seedlength 0.02933 0.01905 1.540 0.13

14. Critical values

15. Risk of by chance only > 5 % 95% 70 60 50 40 Normal probability 30 2,5% 2,5% 20 10 0 Difference

16. Risk by chance = 6.5 +6.5 = 13 % 70 60 50 40 Normal probability 30 6.5% 6.5% 20 10 0 Difference

17. Regression mod.reg<-lm(falltime~seedlength) summary(mod.reg) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.55923 0.65656 2.375 0.024 * seedlength 0.02933 0.01905 1.540 0.13

18. Regression: a glimpse under the hood • Does x affect y? •  Does the slope differ from zero?

19. A regression t-test

20. Or in R: summary(lm(y~x))

21. Regression terminology • b = slope of the line • intercept = where the line cuts the y-axis • r = correlation coefficienten • = slope if you standardise y and x • ≈ how tight the points are in relation to the line. • From -1 to 1. 1=supertight positive relationship0=shutgun / no relationship • R2 = r2 = % of variation in the y-variable that is explained by the x-variable

22. b = 0,16 sec / mm p = 0.013 fall time ~ wing length

23. r = 0,56  R2 = 0,31 r n p = 0,013 standardised fall time ~ standardised wing length

24. Regression exercise

25. t-test / Anova

26. t-test table t.test(twiglength~treeside,var.equal=T) Two Sample t-test t = -2.7427, df = 38, p-value = 0.009244 mean in group shade mean in group sunny 1.475 2.705

27. t-test / Anova

28. t-test / Anova

29. Confidence intervals • …shows how sure we are of a group mean. • The confidence interval will contain the ”true” mean in 95 % of the time. • The larger our sample size the more sure (= confident!) we are of our sample mean  the confidence interval decreases • And (of course…), the more variation within groups, the less sure we get  confidence interval increases

30. Is there any difference? Seed size in plants

31. p = 0,047

32. Seed size

33. p = 0,0047

34. Flower size in Geranium

35. p = 0,0037

36. Flower size in Geranium

37. p = 0,094

38. Orchid seeds

39. p = 0, 40

40. Bat penises

41. p < 0,0001

42. Break?

43. Variance

44. How does the t-test work?

45. t-test table t.test(twiglength~treeside,var.equal=T) Two Sample t-test t = -2.7427, df = 38, p-value = 0.009244 mean in group shade mean in group sunny 1.475 2.705

46. Anova mod.aov<-aov(twiglength~treeside) summary(mod.aov) Df Sum Sq Mean Sq F value Pr(>F) treeside 1 15.129 15.129 7.5222 0.009244 ** Residuals 38 76.427 2.011

47. How does this F-test work? • The idea behind the F-test is to check whether the variation caused by the explanatory variable is larger than the random variation in each data point. • In this case the variation caused by the explanatory variable is the variation among groups. • The random variation is simply the variation that is NOT explained by the explanatory variable.

48. How does this F-test work? • Under the hood. • A frog example. female male

49. We measure 4 + 4 frogs 10 15 12 14 8 11 9 7