Lab 3

Due: end-of-lab Friday September 18

In this lab you’ll “make up” data for an outcome variable to match certain criteria, and then visualize and summarize the relationship between your outcome and predictor variables as well as fit a model to evaluate whether the made up data meets the criteria you set out to achieve.

Your starting point will be this data frame, which contains only the predictor variable x:

our_data <- tibble(x = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
our_data
# A tibble: 10 × 1
       x
   <dbl>
 1     1
 2     2
 3     3
 4     4
 5     5
 6     6
 7     7
 8     8
 9     9
10    10

Your goal is to “make up” the outcome variable y and add it to the data frame. You want to do this in such a way that when you fit a linear regression model predicting y from x, the following are true about the model:

Setup

  1. Log-in to your container;
  2. Double-check that you have the sta101-f26-files project loaded in the upper-right corner of RStudio (this should always be true);
  3. Go to the “Git” tab in the upper-right panel of RStudio and click the Pull button (arrow pointing down). Now the new assignment template and dataset should appear in the lab folder of your Files;
  4. At the top of the new .qmd, in between ---, you have the settings for the document (the so-called YAML, but don’t worry about that). Modify the authors so it lists yourself and your teammates.

Task 1

Make up the values for y in the data frame above so that the linear regression model predicting y from x meets the criteria specified in the introduction. Add these values to the data frame our_data and display the updated data frame.

Tip

Task 1 will require some trial and error, creativity, and patience. Specifically, it will require writing and testing the code for Tasks 2 and 3 multiple times until you get the desired results.

Task 2

Visualize the relationship between x and y using a scatter plot with a regression line. Comment on how the plot supports the criteria specified in the introduction.

Task 3

Fit a linear regression model predicting y from x. Display the model coefficients and the R-squared value from the model summary. Comment on how the model coefficients and R-squared value support the criteria specified in the introduction.

Submission

You collaborated with your team, but now everyone submits individually:

  1. Hit the blue Render button to generate your final PDF;
  2. Give your work a final look over to double-check a few things:
    • that your code is stylish;
    • that none of your code or pictures runs off the page. We cannot grade what we cannot read;
    • that all of your plots are well-labeled and human-readable. In other words “Flipper length (mm)” instead of flipper_length_mm;
    • If your work is lacking on any of these items, fix them and re-render as needed;
  3. Download the PDF from your container;
  4. Upload it to Gradescope;
  5. Don’t forget to mark your pages.