Woodpecker Foraging Lab

Statistical Analysis in R Studio

First, lets import our data file from our TreeData.csv file into R. by going to our Environment tab in the R Studio interface

QUESTION 1:

Does the mean Diameter at Breast Height (DBH) differ between trees with woodpecker holes or no woodpecker holes?

What is our null hypothesis?:

Woodpeckers do not have a preference for dead or alive trees.

What is our alternate hypothesis?:

Woodpeckers do have a preference for dead or alive trees.

Make a BOXPLOT of the two categories and paste below:

boxplot(DBH~Holes, data = Treedata, ylab=”DBH in inches”, xlab=”Presence or Absence of Woodpecker Holes”, main=”Boxplot of DBHs of Trees with Woodpecker Holes Present or Absent”)

where:

boxplot = this is telling R to create a boxplot

DBH~Holes = the columns from our data. The “~” means to compare by groups in column called “Holes”

Data = the name of our data file

ylab= gives the y axis a label “make sure its in quotation marks”

xlab= gives the x axis a label “…………………………………………”

main= gives the plot a title    “…………………………………………”

How do you interpret this boxplot?

The box plot shows that the data looks the same given the trees and age and growth is the same as well. Woodpeckers do not have a preference.

Now, lets see if our results are statistically significant with a t-tesTest1<-t.test(DBH~Holes, data = Treedata)

Where:

Test1 = the name we are tell R to call our results

t.test= tells R the type of test we want to conduct

DBH~Holes = what we are comparing (as in the boxplot)

Data = our data

Now type: Test1

Welch Two Sample t-test

data:  DBH by Holes

t = -0.61283, df = 203.86, p-value =

0.5407

alternative hypothesis: true difference in means is not equal to 0

95 percent confidence interval:

-20.10426  10.57011

sample estimates:

mean in group N mean in group Y

114.3512        119.1183

How do you interpret this result?:

This shows that there is a 50/50 chance that there is not a difference in preference. The p-value is not significant between DBH and Holes made by woodpeckers.

QUESTION 2:

Is there a difference between frequency of trees with woodpecker holes based on the condition of the tree (dead or alive)?

What is our null hypothesis?:

They do not have a preference to dead or alive trees.

What is our alternate hypothesis?:

They do have a preference for alive or dead trees.

Lets make a Table of our data so R can calculate the frequencies for us! (We are using 2 categories so R will calculate this for us!)

TreeTable  <- table(TreeData\$Holes, TreeData\$Condition)

Where:

TreeTable = what we are naming out table

table = telling R to make table

TreeData\$Holes = making 2 rows for Holes (Yes , No)

TreeData\$Holes = making 2 columns for Condition(Alive , Dead)

Now, type: TreeTable

What did R just do to help format our data?

Makes it easier to see that wood peckers prefer dead trees as to alive trees. It is concise and easier to visualize.

Make a MOSAIC plot of the two categories and paste below:

mosaicplot(TreeTable, color = c(“blue”, “yellow”), main=”Mosaic plot of Tree Condition and Presence Absence of Holes”, ylab= “Tree Condition”, xlab =”Presence / Absence”)

where:

mosiacplot = this is telling R to create a mosaic plot from our data

color = c(“blue”, “yellow”) = here we are telling R to make the plot different colors so that it is easier to read

ylab= gives the y axis a label “make sure its in quotation marks”

xlab= gives the x axis a label “…………………………………………”

main= gives the plot a title    “…………………………………………”

How do you interpret this mosaic plot?

The alive trees are not likely to have holes, while as the dead trees are likely to have.

Now, lets see if our results are statistically significant with a X2 goodness of fit test:

chisq.test(TreeTable)

Where:

chisq.test = we are telling R to run a X2-GOF on our table

Pearson’s Chi-squared test with        Yates’ continuity correction data:  nicole2X-squared = 43.434, df = 1,p-value = 4.385e-11

How do you interpret this result?:

It is significant and we reject the null hypothesis. When a tree is alive it is mostly likely to not have holes and when they are dead they do have.

GROUP DISCUSSION:

Brainstorm with your group about as to WHY you might have gotten these results. For example, if we found that woodpeckers prefer to forage in dead trees let’s think of reasons as to WHY this might be true. Discuss what literature we could we use to support this.

Woodpeckers prefer dead trees because the abundance insects may be greater and good shelter for nesting.