Using GoogleSheets for Least-Squares Linear Regression

1. Enter the data you want in a spreadsheet. (Most often this will be in two consecutive columns with headers. Make the left column the independent variable or “predictor” variable and the right column the output or “response” variable. You can also tell GoogleSheets to select any two columns to use here by options from the Chart editor sidebar.)

2. Highlight the data columns, including the headers.

3. You can always press the Explore button at the lower right to see if GoogleSheets has prepared the scatter plot of the data as one of its suggestions. If so, go to step 8 below; if not, continue.

4. Press Insert/Chart from the Sheets toolbar

5. Select Data/Chart type/Scatter chart in the Chart editor (this is not the plot you want yet!)

6. Check the “Use Column A as labels” box (this is probably still not the plot you want)

7. Now go to Customize/Horizontal Axis, and uncheck the “Treat labels as text box” if it is checked.

8. You can now adjust the minimum and maximum x and y values for the scatterplot, add axis labels, etc. from the options under Customize/Horizontal Axis and Customize/Vertical Axis

9. To add the regression line, go to Customize/Series and check the Trendline box

10. The Label option lets you display the equation of the regression line and display the R^{2} value.