Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

by R programming Perform a two way ANOVA . This data is the number of spruce mot

ID: 3335850 • Letter: B

Question

by R programming Perform a two way ANOVA. This data is the number of spruce moths found in traps classified by Factor 1: location of trap in tree – Top, Middle, lower, and ground and Factor 2: type of lure in trap – scent, sugar, chemical. You will need to rearrange the data so that each row is one observation with three variables – Factor 1, Factor 2 and Count

1 Location Scent 2 Top Chemical 28 19 32 15 13 39 12 42 25 21 32 29 16 18 20 37 40 18 28 36 35 39 35 4 5 6 7 Middle 8 21 17 36 38 10 27 12 Lower 13 14 15 16 17 Ground 18 21 38 32 29 17 12 23 19 14 42 17 31 29 37 18 27 15 29 16 31 34 25 14 16 19 21 23

Explanation / Answer

Below is the R code for two way Anova and the interaction plot.

# Load the data
moths <- c(28,19,32,15,13,35,22,33,21,17,32,29,16,18,20,39,12,42,25,21,36,38,44,27,22,37,40,18,28,36,44,21,38,32,29,42,17,31,29,37,35,39,41,31,34,17,12,23,19,14,18,27,15,29,16,22,25,14,16,19)
# Create vectors of factors (4 levels) for location
location=factor(c(rep(1,15),rep(2,15),rep(3,15),rep(4,15)))
# Create vectors of factors (3 levels) for lure
lure=factor(rep(gl(3,5),4))
tapply(moths,lure,mean)
tapply(moths,location,mean)
tapply(moths,location:lure,mean)
# Fit a regression model on moths data for different factors of location and lures
model <- lm(moths~location+lure+location:lure)
# Run the anova test
anova(model)
interaction.plot(lure,location,moths)

The output of the anova test is,

Analysis of Variance Table

Response: moths
Df Sum Sq Mean Sq F value Pr(>F)
location 3 1981.38 660.46 10.4503 2.094e-05 ***
lure 2 113.03 56.52 0.8943 0.4156
location:lure 6 114.97 19.16 0.3032 0.9322
Residuals 48 3033.60 63.20
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

P-value of location for F test (2.094e-05) is less than the significance level of 0.05, so we reject the null hypothesis and conclude that there is significant difference in number of spruce moths for different locations of trees.

P-value of lure for F test (0.4156) is greater than the significance level of 0.05, so we fail to reject the null hypothesis and conclude that there is not significant difference in number of spruce moths for different type of lure in trap of trees.

P-value of location and lure interaction for F test (0.9322) is greater than the significance level of 0.05, so we fail to reject the null hypothesis and conclude that there is not significant interaction of location and lure in consideration of number of spruce moths.