Assignment 3
Due Date
Friday, February 3, 2012
Data Source
The data for this assignment is the RIKZ data set, the same data set that was used in Assignment 1.
Overview
Some of you have noticed that three of the Simpson diversity values calculated by the diversity function of the vegan package are incorrect. There are three sites with no animals present and the diversity function assigns them a Simpson's diversity index of 1. Because these sites also had high values of NAP this assignment has a big effect on the regression results. (Examine the graph you made in Assignment 1 to see this.)
An examination of the code used by the diversity function makes it clear that this calculation is a mistake. The authors of the code didn't bother to consider the special limiting case of no species present. (To see the code that underlies the diversity function load the vegan package, type diversity at the R command prompt, and press the return key.) When no animals are present diversity could be sensibly assigned either a missing value or a value of zero. The problem with setting diversity equal to zero is that then the zero sites are heterogeneous—some of them are zero because they have no species while others are zero because they have a single species present.
In this HW exercise we will assign these three sites a diversity of zero and refit the models from Assignment 1. The final model you get will be different from Assignment 1. Furthermore by redefining the week variable the model can be simplified even further.
Questions
- Use the ifelse function of R to change the diversity values of those sites for which currently diversity = 1 to diversity = 0.
- Refit your models from Assignment 1 and find the best model that relates diversity to NAP and week. It will be different from what you found before.
- Based on the summary output of the model, which weeks appear to be different from each other?
- Based on your answer to Question 3 create a new "week" variable that dichotomizes the weeks into similar groups so that there are only two groups of weeks. Fit your best model from Question 2 using this week variable instead of the old week variable.
- The two "best" models with different versions of the week variable are nested models. Demonstrate this by formulating a null hypothesis that tests whether the four-week model can be reduced to the model with just two week categories. Clearly indicate what the nature of the simplification is in terms of the model parameters. Use R to formally test this null hypothesis. State your conclusions.
- Graph your final model from Question 5.
- Based on your final model from Question 5 and using all the appropriate statistical jargon, quantify and explain the effect that "week" appears to have on diversity.
Hints
- Question 1
- The ifelse function operates on vectors and returns vectors. The syntax for the ifelse function is:
ifelse(Boolean condition, value to return if TRUE, value to return if FALSE).
- A Boolean condition is any statement that evaluates to TRUE or FALSE. Boolean conditions can be constructed from logical comparison operators: less than, equal to, greater than, etc. In R the logical equals operator is the double equals sign, ==, not the single equals sign, which is an assignment operator.
- One way to proceed is to set up the ifelse statement as follows. If the Boolean condition is TRUE diversity is assigned a value of 0. If the Boolean condition is FALSE diversity is assigned its original value and hence is left unchanged.
- Question 5: The anova function can be used to compare two nested models. Just enter the names of the two models separated by commas as the arguments to anova. In this case anova tests whether the models are significantly different, i.e., whether or not the more complicated model can be reduced to the simpler model.
- Question 7: If you pretend "week" is the variable of interest here and NAP is merely a control variable, then your final model can be viewed as one of the classical regression models of statistics. There is a standard way of describing the results from such a model.
Course Home Page