---
url: https://jer-k.github.io/effect-prophet/examples/flat-trend.md
description: >-
  Flat growth for data that moves around a steady level, with seasonality,
  events and regressors.
---

# Flat trends

If your data moves around a steady level, with no long-term growth or decline, use
`growth: "flat"`. The trend becomes a single constant, and all the movement comes from seasonal
patterns, events and regressors.

```ts
import { Effect } from "effect";
import { fit, predict, prophetFittingBackendLayer } from "effect-prophet";

const date = (day: number) => new Date(Date.UTC(2025, 0, 1 + day)).toISOString();

// Daily support tickets: a steady level with a weekly pattern, no long-term growth.
const history = Array.from({ length: 84 }, (_, day) => ({
  timestamp: date(day),
  value: 40 + 12 * Math.sin((2 * Math.PI * day) / 7) + 2 * Math.sin(day * 12.9898),
}));

const forecast = await Effect.runPromise(
  Effect.gen(function* () {
    const model = yield* fit(history, { growth: "flat" });

    return yield* predict(model, [date(84), date(85), date(86)]);
  }).pipe(Effect.provide(prophetFittingBackendLayer)),
);

console.log(forecast.map((row) => `${row.value.toFixed(1)} (trend ${row.trend.toFixed(1)})`));

```

```txt [Output]
[ '40.1 (trend 40.1)', '49.5 (trend 40.1)', '51.8 (trend 40.1)' ]
```

::: tip Verified against Python Prophet
Flat trends match Python Prophet 1.4.0. The [flat growth benchmarks](/benchmarks/flat) show every
case side by side.
:::

## When to use it

* The data has no real trend, and you don't want the model to invent one from a few unusual
  weeks.
* You are forecasting far ahead and would rather assume "same as now" than extend a slope.

## Changepoint settings

`map.changepoints` and `map.changepointPriorScale` work with `growth: "flat"`, as they do in
Python. They never bend a flat trend. Prophet still fits a slope and one adjustment per
changepoint alongside the level, held in place only by their priors, so these settings decide how
many of those values there are and how tightly they are held. In exact arithmetic that leaves the
fitted level and effects unchanged. In practice it changes the path the fit takes, so forecasts
can differ in the last digits, and fewer changepoints make each fitting step cheaper. Pass the
values you would pass Python to get the same fit.
