Due Date: Friday, February 17, 2006
These data are taken from Beall (1940) and are reproduced in Evans (1953). The object is to determine the effect of fungus (Beauveria Bassiana) spore treatment on the control of European corn borer, Pyrausta nubilalis. Four different treatment were used as described below. Recorded applications are in grams per acre.
| Treatment | Application on July 8 |
Application on July 19 |
|---|---|---|
1 |
0 |
0 |
2 |
0 |
40 |
3 |
40 |
0 |
4 |
40 |
40 |
The first treatment occurred at the beginning of the period of oviposition while the second treatment was administered at the height of the period of oviposition. Eggs were allowed to hatch and the larva to grow to full size. What is recorded are the number of borers that were found on a unit area occupied by a hill of corn. For each treatment 120 hills of corn were examined. The table below records the number of hills exhibiting different levels of infestation (first column) under the the four different treatment regimes.
# of borers per hill of corn |
Frequency |
|||
Trt 1 |
Trt 2 |
Trt 3 |
Trt 4 |
|
0 |
19 |
24 |
43 |
47 |
1 |
12 |
16 |
35 |
23 |
2 |
18 |
16 |
17 |
27 |
3 |
18 |
18 |
11 |
9 |
4 |
11 |
15 |
5 |
7 |
5 |
12 |
9 |
4 |
3 |
6 |
7 |
6 |
1 |
1 |
7 |
8 |
5 |
2 |
1 |
8 |
4 |
3 |
2 |
0 |
9 |
4 |
4 |
— |
0 |
10 |
1 |
3 |
— |
1 |
11 |
0 |
0 |
— |
1 |
12 |
1 |
1 |
— |
— |
13 |
1 |
— |
— |
— |
15 |
1 |
— |
— |
— |
17 |
1 |
— |
— |
— |
19 |
1 |
— |
— |
— |
26 |
1 |
— |
— |
— |
Later on we'll learn how to analyze these data efficiently. For the moment we'll take an inefficient approach and analyze things one treatment at a time.
(1) Fit four separate negative binomial models to these data, one for each treatment.
Hint 1 : To make your life easier I suggest writing your negative binomial negative loglikelihood function so that it takes two arguments: a name for the raw data and a vector of parameters for the negative binomial distribution. When you run nlm you will then need to specify a generic function in which you include the data set explicitly but the parameter argument is left unspecified. I'm envisioning something like the following:
nlm(function(p) NBvec.neg(dataset1,p), c(2,1), hessian=TRUE)
where NBvec.neg is a function I wrote that constructs the negative loglikelihood for this problem. This way you will only need to write one negative loglikelihood function, but you'll have to call it four times once for each treatment each time changing the data set and initial values you use.
(2) Check the fit of the negative binomial for each treatment separately using a goodness of fit test.
(3) Create an error bar plot for the results in which you display 95% Wald confidence intervals for the mean. An example of what I have in mind is shown below.

Hint 2 : The error bars are generated with the arrows function of R. It gets used much like the lines function. See the arrows help window. To get arrows on both ends use code=3. To get the end bars use angle=90. The length of the end bars is controlled by the length argument.
Hint 3 : You will need to use the arrows function four times, once for each treatment. I recommend writing your own function with three arguments that then calls the arrows function. Your arguments should be the position along the x-axis, the value of the mean, and the value of the standard error of the mean. These three arguments are then used to position the error bar correctly on the graph. The rest of the arguments for arrows will not change across treatments and can be hard-coded into the function.
Hint 4 : You don't want any tick marks on the x-axis except those that correspond to the four treatments. To achieve this use axes=FALSE in the plot function and in the axis function for axis 1 use the at= argument to specify the position of the tick marks. You may want to use the xlim argument in the plot function to add a little white space to the plot so that the first and last tick marks are offset a little from the edges of the box, as is shown above.
(4) Do a second error bar plot this time using profile likelihood confidence intervals for the mean (in which the dispersion parameter is fixed at its MLE).
Beall, Geoffrey. 1940. The fit and significance of contagious distributions when applied to observations on larval insects. Ecology 21(4): 460474.
Evans, D. A. 1953. Experimental evidence concerning contagious distributions in ecology. Biometrika 40: 186–211.
| Jack Weiss Phone: (919) 962-5930 E-Mail: jack_weiss@unc.edu Address: Curriculum in Ecology, Box 3275, University of North Carolina, Chapel Hill, 27516 Copyright © 2006 Last Revised--Feb 17 2006 URL: http://www.unc.edu/courses/2006spring/ecol/145/001/docs/assignments/assign4.htm |