Ticks use large mammals as hosts and the presence of mammals represents an important vector for tick-borne diseases and humans. Tick presence may also be influenced by environmental factors. The tick.csv file has a number of different variables that can be analyzed, below are a list of the important variables for this study:
Treatment - what type of animals were allowed within the plot? CONT (control, no exclosure), LMH (total exclosure, no mammals), MESO (exclosion of large herbivores >15kg), and MEGA (exclusion of Elephants and Giraffes)
Rain - average rainfall (mm/year)
Total - total number of ticks found across 3 study species
NOTE: for each prompt, I need to see code in order to give you credit! NOTE: you can perform all of these tasks in one code chunk or many code chunks, this is up to you
tick <- read.csv("ticks.csv", header = TRUE)
str(tick)
## 'data.frame': 180 obs. of 11 variables:
## $ Period : num 11 11 11 11 11 11 11 11 11 11 ...
## $ Date : chr "20/08/2014" "20/08/2014" "20/08/2014" "21/08/2014" ...
## $ Month : chr "Aug" "Aug" "Aug" "Aug" ...
## $ Level : int 2 2 2 3 3 3 1 1 1 2 ...
## $ Replicate: int 4 5 6 7 8 9 1 2 3 4 ...
## $ Treatment: chr "CONT" "CONT" "CONT" "CONT" ...
## $ Total : int 1 1 1 0 0 5 4 0 1 37 ...
## $ RHPU : int 0 0 0 0 0 4 3 0 0 0 ...
## $ RHPR : int 0 0 0 0 0 0 0 0 0 1 ...
## $ RHPV : int 1 1 1 0 0 1 1 0 1 36 ...
## $ Rain : int 580 580 580 440 440 440 640 640 640 580 ...
table(tick$Treatment)
##
## CONT LMH MEGA MESO
## 45 45 45 45
#histogram
hist(tick$Total,
main = "Total Ticks Distribution",
xlab = "Total Number of Ticks",
col = "orchid")
#Shapiro-Wilk test
shapiro.test(tick$Total)
##
## Shapiro-Wilk normality test
##
## data: tick$Total
## W = 0.64898, p-value < 2.2e-16
#Levene's test
library(car)
## Loading required package: carData
leveneTest(Total ~ Treatment, data = tick)
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 3 7.506 9.346e-05 ***
## 176
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tickANOVA <- aov(Total ~ Treatment,
data = tick)
summary(tickANOVA)
## Df Sum Sq Mean Sq F value Pr(>F)
## Treatment 3 3387 1128.9 8.67 2.13e-05 ***
## Residuals 176 22915 130.2
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(tickANOVA)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Total ~ Treatment, data = tick)
##
## $Treatment
## diff lwr upr p adj
## LMH-CONT 11.844444 5.6050266 18.083862 0.0000115
## MEGA-CONT 3.177778 -3.0616401 9.417196 0.5508095
## MESO-CONT 5.355556 -0.8838623 11.594973 0.1201486
## MEGA-LMH -8.666667 -14.9060845 -2.427249 0.0022968
## MESO-LMH -6.488889 -12.7283067 -0.249471 0.0380749
## MESO-MEGA 2.177778 -4.0616401 8.417196 0.8020299
boxplot(Total ~ Treatment,
data = tick,
main = "Tick Population based on Treatment",
xlab = "Treatment",
ylab = "Total Number of Ticks",
col = c("lightsalmon", "orangered2", "red3", "red4"))
tick$logTotal <- log(tick$Total + 1)
#histogram
hist(tick$logTotal,
main = "Total Ticks Distribution",
xlab = "Total Number of Ticks",
col = "darkorchid")
#Shapiro-Wilk test
shapiro.test(tick$logTotal)
##
## Shapiro-Wilk normality test
##
## data: tick$logTotal
## W = 0.98087, p-value = 0.01424
#Levene's test
library(car)
leveneTest(logTotal ~ Treatment, data = tick)
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 3 2.3584 0.0733 .
## 176
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
kruskal.test(Total ~ Treatment,
data = tick)
##
## Kruskal-Wallis rank sum test
##
## data: Total by Treatment
## Kruskal-Wallis chi-squared = 23.869, df = 3, p-value = 2.66e-05
tickReg <- lm(Total ~ Rain, data = tick)
summary(tickReg)
##
## Call:
## lm(formula = Total ~ Rain, data = tick)
##
## Residuals:
## Min 1Q Median 3Q Max
## -12.471 -6.593 -2.959 2.163 76.041
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 23.50781 5.95874 3.945 0.000115 ***
## Rain -0.02508 0.01065 -2.356 0.019565 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.97 on 178 degrees of freedom
## Multiple R-squared: 0.03024, Adjusted R-squared: 0.02479
## F-statistic: 5.55 on 1 and 178 DF, p-value: 0.01957
plot(x = tick$Rain,
y = tick$Total,
pch = 16,
col = "blue",
xlab = "Average Rainfall (mm/year)",
ylab = "Tick Abundance",
main = "Relationship Between Rainfall and Tick Abundance")
5. Code: add a best fit line to help visualize the pattern
plot(x = tick$Rain,
y = tick$Total,
pch = 16,
col = "blue",
xlab = "Average Rainfall (mm/year)",
ylab = "Tick Abundance",
main = "Relationship Between Rainfall and Tick Abundance")
abline(tickReg,
col = "red",
lwd = 2)
6. Question: Do ticks prefer wet or dry climates? - According to the
linear regression line of best fit, ticks prefer drier climates due to
the indirect relationship between tick abundance and rainfall. 7. Code:
predict the number of ticks observed in a region that experiences 500
mm/year mean rainfall
newtick <- data.frame(Rain = 500)
predict(tickReg,
newdata = newtick)
## 1
## 10.96561