Overview

In this assignment, you will practice applying the computational approaches we have covered in class. You will upload your R script with your code for this assignment. Your script must include comments (i.e., annotations) that demonstrate that you know what your code is doing. You must also include brief answers to the question posed for each task as comments in your code. You can find the rubric I will use for assessment of this assignment on the assignment page (i.e., where you downloaded this document).

Task 1

1080 caterpillars were reared on alfalfa (a host plant for this species) with the aim of estimating the probability that caterpillars survive to adulthood on this plant. Assume Y = 208 of the N = 1080 caterpillars survived (the others died before completing development). Use \(\hat{p} = \frac{Y}{N}\) as a point estimate for survival probability. Then, generate 95% confidence intervals for this estimate by bootstrapping. Your code should include the complete procedure for performing this bootstrap estimate and your comments should report the lower and upperbounds of the 95% confidence interval.

Task 2

You have a data set in the file CherryTrees.txt with girth, height and volume measurements for 31 trees. Your task is to conduct a permutation test to determine whether the observed positive correlation between girth and height could arise by chance in your sample. Think of this as a one-tailed test, where the null hypothesis is that the correlation is negative or zero and the alternative hypothesis is that the correlation is greater than 0. You will need to download the data set from the assignment page. Write the code to perform the permutation test. Provide your complete, annotated code along with your estimate of the probability of seeing a correlation as large and positive as that observed by chance (analogous to a one-tailed P-value).

Task 3

We went over code for a golden section search designed to estimate the parameter p from a binomial model given an observation of some number of successes y out of some number of trial N. See goldenSearch.R on the course website. Your task here is to modify the goldenSearch function to instead estimate the rate parameter from a Poisson model. Your function should be written to estimate a single parameter from a set of observations (counts). Note that in such cases, you can base your inference on the product of the likelihoods of each observation, or equivalently, on the sum of log likelihoods. Once you have the code, use it to estimate the birth rate (number of births in a lifetime) from the births data set (see beetleBirths.txt). This data set has one row per individual that gives the total number of offspring (births) during the individual’s lifetime. These are seed beetles with high numbers of offspring. When you run your analysis, consider values for the rate parameter, lambda, between 1 and 100. Provide the code for the function and your analysis along with the final bounds on the rate parameter.