How to Use LINEST in Excel
LINEST is Excel's built-in function for performing linear regression analysis. While most Excel users reach for trendlines on charts or the Analysis ToolPak, LINEST provides a formula-based approach...
Key Insights
- LINEST performs linear regression analysis in Excel and returns an array of statistics including slope, intercept, R-squared, and standard errors—all in a single formula without needing the Analysis ToolPak
- The function accepts up to four parameters, with the most powerful being the stats parameter that outputs a complete 5-row statistical summary for comprehensive regression analysis
- For multiple regression models, LINEST handles multiple independent variables simultaneously by selecting adjacent columns as the known_x’s range, returning coefficients in reverse order from right to left
Introduction to LINEST
LINEST is Excel’s built-in function for performing linear regression analysis. While most Excel users reach for trendlines on charts or the Analysis ToolPak, LINEST provides a formula-based approach that calculates the best-fit straight line through your data using the least squares method.
The function returns an array of statistical values that describe the linear relationship between your dependent variable (y) and one or more independent variables (x). This makes it invaluable for forecasting, trend analysis, and building predictive models directly within your spreadsheet.
Use LINEST when you need to quantify relationships between variables, make predictions based on historical data, or understand how multiple factors influence an outcome. Unlike chart trendlines that only show visual results, LINEST gives you the actual statistical values you can use in other formulas.
Understanding LINEST Syntax and Parameters
The LINEST function follows this syntax:
=LINEST(known_y's, [known_x's], [const], [stats])
known_y’s (required): Your dependent variable data—the values you’re trying to predict or explain. This should be a single column or row of numeric values.
known_x’s (optional): Your independent variable(s)—the data you’re using to make predictions. Can be one or more adjacent columns or rows. If omitted, Excel assumes an array of {1,2,3,…} matching the size of known_y’s.
const (optional): A logical value specifying whether to force the intercept to zero. Use TRUE or omit for normal calculation (intercept calculated). Use FALSE to force the line through the origin (intercept = 0).
stats (optional): Determines output detail. Use FALSE or omit to return only slope and intercept. Use TRUE to get comprehensive statistics including R-squared, standard errors, and F-statistic.
Here’s a basic structure:
=LINEST(B2:B11, A2:A11, TRUE, FALSE)
This formula analyzes the relationship between values in column A (x) and column B (y), calculates the intercept normally, and returns only slope and intercept values.
Simple Linear Regression with LINEST
Let’s work through a practical example: analyzing how advertising spend affects sales.
Suppose you have monthly advertising spend in column A and corresponding sales in column B:
A (Ad Spend) | B (Sales)
$1,000 | $15,000
$1,500 | $18,000
$2,000 | $22,000
$2,500 | $25,000
$3,000 | $28,000
To perform simple linear regression:
- Select two adjacent cells horizontally (e.g., D2:E2)
- Enter the formula:
=LINEST(B2:B6, A2:A6) - Press Ctrl+Shift+Enter (in Excel 2019 and earlier) to enter as an array formula, or just Enter in Excel 365
The result displays two values:
- First cell (D2): Slope (approximately 5.2)
- Second cell (E2): Intercept (approximately 9,800)
This tells you that for every $1 increase in advertising spend, sales increase by $5.20, and if you spent $0 on advertising, you’d expect about $9,800 in baseline sales.
To use these values for predictions:
=E2 + D2*A2
This formula calculates predicted sales based on the advertising spend in A2.
Multiple Linear Regression
LINEST’s real power emerges with multiple independent variables. Suppose sales depend on advertising spend, product price, and a seasonal factor:
A (Ad Spend) | B (Price) | C (Season) | D (Sales)
$2,000 | $50 | 1 | $22,000
$2,500 | $48 | 1 | $26,000
$3,000 | $45 | 2 | $32,000
$1,500 | $52 | 0 | $18,000
$2,200 | $49 | 1 | $24,000
To analyze this multi-variable relationship:
- Select a horizontal range of four cells (one more than the number of x variables)
- Enter:
=LINEST(D2:D6, A2:C6) - Press Ctrl+Shift+Enter (or Enter in Excel 365)
The output appears in reverse order:
[Season Coef] [Price Coef] [Ad Spend Coef] [Intercept]
2,400 -800 6.5 50,000
This means:
- Each $1 in ad spend increases sales by $6.50
- Each $1 price increase decreases sales by $800
- Each seasonal unit increases sales by $2,400
- Base sales (all factors at zero) would be $50,000
To make predictions with multiple regression:
=E2 + D2*A2 + C2*B2 + B2*C2
Where E2 contains the intercept, and D2:B2 contain the coefficients in reverse order.
Interpreting Statistical Output
Setting the stats parameter to TRUE unlocks comprehensive regression statistics. Select a range of 5 rows by (number of x variables + 1) columns:
=LINEST(D2:D6, A2:C6, TRUE, TRUE)
For our three-variable example, select a 5×4 range and enter the formula. The output structure:
Row 1: [m3] [m2] [m1] [b] - Regression coefficients
Row 2: [se3] [se2] [se1] [seb] - Standard errors
Row 3: [r²] [sey] - R-squared, standard error of y
Row 4: [F] [df] - F-statistic, degrees of freedom
Row 5: [ssreg] [ssresid] - Regression/residual sum of squares
R-squared (row 3, first cell): Indicates model fit. Values closer to 1 mean your independent variables explain more variance in the dependent variable. An R² of 0.85 means your model explains 85% of sales variation.
Standard errors (row 2): Measure coefficient reliability. Smaller values relative to coefficients indicate more reliable estimates.
F-statistic (row 4, first cell): Tests overall model significance. Higher values (typically >4) suggest your model is statistically meaningful.
To extract specific statistics using INDEX:
=INDEX(LINEST(D2:D6, A2:C6, TRUE, TRUE), 3, 1) // Returns R-squared
=INDEX(LINEST(D2:D6, A2:C6, TRUE, TRUE), 1, 4) // Returns intercept
Practical Applications and Use Cases
Sales Forecasting Model
Build a dynamic forecasting model that updates automatically:
// Named range for historical data
Sales_Data: B2:B25
Marketing_Spend: A2:A25
// Forecast formula in C26
=INDEX(LINEST(Sales_Data, Marketing_Spend, TRUE, FALSE), 1, 2) +
INDEX(LINEST(Sales_Data, Marketing_Spend, TRUE, FALSE), 1, 1) * A26
This formula uses INDEX to extract slope and intercept from LINEST, then calculates the forecast for the marketing spend value in A26.
Confidence Assessment
Determine if your regression is reliable:
// Calculate R-squared
=INDEX(LINEST(B2:B25, A2:A25, TRUE, TRUE), 3, 1)
// Display warning if R² < 0.7
=IF(INDEX(LINEST(B2:B25, A2:A25, TRUE, TRUE), 3, 1) < 0.7,
"Low confidence - use with caution",
"Good model fit")
Deseasonalized Trend Analysis
Use LINEST to identify underlying trends after removing seasonal effects:
// Assuming seasonal adjustment in column C
=LINEST(B2:B25/C2:C25, A2:A25, TRUE, TRUE)
Common Pitfalls and Best Practices
Array Formula Errors
In Excel 2019 and earlier, forgetting Ctrl+Shift+Enter causes #VALUE! errors:
// Wrong - entered with just Enter (pre-Excel 365)
=LINEST(B2:B10, A2:A10) // Shows only first value or error
// Correct - entered with Ctrl+Shift+Enter
{=LINEST(B2:B10, A2:A10)} // Shows full array (note curly braces)
Excel 365 handles this automatically with dynamic arrays.
Misaligned Data Ranges
LINEST requires equal-sized ranges:
// Wrong - mismatched ranges
=LINEST(B2:B10, A2:A9) // #REF! error
// Correct - matching ranges
=LINEST(B2:B10, A2:A10)
Multiple X Variables Selection
For multiple regression, x variables must be adjacent columns:
// Wrong - non-adjacent columns
=LINEST(D2:D10, A2:A10, C2:C10) // Error
// Correct - adjacent columns
=LINEST(D2:D10, A2:C10) // Analyzes columns A, B, and C together
Data Quality Issues
LINEST fails with text, blanks, or error values. Clean your data first:
// Use IFERROR to handle missing data
=LINEST(IFERROR(B2:B10, ""), IFERROR(A2:A10, ""))
When to Use Alternatives
- Use TREND for simple predictions without needing statistics
- Use FORECAST.LINEAR (or FORECAST) for single-point forecasts
- Use Analysis ToolPak regression for detailed reports and residual analysis
- Consider LOGEST for exponential relationships instead of linear
LINEST excels when you need regression coefficients embedded in formulas that update dynamically. For one-time analysis with extensive diagnostics, the Analysis ToolPak provides better documentation. For simple forecasting without statistical rigor, FORECAST.LINEAR offers simpler syntax.
The key is understanding your data relationships and choosing the tool that matches your analytical needs and workflow requirements.