How to use the INTERCEPT function
What is the INTERCEPT function?
The INTERCEPT function returns a value representing the y-value where a line intersects the y-axis. The line is calculated using the method of least squares based on known x- and y-values.
Table of Contents
1. Introduction
When to use the INTERCEPT function?
Use the INTERCEPT function when you want to build a linear regression line based on this straight line equation:
y = mx + c.
c is where the line cuts the y-axis
m is the slope of the line and can be calculated using the SLOPE function.
What is a linear regression line?
A linear regression line is a straight line fit to data to model the linear relationship between two variables. But it does not definitively prove causality, it provides a simple fitted model for prediction.
What is a linear equation?
A linear equation is a type of equation that can be written in the form ax + b = 0, where a and b are constants and x is a variable. A linear equation represents a relationship between two quantities that are proportional to each other.
For example, if you have a linear equation that says y = 3x + 4, it means that for every unit increase in x, the value of y increases by 3 units and when x is zero y is 4.
The graph of a linear equation is always a straight line, a linear equation does not involve powers of variables.
How to calculate a regression line?
A regression line is based on the method of least squares, which aims to find the line that best fits a set of data points by minimizing the sum of the squared differences between the actual data points and the corresponding points on the line.
We discussed the straight line equation above:
y = mx + c.
- c is where the line cuts the y-axis
- m is the slope of the line
To find the values of m and c that best fit the data we use the following formulas:
Slope (m): m = Σ((x - xmean)(y - ymean)) / Σ((x - xmean)2)
Σ represents the sum of the values
xmean and ymean are the means (averages) of the x and y values respectively.
Y-intercept (b): b = ymean - m * xmean
2. Syntax
INTERCEPT(known_y's, known_x's)
3. Arguments
known_y's | Required. An array or cell reference to dependent data points. |
known_x's | Required. An array or cell reference to independent data points. |
4. Example 1
Determine the intercept of a linear regression line for the following data? X Values: 10, 15, 20, 25, 30 Y Values: 25, 30, 35, 40, 45
The image above shows the data in cell range B23:C27, the x y scatter chart above shows the data points. The formula in cell E3 calculates the intercept value based on the x and y values in B23:C27.
Formula in cell E3:
INTERCEPT function = ȳ - bx̄
The intercept value is where the regression line intersects the y-axis. The regression line is calculated using the INTERCEPT and SLOPE function, the black line shown in the chart above represents the regression line.
In this particular example, all data points are on the regression line meaning they are not scattered below and above the regression line.
SLOPE function: Σ((x-x̄)(y-ȳ))/ Σ(x-x̄)2
Zero values are included but text, logical values and empty cells are ignored.
5. Example 2
Find the intercept of the line that best fits the following sales data? Units Sold: 80, 170, 190, 280, 290 Revenue ($): 5000, 7500, 10000, 12500, 15000
The image above shows the data in cell range B23:C27, the x y scatter chart above shows the data points. The formula in cell E3 calculates the intercept value based on the x and y values in B23:C27.
Formula in cell E3:
INTERCEPT function = ȳ - bx̄
The intercept value is where the regression line intersects the y-axis. The regression line is calculated using the INTERCEPT and SLOPE function, the black line shown in the chart above represents the regression line.
SLOPE function: Σ((x-x̄)(y-ȳ))/ Σ(x-x̄)2
x̄ = AVERAGE(B23:B27) equals 202
ȳ = AVERAGE(C23:C27) equals 10000
Calculate x-x̄
80 - 202 = -122
170 - 202 = -32
190 - 202 = -12
280 - 202 = 78
290 - 202 = 88
Calculate y-ȳ
5000 - 10000 = -5000
7500 - 10000 = -2500
10000 - 10000 = 0
12500 - 10000 = 2500
1500 - 10000 = 5000
Calculate (x-x̄)(y-ȳ)
-122*-5000=610000
-32*-2500=80000
-12*0=0
78*2500=195000
88*5000=440000
Calculate Σ((x-x̄)(y-ȳ))
610000+80000+0+195000+440000=1325000
Calculate Σ(x-x̄)2
(-122)2+(-32)2+(-12)2+782+882=29880
Calculate Σ(x-x̄)2
1325000/29880 = 44.34 This is the SLOPE value.
Y-intercept (b): b = ymean - m * xmean
b = 10000 - 44.34 * 202 = 1042.50334672021 which is the INTERCEPT value. This value matches the value in cell C17.
6. Example 3
Estimate the fixed cost component based on the following production data? Output (units): 1000, 1200, 1400, 1600, 1800 Total Cost ($): 19600, 22450, 25130, 25340, 29670
The image above shows the data in cell range B23:C27, the x y scatter chart above shows the data points. The formula in cell E3 calculates the intercept value based on the x and y values in B23:C27.
Formula in cell E3:
INTERCEPT function = ȳ - bx̄
The intercept value is where the regression line intersects the y-axis. The regression line is calculated using the INTERCEPT and SLOPE function, the black line shown in the chart above represents the regression line.
SLOPE function: Σ((x-x̄)(y-ȳ))/ Σ(x-x̄)2
x̄ = AVERAGE(B23:B27) equals 1400
ȳ = AVERAGE(C23:C27) equals 24438
Calculate x-x̄
1000-1400=-400
1200-1400=-200
1400-1400=0
1600-1400=200
1800-1400=400
Calculate y-ȳ
19600-24438=-4838
22450-24438=-1988
25130-24438=692
25340-24438=902
29670-24438=5232
Calculate (x-x̄)(y-ȳ)
-400*-4838=1935200
-200*-1988=397600
0*692=0
200*902=180400
400*5232=2092800
Calculate Σ((x-x̄)(y-ȳ))
1935200+397600+0+180400+2092800=4606000
Calculate Σ(x-x̄)2
-400^2=160000
-200^2=40000
0^2=0
200^2=40000
400^2=160000
160000+40000+0+40000+160000=400000
Calculate Σ((x-x̄)(y-ȳ))/ Σ(x-x̄)2
4606000/400000=11.515
Y-intercept (b): b = ymean - m * xmean
24438-11.515*1400 = 8317
This value matches the calculated value in cell C17.
7. Function not working
Text, logical values, and empty cells within array or reference arguments are ignored. However, zero values are included in calculations.
The INTERCEPT function returns
- #N/A! error if there are a different number of values in known_y's and known_x's.
INTERCEPT/SLOPE vs LINEST handle undefined or collinear data differently. When all y-values are 0 (zero) and all x-values are 1:
- INTERCEPT and SLOPE functions return #DIV/0! because:
- These functions are designed to find a single, unique solution.
- When data is collinear, multiple solutions are possible.
- Thus, they cannot determine a single answer.
- LINEST function returns 0 (zero) because:
- It's designed to handle collinear data more flexibly.
- When multiple solutions exist, it provides a mathematically valid solution.
- It aims to give useful results even with imperfect data.
Collinearity means data points that lie on a straight line. In statistics, when points are collinear, it can be difficult to determine a unique relationship between variables because multiple solutions could fit the data equally well.
7.1 Troubleshooting the error value
When you encounter an error value in a cell a warning symbol appears, displayed in the image above. Press with mouse on it to see a pop-up menu that lets you get more information about the error.
- The first line describes the error if you press with left mouse button on it.
- The second line opens a pane that explains the error in greater detail.
- The third line takes you to the "Evaluate Formula" tool, a dialog box appears allowing you to examine the formula in greater detail.
- This line lets you ignore the error value meaning the warning icon disappears, however, the error is still in the cell.
- The fifth line lets you edit the formula in the Formula bar.
- The sixth line opens the Excel settings so you can adjust the Error Checking Options.
Here are a few of the most common Excel errors you may encounter.
#NULL error - This error occurs most often if you by mistake use a space character in a formula where it shouldn't be. Excel interprets a space character as an intersection operator. If the ranges don't intersect an #NULL error is returned. The #NULL! error occurs when a formula attempts to calculate the intersection of two ranges that do not actually intersect. This can happen when the wrong range operator is used in the formula, or when the intersection operator (represented by a space character) is used between two ranges that do not overlap. To fix this error double check that the ranges referenced in the formula that use the intersection operator actually have cells in common.
#SPILL error - The #SPILL! error occurs only in version Excel 365 and is caused by a dynamic array being to large, meaning there are cells below and/or to the right that are not empty. This prevents the dynamic array formula expanding into new empty cells.
#DIV/0 error - This error happens if you try to divide a number by 0 (zero) or a value that equates to zero which is not possible mathematically.
#VALUE error - The #VALUE error occurs when a formula has a value that is of the wrong data type. Such as text where a number is expected or when dates are evaluated as text.
#REF error - The #REF error happens when a cell reference is invalid. This can happen if a cell is deleted that is referenced by a formula.
#NAME error - The #NAME error happens if you misspelled a function or a named range.
#NUM error - The #NUM error shows up when you try to use invalid numeric values in formulas, like square root of a negative number.
#N/A error - The #N/A error happens when a value is not available for a formula or found in a given cell range, for example in the VLOOKUP or MATCH functions.
#GETTING_DATA error - The #GETTING_DATA error shows while external sources are loading, this can indicate a delay in fetching the data or that the external source is unavailable right now.
7.2 The formula returns an unexpected value
To understand why a formula returns an unexpected value we need to examine the calculations steps in detail. Luckily, Excel has a tool that Here is how to troubleshoot a formula:
- Select the cell containing the formula you want to examine in detail.
- Go to tab “Formulas” on the ribbon.
- Press with left mouse button on "Evaluate Formula" button. A dialog box appears.
The formula appears in a white field inside the dialog box. Underlined expressions are calculations being processed in the next step. The italicized expression is the most recent result. The buttons at the bottom of the dialog box allows you to evaluate the formula in smaller calculations which you control. - Press with left mouse button on the "Evaluate" button located at the bottom of the dialog box to process the underlined expression.
- Repeat pressing the "Evaluate" button until you have seen all calculations step by step. This allows you to examine the formula in greater detail and hopefully find the culprit.
- Press "Close" button to dismiss the dialog box.
There is also another way to debug formulas using the function key F9. F9 is especially useful if you have a feeling that a specific part of the formula is the issue, this makes it faster than the "Evaluate Formula" tool since you don't need to go through all calculations to find the issue..
- Enter Edit mode: Double-press with left mouse button on the cell or press F2 to enter Edit mode for the formula.
- Select part of the formula: Highlight the specific part of the formula you want to evaluate. You can select and evaluate any part of the formula that could work as a standalone formula.
- Press F9: This will calculate and display the result of just that selected portion.
- Evaluate step-by-step: You can select and evaluate different parts of the formula to see intermediate results.
- Check for errors: This allows you to pinpoint which part of a complex formula may be causing an error.
The image above shows cell reference C23:C27 and B23:B26 converted to hard-coded value using the F9 key. The number of values in the first array must match the number of values in the second array, this is not the case in this example. We have found what is wrong with the formula.
Tips!
- View actual values: Selecting a cell reference and pressing F9 will show the actual values in those cells.
- Exit safely: Press Esc to exit Edit mode without changing the formula. Don't press Enter, as that would replace the formula part with the calculated value.
- Full recalculation: Pressing F9 outside of Edit mode will recalculate all formulas in the workbook.
Remember to be careful not to accidentally overwrite parts of your formula when using F9. Always exit with Esc rather than Enter to preserve the original formula. However, if you make a mistake overwriting the formula it is not the end of the world. You can “undo” the action by pressing keyboard shortcut keys CTRL + z or pressing the “Undo” button
Other errors
Floating-point arithmetic may give inaccurate results in Excel - Article
Floating-point errors are usually very small, often beyond the 15th decimal place, and in most cases don't affect calculations significantly.
'INTERCEPT' function examples
The following article has a formula that contains the INTERCEPT function.
Have you ever tried to build a formula to calculate discounts based on price? The VLOOKUP function is much easier […]
'INTERCEPT' function examples
This post explains how to lookup a value and return multiple values. No array formula required.
This article explains different techniques that filter rows/records that contain a given text string in any of the cell values […]
This article demonstrates how to extract records/rows based on two conditions applied to two different columns, you can easily extend […]
Functions in 'Statistical' category
The INTERCEPT function function is one of 73 functions in the 'Statistical' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form