# Linear Regression Trend Forecast Calculator

> Source: https://netray.co/tools/linear-regression-trend-forecast-calculator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Enter six periods of demand and get the least squares trend, how well it fits and the forecast for the period you choose.

## Category

supply-chain

## Audience

- Demand planner
- Supply planner
- Financial planner

## Tool

**Kind:** calculator

**Inputs:**

#### Demand period 1 (oldest)

**Key:** y1

**Type:** number

**Default:** 410

**Min:** 0

**Step:** 5

#### Demand period 2

**Key:** y2

**Type:** number

**Default:** 435

**Min:** 0

**Step:** 5

#### Demand period 3

**Key:** y3

**Type:** number

**Default:** 428

**Min:** 0

**Step:** 5

#### Demand period 4

**Key:** y4

**Type:** number

**Default:** 462

**Min:** 0

**Step:** 5

#### Demand period 5

**Key:** y5

**Type:** number

**Default:** 480

**Min:** 0

**Step:** 5

#### Demand period 6 (latest)

**Key:** y6

**Type:** number

**Default:** 497

**Min:** 0

**Step:** 5

#### Periods ahead to forecast

**Key:** h

**Type:** slider

**Default:** 3

**Min:** 1

**Max:** 12

**Step:** 1

**Unit:** periods

**Outputs:**

#### Average demand

**Key:** ybar

**Expr:** (y1 + y2 + y3 + y4 + y5 + y6) / 6

**Format:** decimal

#### Trend slope per period

**Key:** slope

**Expr:** (-2.5 * y1 - 1.5 * y2 - 0.5 * y3 + 0.5 * y4 + 1.5 * y5 + 2.5 * y6) / 17.5

**Format:** decimal

**Primary:** true

#### Intercept at period 0

**Key:** icpt

**Expr:** ybar - slope * 3.5

**Format:** decimal

#### Total sum of squares

**Key:** sst

**Expr:** pow(y1 - ybar, 2) + pow(y2 - ybar, 2) + pow(y3 - ybar, 2) + pow(y4 - ybar, 2) + pow(y5 - ybar, 2) + pow(y6 - ybar, 2)

**Format:** decimal

#### R squared

**Key:** r2

**Expr:** slope * slope * 17.5 / sst

**Format:** decimal

**Description:** Share of variation explained by the line.

#### Forecast for chosen period

**Key:** fc

**Expr:** max(0, icpt + slope * (6 + h))

**Format:** integer

**Primary:** true

**Chart:**

#### Trend forecast by periods ahead

**Type:** line

**X:** h

**From:** 1

**To:** 12

**Steps:** 12

**Series:**

- fc

**Disclaimer:** A straight line extended far ahead can mislead. Check R squared, look for seasonality and use short horizons.

## Content

**Intro:** When demand drifts steadily up or down, a trend line is the simplest honest forecast. This calculator fits a least squares line to the last six periods and projects it forward, showing slope, intercept and R squared so you can judge whether the line deserves trust.

**Sections:**

#### How to use it

**Body:** Enter the six most recent periods of demand, oldest first, and choose how many periods ahead to forecast. The tool computes the slope, which is the average change per period, the intercept and R squared. The primary forecast is the line value at period six plus the number of periods ahead, floored at zero. Use the chart to see how the projection runs over the next twelve periods.

**Bullets:**

- Use consistent period lengths
- Remove one-off spikes first
- Adjust for seasonality before fitting
- Keep the horizon short

#### The method

**Body:** Ordinary least squares picks the line that minimises squared errors. With periods 1 to 6 the mean of x is 3.5 and the sum of squared deviations of x is 17.5. Slope equals the sum of (x minus 3.5) times y, divided by 17.5. Intercept equals the mean of y minus slope times 3.5. R squared is the explained sum of squares, slope squared times 17.5, divided by the total sum of squares of y.

#### Reading the example

**Body:** With the default data, average demand is 452 and the slope is about 17 units per period, so demand is rising roughly 3.7% per period. R squared is above 0.9, so most variation is explained by the line. Three periods ahead the forecast is about 538. If R squared were 0.3 the slope would be mostly noise and a flat average or exponential smoothing would be more sensible.

#### Common mistakes

**Body:** Fitting a line through seasonal data and calling the result a trend is the most frequent error. Six points are few, so a single outlier moves the slope. Extrapolating twelve periods from six is aggressive. Also, a trend that is true in units may be wrong after a lifecycle event such as a price change or a competitor entry, so combine it with sales knowledge.

**Cta:** Netray can run trend, seasonality and smoothing models on your ERP history side by side and show which fits each item best.

**Faq:**

#### What does R squared tell me here?

**Answer:** It is the share of the variation in demand explained by the straight line. Close to 1 means a strong linear trend. Low values mean the line adds little over a simple average.

#### How many periods should I use?

**Answer:** Six is a minimum for a quick check. For a stable estimate use 12 to 24 periods, and deseasonalise first if demand has a seasonal pattern.

#### Why is the forecast floored at zero?

**Answer:** A falling trend can project negative demand, which is impossible. The floor avoids that, but it is also a signal that the straight line no longer describes the item.

#### How does this differ from exponential smoothing?

**Answer:** Regression weights all six periods equally and assumes a constant slope. Holt style smoothing weights recent periods more and lets the slope change over time.

## Search terms

linear regression forecast calculator, trend line forecast, least squares demand forecast, linear trend forecasting excel, slope intercept demand, r squared forecast fit, trend projection method, forecast next period trend

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
