Please submit this homework as an R Markdown (Rmd) file. See the introduction to Problem Set 1 if you need more information about the Rmd format.
Your file should use the following naming scheme
[last name]_ENS623_SP18_PS6.Rmd
For example,
Lammens_ENS623_SP18_PS6.Rmd
Problem 1, 3, 4 and the Bonus are worth 5 points; Problem 2 is worth 10 points.
Use the rpois
function to draw 1000 samples from a Poisson Distribution, with \(\lambda = 1\) (set as lambda = 1
). Make a histogram of the resulting data and describe the shape of the histogram.
Below is a piece of uncommented code. Go through this code, run it, and add a comment that explains each step where I have placed a #
sign. Your comments should reflect that you understand what is happening in this code.
#
n_samples <- 1000
#
n_obs <- 1000
#
n_samples_means <- c()
for (int in 1:n_samples){
#
obs <- rpois(n_obs, lambda = 1)
#
obs_mean <-mean(obs)
#
n_samples_means <- c(n_samples_means, obs_mean)
}
#
ggplot(data = NULL) +
geom_histogram(aes(x = n_samples_means, y = ..density..))
Describe the shape of the histogram resulting from the code in Problem 2. Based on this exercise, what can you say about the distributional form of the sample mean?
Review Chapter 2.3 in Quinn and Keough. In your own words, describe what the standard error of the mean is.
How do the results of Problem 2 and 3 relate to the calculation of a Confidence Interval?