homework/ folderfull_name_hw##.R
justin_pomeranz_hw06.RSource with echo
dplyr, ggplot2, and
arm packages are downloaded on the machine you’re using
Packages tab in
the Files, Plots, Packages… panel and scrolling downinstall.packages("dplyr")dplyr package:# load libraries
library(arm)
library(tidyverse)
For this homework assignment, we will once again be working with the real finch data from the Galapagos Islands collected by the Grants. This time, we will just focus on the Geospiza scandens data which was collected on Daphne Major Island in 1975 and 2012. We will use a simple linear model to determined of the beak depth changed across the time period.
Be sure to download the data galapago-finches.csv and
from D2L and place them both in your data/ folder in your R
project.
Copy the following code and put it at the top of your homework script:
# read in full data set
finch <- read_csv("data/galapago-finches.csv")
# filter out scandens data and make a tibble
scandens <- finch %>%
filter(species == "scandens")
# change the year column to a character data type
scandens$year <- as.character(scandens$year)
All of the following questions relate to the scandens
object NOT the finch object.
names(), and dim() of the
columns in your scandens data object.distinct() or unique() to show each of
the values in both the year and species
column. Each value in both columns should only be printed once.blength variable in the
complete data set, ignoring any grouping variables (i.e., set
x = 0)lm() function,
and save it in an object called flm0 (short for “finch
linear model 0”).display() function to show the results of
flm0.display(flm0) doesn’t work, either the
arm package was not successfully installed or loaded, OR
you did not save the output from the lm() function
properly.Calculate and print the global mean of blength. Is
this in agreement with the global mean you wrote in problem 1.6a
above?
Calculate and print the sd for blength. Is this in
agreement with the global mean you wrote in problem 1.6e above?
blength observations
separated by year.width = 0.1 and height = 0lm() to fit a model which includes
year as a predictor variable. Save this model output in an
object called flm1, and use display() to print
out the results in your console.stat_summary() function, set
shape = 18 and size = 6.Using confint(), calculate and display a 95%
confidence interval for the estimated difference in beak length between
1975 and 2012.
Use coefplot() to display a graphical representation
of the approximate 95% CI for the estimated difference in beak length
between 1975 and 2012.
Use a comment in your script to interpret the results of problem 3.1 and 3.2. Are these interpretations in agreement with each other?
Use confint() to calculate and display a 99% CI for
the estimated difference in beak length between 1975 and 2012.
Use a comment to interpret the results of problem 3.4 above. How are the 95% and 99% CI’s different? How does our interpretation change when discussing a 95% and 99% CI?
blength variable in the
scandens data set.aes(sample = blength) inside the ggplot()
function.flm1 model
output.aes(x = .fitted, y = .resid) inside
the ggplot() function.year variable (optional)scandens data set into a new object called
scandens_factor. Make the year column a factor
and order the levels so that 2012 is first. Fit the same linear model as
in problem 2.3 but use the new scandens_factor data object
as the input, and display the results of this new model.