askvity

How to Find Slope of Line of Best Fit in Google Sheets?

Published in Google Sheets 2 mins read

To find the slope of the line of best fit in Google Sheets, you can use the SLOPE function. Here's how:

Steps to Calculate Slope

  1. Prepare your Data: Organize your data in two columns. Let's assume:

    • Column A: Represents the independent variable (X-values, e.g., time, month number).
    • Column B: Represents the dependent variable (Y-values, e.g., sales, revenue).

    Example:

    Month Number (Column A) Sales (Column B)
    1 100
    2 110
    3 125
    4 130
    5 145
    6 150
    7 165
    8 170
    9 185
    10 190
    11 205
    12 210
  2. Use the SLOPE Function: In an empty cell, enter the SLOPE formula. The syntax is:

    =SLOPE(data_y, data_x)

    • data_y: The range of cells containing the dependent variable (Y-values). In our example, this would be B2:B13.
    • data_x: The range of cells containing the independent variable (X-values). In our example, this would be A2:A13.
  3. Enter the Formula: In a blank cell (e.g., C2), type the following formula:

    =SLOPE(B2:B13, A2:A13)

  4. Press Enter: The cell will now display the calculated slope of the line of best fit. This value represents the average change in your Y-values (sales) for every unit change in your X-values (month number).

Explanation

The SLOPE function calculates the slope of the linear regression line using the least squares method. It essentially finds the line that minimizes the sum of the squared differences between the actual Y-values and the predicted Y-values on the line. The slope indicates the direction and steepness of the linear relationship between your X and Y variables.

Related Articles