\[%% % Add your macros here; they'll be included in pdf and html output. %% \newcommand{\R}{\mathbb{R}} % reals \newcommand{\E}{\mathbb{E}} % expectation \renewcommand{\P}{\mathbb{P}} % probability \DeclareMathOperator{\logit}{logit} \DeclareMathOperator{\logistic}{logistic} \DeclareMathOperator{\sd}{sd} \DeclareMathOperator{\var}{var} \DeclareMathOperator{\cov}{cov} \DeclareMathOperator{\Normal}{Normal} \DeclareMathOperator{\Poisson}{Poisson} \DeclareMathOperator{\Beta}{Beta} \DeclareMathOperator{\Binom}{Binomial} \DeclareMathOperator{\Gam}{Gamma} \DeclareMathOperator{\Exp}{Exponential} \DeclareMathOperator{\Cauchy}{Cauchy} \DeclareMathOperator{\Unif}{Unif} \DeclareMathOperator{\Dirichlet}{Dirichlet} \DeclareMathOperator{\Wishart}{Wishart} \newcommand{\given}{\;\vert\;} \]

Homework 2: Lilypads

Assignment: You should use R for your work, and submit your work as both a final .Rmd file and rendered pdf or html files.

Due: Submit your work via Canvas by the end of the day (midnight) on Thursday, January 31. You can work with other members of class, but I expect each of you to construct and run all of the scripts yourself.

The problem

As part of a survey of plant–insect interactions in Upper Klamath Lake, we have measured the radius of a large number of lilypads, counted the number of insect pupae found on each. We would like to use these data to estimate the distribution of ages of the lilypads. We know that insects pupate here at a mean rate of 1 per square meter per week, and assume that lilypads are circular. Then, it is reasonable to assume that for a lilypad that is \(T\) weeks old with radius \(R\), the number of insects on it, which we denote \(Z\), is Poisson distributed: \[ Z \sim \text{Poisson}(\pi T R^2) . \] We want to infer the distribution of ages of the lilypads, assuming that the distribution if Gamma distributed, with shape \(k\) and rate \(\lambda\).

Here: lilypads.tsv is a file with the data. Please develop a Stan model, and apply it to estimate \(k\) and \(\lambda\). Make a histogram of the distribution of lilypad ages using the posterior mean estimates. How many lilypads do you estimate are older than 3 weeks old?