holtWinters() function
The holtWinters()
function applies the Holt-Winters forecasting method to input tables.
Function type: Transformation
Output data type: Float
holtWinters(
n: 10,
seasonality: 4,
interval: 30d,
withFit: false,
timeColumn: "_time",
column: "_value",
)
The Holt-Winters method predicts n
seasonally-adjusted values for the
specified column
at the specified interval
.
For example, if interval
is six minutes (6m
) and n
is 3
, results include three predicted
values six minutes apart.
Seasonality
seasonality
delimits the length of a seasonal pattern according to interval
.
If your interval
is two minutes (2m
) and seasonality
is 4
, then the seasonal pattern occurs every eight minutes or every four data points. Likewise, if your interval
is two months (2mo
) and seasonality
is 4
, then the seasonal pattern occurs every eight months or every four data points.
If data doesn’t have a seasonal pattern, set seasonality
to 0
.
Space values evenly in time
holtWinters()
expects values evenly spaced in time.
To ensure holtWinters()
values are spaced evenly in time, the following rules apply:
- Data is grouped into time-based “buckets” determined by the
interval
. - If a bucket includes many values, the first value is used.
- If a bucket includes no values, a missing value (
null
) is added for that bucket.
By default, holtWinters()
uses the first value in each time bucket to run the Holt-Winters calculation.
To specify other values to use in the calculation, use:
Fitted model
The holtWinters()
function applies the Nelder-Mead optimization
to include “fitted” data points in results when withFit
is set to true
.
Null timestamps
holtWinters()
discards rows with null
timestamps before running the Holt-Winters calculation.
Null values
holtWinters()
treats null
values as missing data points and includes them in the Holt-Winters calculation.
Parameters
n
The number of values to predict.
Data type: Integer
seasonality
The number of points in a season.
Defaults to 0
.
Data type: Integer
interval
The interval between two data points.
Data type: Duration
withFit
Return fitted data in results.
Defaults to false
.
Data type: Boolean
timeColumn
The time column to use.
Defaults to "_time"
.
Data type: String
column
The column to operate on.
Defaults to "_value"
.
Data type: String
Examples
Use aggregateWindow to prepare data for holtWinters
from(bucket: "example-bucket")
|> range(start: -7y)
|> filter(fn: (r) => r._field == "water_level")
|> aggregateWindow(every: 379m, fn: first).
|> holtWinters(n: 10, seasonality: 4, interval: 379m)
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, the following resources are available:
InfluxDB Cloud and InfluxDB Enterprise customers can contact InfluxData Support.