Eamonn Mallon
25/09/2019
mod_diamond2 <- lm(lprice ~ lcarat + color + cut + clarity, data = diamonds2)
library(SMPracticals)#Data is in this package
t.test(formula = height ~ type, # Formula
data = darwin) # Dataframe containing the variables
Welch Two Sample t-test
data: height by type
t = 2.4371, df = 22.164, p-value = 0.02328
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
0.3909566 4.8423767
sample estimates:
mean in group Cross mean in group Self
20.19167 17.57500
Outcrossed plants (mean +/- 95% confidence intervals: 20.19(0.39)) are larger than selfed plants (17.58 (4.48)) (t-test: t = 2.4371, df =22.164, p = 0.02328)
wilcox.test(formula = len ~ supp, # Formula
data = ToothGrowth, exact=FALSE) # Dataframe containing the variables
Wilcoxon rank sum test with continuity correction
data: len by supp
W = 575.5, p-value = 0.06449
alternative hypothesis: true location shift is not equal to 0
There is no significant difference between supplement types on their effect on tooth growth (Wilcoxon Rank-Sum Test: W= 575.5, n = 60, p = 0.06449)
cor.test(babies$gestation, babies$bwt)
Pearson's product-moment correlation
data: babies$gestation and babies$bwt
t = 15.609, df = 1221, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.3600303 0.4535398
sample estimates:
cor
0.407854
The length of gestation correlates with a baby's weight (pearson: r = 0.408, t = 15.609, df =1221, p < 0.0001 )
cor.test(babies$gestation, babies$bwt, method = "spearman")
Spearman's rank correlation rho
data: babies$gestation and babies$bwt
S = 181438572, p-value < 2.2e-16
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
0.4048838
The length of gestation correlates with a baby's weight (spearman: rho = 0.405, n = 1223, p < 0.0001 )
Blue.eyes | Brown.eyes | Row.totals | |
---|---|---|---|
Fair hair | 38 | 11 | 49 |
Dark hair | 14 | 51 | 65 |
Column totals | 52 | 62 | 114 |
count <- matrix(c(38,14,11,51), nrow=2)
chisq.test(count)
Pearson's Chi-squared test with Yates' continuity correction
data: count
X-squared = 33.112, df = 1, p-value = 8.7e-09
Hair colour is associated with eye colour (\( \chi^2 \) = 33.112, d.f. = 1, p = \( 8.7 \times 10^{-9} \))
Is hair colour associated with eye colour
These are examples of almost any biological question. Can you think of one that doesn't fit above? At a simple level, there isn't anything you can't ask with the tools you have