> ## Documentation Index
> Fetch the complete documentation index at: https://docs.macrobymark.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Forecasting

> Run statistical forecasts on macroeconomic indicators.

# Forecasting

The forecasting engine lets you run time-series models on any registered
indicator directly through the API.

## Available models

| Model        | Family       | Best for                                                    |
| ------------ | ------------ | ----------------------------------------------------------- |
| ARIMA        | Classical    | Univariate series with trend and seasonality                |
| ETS          | Classical    | Exponential smoothing with error/trend/season decomposition |
| VAR          | Multivariate | Joint forecasting of related series                         |
| Holt-Winters | Classical    | Strong seasonal patterns                                    |

## Running a forecast

```bash theme={null}
curl -X POST https://macrobymark.com/api/forecast/run \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "slug": "us-cpi-all-items",
    "model": "arima",
    "horizon": 12,
    "vintage": { "mode": "latest" }
  }'
```

The response includes point forecasts, confidence bands, model diagnostics,
and a cache key you can use to export results.

## Vintage-aware forecasting

You can run forecasts against historical data vintages to backtest how a
model would have performed in real time:

```bash theme={null}
curl -X POST https://macrobymark.com/api/forecast/run \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "slug": "us-cpi-all-items",
    "model": "arima",
    "horizon": 6,
    "vintage": { "mode": "specific", "date": "2024-01-15" }
  }'
```

FRED series support native vintage retrieval. BLS and BEA use simulated
vintages derived from revision history. Other providers fall back to the
current snapshot with a disclaimer in the audit metadata.

## Exporting results

Use the cache key from the forecast response to download results:

```bash theme={null}
# CSV
curl -G "https://macrobymark.com/api/forecast/run/{cacheKey}/csv" \
  -H "X-API-Key: YOUR_KEY"

# JSON
curl -G "https://macrobymark.com/api/forecast/run/{cacheKey}/json" \
  -H "X-API-Key: YOUR_KEY"
```
