Data In The Wild
  1. Module 4
  2. Assignment 2
  • 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
  • Assignment Questions
    • Section 1
      • Set-Up
      • Linear Regression with Hairgrass Data
    • Section 2
      • Running A Statistical Model for Your Research Question
      • Set-Up: Research Question and Data
      • Conceptual
      • Analysis
  1. Module 4
  2. Assignment 2

Module 4 Assignment 2: Applying Regression

Author

Ellen Bledsoe, Lily McMullen

Assignment Details

Purpose

The goal of this assignment is to assess your ability to perform and interpret linear regressions and to perform a statistical analysis for your research question.

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

Assignment Questions

In this assignment, we are going to continue using the hair grass data set from class.

At the end of the assignment, you will perform the correct statistical analysis for your own research question.

NOTE! Because you are choosing which variables to use in both sections of the assignment, there is no Answer Key provided.

Section 1

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.

# Load the tidyverse

# Read in the dataset

Linear Regression with Hairgrass Data

Take a look at the hairgrass data and choose one of the environmental variables we think might influence hairgrass density that we have not used in class (AKA choose one other than nitrogen content or soil pH).

  1. Calculate the mean and standard deviation of your chosen environmental variable.

Now, we are going to explore the relationship between your chosen variable and hairgrass densities.

  1. Which variable is the independent variable? Which is the dependent?

    Independent:

    Dependent:

  2. Create a scatter plot of hair grass density and the environmental variable (do not add a line of best fit yet).

    Be sure to make the labels easier to understand and add a theme. Also make sure that the dependent variable is on the y-axis.

  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. (2 points)

Interpretation:

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

    Null:

    Alternative:

  2. Create a scatter plot that includes the line of best fit. Again, make the labels clearer, add a theme, and make sure the correct variables are on the correct axes.

  1. Run a linear regression model and print out the summary.
  1. Write out the equation for the line of best fit using numeric 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 can we conclude, then, about the relationship between your chosen environmental variable and hair grass density? (2 points)

    Answer:


Section 2

Running A Statistical Model for Your Research Question

In this module, we have covered 3 different statistical analyses: t-tests, ANOVAs, and linear regression. It is now time to decide how to apply these statistical analyses to your own research question!

For this part of the assignment, referring back to Module 2 Assignment 3 will be very helpful!

Set-Up: Research Question and Data

First, write your research question below (this really helps us when grading!).

Research question:

Now that you’ve written out your research question above, read in your chosen dataset for your final project.

Conceptual

  1. Take a look back at Module 2, Assignment 3; this is the assignment where you explored your choices for data sets to use for the final assignment. Between questions 2 and 3, there is a lot of very important information about how you should treat certain variables in each dataset.

    Assisted by that information, determine whether each variable in your research question is numeric or categorical.

Answer:

  1. State which variable is dependent and which one is independent.

Answer:

  1. Based on your answers to Questions 12 and 13 above and other information about your chosen dataset, determine which statistical analysis you should perform to answer your question. In 1-2 sentences, explain how you know.

Answer:

Analysis

  1. Perform the appropriate statistical analysis below. If necessary, add an additional line of code to print out the results.
  1. If necessary, run a pairwise comparison. If a pairwise comparison is unnecessary for your statistical analysis, explain why.

Answer:

# space for code to run a pairwise comparison if needed
  1. Interpret the results of your statistical analysis (including the pairwise comparison, if relevant). In your answer, include the p-value and if the result of your analysis is significant. Do you reject or fail to reject your null hypothesis? What do these results mean in the context of your research question? (2 points)

Answer:

2026, University of Arizona & Lewis & Clark College

 
  • Made with Quarto