Data In The Wild
  1. Module 4
  2. Assignment 1
  • Home
  • Contact Us
  • For Instructors

  • Module 1
    • Overview
    • 1.1: Introduction to R and RStudio
    • 1.2: Intro to Coding in R
    • 1.3: Introduction to the tidyverse
    • Assignment 2
    • Assignment 3
  • Module 2
    • Overview
    • 2.1: Good Food Gone Bad
    • 2.2: Plotting with ggplot2
    • 2.3: Data Visualization
    • 2.4: Exploring geom Functions
    • 2.5: Module 2 Wrap-Up
    • Assignment 1
    • Assignment 2
    • Assignment 3
  • Module 3
    • Overview
    • 3.1: Leopard Seals
    • 3.2: T-Tests
    • 3.3: Comparing (Multiple) Means
    • Assignment 1
    • Assignment 2
  • Module 4
    • Overview
    • 4.1: Combining Datasets (Joins & Binds)
    • 4.2: K-Nearest Neighbor
    • 4.3: Roads and Regressions
    • 4.4: Multiple Regression
    • 4.5: Writing Functions
    • Assignment 1
    • Assignment 2
    • Assignment 3
    • Assignment 4
  • Module 5
    • Overview
    • 5.1: Population Growth
    • 5.2: Sustainable Fishing
    • 5.3: Comparing Populations
    • Assignment 1
    • Assignment 2
    • Assignment 3
  • Final Project

  • Resources

On this page

  • Assignment Details
    • Purpose
    • Task
    • Criteria for Success
    • Due Date
  • Assignment Questions
    • Set-Up
    • Phosphorus Content
    • Summer Temperature
  1. Module 4
  2. Assignment 1

Module 4 Assignment 1: Phosphorus and Hairgrass

Author

Ellen Bledsoe, Lily McMullen

Assignment Details

Purpose

The goal of this assignment is to assess your ability to perform and interpret linear regressions.

Task

Write R code which produces the correct answers and correctly interpret the results of visualizations and statistical tests.

Criteria for Success

  • Code is within the provided code chunks
  • Code chunks run without errors
  • Code produces the correct result
    • Code that produces the correct answer will receive full credit
    • Code attempts with logical direction will receive partial credit
  • Written answers address the questions in sufficient detail

Due Date

November 14 at 4 MST

Assignment Questions

In this assignment, we are going to continue using the hair grass data set from class. The first lesson (Roads and Regressions) will be particularly helpful to you in completing this assignment.

We are going to look at the relationship between hair grass density and two other variables: phosphorus content and the average summer temperature.

Set-Up

As always, we must get organized before we can do anything!

First load the tidyverse and read in the hair grass data set.

Phosphorus Content

  1. Calculate the mean and standard deviation of the measured phosphorus content.
  1. Which variable is the independent variable? Which is the dependent?

    Independent:

    Dependent:

  2. Create a scatter plot of hair grass density and phosphorus content (do not add a line of best fit yet). Be sure to make the labels easier to understand and add a theme.

  1. Write 1-2 sentences interpreting the plot above. Is this a positive relationship, negative relationship or no relationship at all? Based on your prediction, do you think the correlation coefficient will be positive, negative, or zero?

    Answer:

  2. Calculate the correlation coefficient, r.

  1. Calculate the r^2 value. Write a one sentence interpretation of what the r^2 value means in the context of these two variables.

Interpretation:

  1. What are the null and alternative hypotheses regarding the relationship between these two variables? (2 pts)

    Null:

    Alternative:

  2. Create the scatter plot that includes the line of best fit (have ggplot2 calculate the linear equation for you). Again, make the labels clearer and add a theme

  1. Using code, create the regression model in R and obtain the summary of it.
  1. Write out the equation for the line of best fit using the values from the results above and the variable names.

    Answer:

  2. Interpret the model summary. What is the p-value for our variable of interest? Do we reject or fail to reject the null hypothesis regarding the relationship between these two variables? What does this mean for the relationship between phosphorus content and hair grass density? (2 pts)

    Answer:

Summer Temperature

Now let’s do the same thing for the average summer temperatures.

  1. Create a scatter plot of hair grass density and average summer temperature. Remember to improve the axes labels and add a theme!
  1. Write 1-2 sentences interpreting the plot above. Is this a positive relationship, negative relationship or no relationship at all? Based on your prediction, do you think the correlation coefficient will be positive, negative, or zero?

    Answer:

  2. Calculate the correlation coefficient, r.

  1. Calculate the r^2 value. Write a one sentence interpretation of what the r^2 value means in the context of these two variables.

Interpretation:

  1. Create the scatter plot that includes the line of best fit (have ggplot2 calculate the linear equation for you). Make the labels easier to interpret and add a theme.
  1. Using code, create the regression model in R and obtain the summary of it.
  1. Interpret the model summary. What is the p-value for our variable of interest? Do we reject or fail to reject the null hypothesis regarding the relationship between these two variables? What does this mean for the relationship between average summer temperature and hair grass density? (2 points)

    Answer:

2026, University of Arizona & Lewis & Clark College

 
  • Made with Quarto