Regression Activity - Pt. 2: Regression Modeling
Checkpoints on this Page:
Regression Modeling
There are a few ways to create a line of best fit, but we will use Python to run a linear regression for us! It will generate our line of best fit.
Replace the ?? placeholder with the color values and nitrate concentrations from the RBG activity and scatterplot!
IMPORTANT: The color values and nitrate concentrations must be in the exact same order.
Click the ▶️ Run Code button to run the block and store your data.
Storing Your Data
Recreating Your Team’s Scatterplot
Replace the ?? placeholders with the x variable (color_data) in the first blank and the y variable (nitrate_ppm) in the second.
Click the ▶️ Run Code button to create a scatterplot that should match your group’s paper plot.
Running the Linear Regression
Replace the ?? placeholders with the x variable (color_data) in the first blank and the y variable (nitrate_ppm) in the second blank.
Click the ▶️ Run Code button to run the block and generate the equation for the line of best fit.
NOTE: The linear regression produces the equation for the line of best fit. After we know the equation, we can graph it.
Remember y = mx + b?
We can just substitute!
No code edits needed!
Click the ▶️ Run Code button to see the slope-intercept equation of your regression line.
Plotting the Regression Line
No code edits needed!
Click the ▶️ Run Code button to plot the scatterplot with the regression line included.
Activity - Draw your line of best fit on your group’s scatterplot
Materials Needed:
- Poster Markers
- Scatterplot
- Yardstick
Using the exact positioning the line of best fit python generated, copy that line onto your group’s scatterplot. When finished, bring your group’s plot to the front of the class.