Final Project
This exam is worth 100 points. It has two plotting questions and two function-writing questions.
Display your function code and output in an Rmarkdown document.
Make a package that includes your code for the two functions. Your package should be installable from Github. Document your functions properly when making the package.
Plotting 1: Scatterplots with ggplot
Use the ChickWeight dataset provided as default in R. The data describes the weight of chicks in four different diet groups over a number of days. Generate
Plotting 2: Histograms with ggplot
Use the CO2 dataset provided as default in R. The data describes carbon dioxide concentration and uptake values for a certain type of grass species.
Create a
Function 1: Mixture Normal Distribution.
Write an R function to do the following. Generate n observations from a mixture of two normal distributions, i.e., generate U from a Bernoulli(
In this context, there is a probability (
Write a function with five arguments
Draw
Generate a two-panel plot in ggplot with the left panel containing the histogram and a fitted density for
Function 2: Weather Simulation.
Write a function to simulate the weather forecast in Richmond. Assume there are two states of weather in Richmond: sunny and rainy. If a day is sunny, the probability that the next day is sunny is
Specifically, given an initial day’s weather conditions, simulate the following
- Write a function describing this process.
- First, assume sunny conditions on the initial day. Output the number of projected sunny days in the next
days, as well as the projected rainfall accumulation. Repeat this times and return the average of all these simulations. - Now, assume rainy conditions on the initial day. Output the number of projected sunny days in the next
days, as well as the projected rainfall accumulation. Repeat this times and return the average of all these simulations.
Grading
A general rubric is below, in terms of points:
Plotting 1: 10 points
Plotting 2: 15 points
Function 1: 30 points
Function 2: 30 points
Package on Github: 10 points
Code is clear and commented: 5 points
Total: 100 Points