Appex 07

STA 112 - Fall 2022

Part 1

We are going to collect some data! We are trying to estimate the average length and width of magnolia leaves. To do this, you are each going to measure 30 leaves on trees in the Mag Quad. We will use this data in class on Thursday.

Measurment collection

  • We are measuring leaf length (from stem to tip of the leaf, in green below) and width (the widest part of the leaf, in yellow below).

  • To do this, you can use an app on your phone.
    • For iPhone users, an app called “Measure” is automatically on your phone (if you don’t see it search “Measure” in your search bar)
    • For Android users, you can install this app called “Ruler” (or something similar)
  • Go to bit.ly/magnolia-data, this will take you to a Google Spreadsheet. Make a copy of this sheet by clicking File > Make a Copy
  • Make your Google Spreadsheet viewable by anyone with the link (so we can use the data in class). Click Share > General Access > Anyone with the link.
  • Measure 30 leaves (in centimeters) and enter the data in this spreadsheet (don’t pull the leaves off the trees please! Either measure ones on the ground or measure them while still on the tree 😄 )
  • Submit your data here: bit.ly/magnolia-data-form

Part 2

  1. Go to lucy.shinyapps.io/least-squares/
  2. This shows a scatter plot of 10 data points with a line estimating the relationship between x and y. Drag the blue points to change the line.
  3. See if you can find a line that minimizes the sum of square errors

Part 3

  1. Create a new project from this template in RStudio Pro:
https://github.com/sta-112-f22/appex-07.git
  1. Load the packages and data by running the top chunk of R code
  2. Learn about the PorschePrice data by running ?PorschePrice in your Console
  3. Fit a linear model predicting Price from Mileage
  4. Add a variable called y_hat to the PorschePrice dataset with the predicted y values
  5. Add a variable called residual to the PorschePrice dataset with the residuals