Time Series Smoothing (Spatial Statistics)

Summary

Smooths a numeric variable of one or more time series using centered, forward, and backward moving averages, as well as an adaptive method based on local linear regression. After smoothing short-term fluctuations, longer-term trends or cycles often become apparent.

Learn more about how Time Series Smoothing works

Illustration

Time Series Smoothing tool illustration
Smooth the values of a time series.

Usage

  • You can append the smoothed value fields to the input features or table using the Append Fields To Input Data parameter. If you append the fields to the input, the output coordinate system environment will be ignored. If the input features or table have joined fields, you cannot append to the input data and must create a new output.

  • The Time Field parameter specifies the time of each input record. There cannot be more than one value at the same time in the same time series.

  • The Analysis Field parameter specifies the values that will be smoothed. When smoothing a value of the analysis field, only nonnull values within the time window are used. If all values of the analysis field are null within a time window, the smoothed value will be null.

  • Multiple time series can be specified using the Grouping Method parameter. You can group all values at the same location into the same time series, group values using an ID field, or group all values (regardless of location) into the same time series. If you group values, ensure that all groups have multiple records with different times so that smoothing can be performed within each group.

  • Due to leap years and differing days of the month, if the Time Window parameter unit is years or months, the time value must be an integer. For example 1.5 months results in a different time window depending on the month. For forward and backward moving averages, the time window can be any positive integer. For centered moving averages and adaptive bandwidth local linear regression, the time window must be a positive even integer so that when it is split on each side of the record being smoothed, each side results in a positive integer.

  • When the Enable time series pop-ups parameter is checked, the tool will create a chart for each time series and add the chart to the first feature record in each time series. On a 2D map, select a feature to view the chart in the pop-up. In a 3D scene, select the first feature in the time series to view the chart in the pop-up.

    Note:

    If a grouping method is used, the first feature from each time series may not draw first in the map. To access the pop-ups for these features, right-click the record in the attribute table.

Parameters

LabelExplanationData Type
Input Features or Table

The features or table containing the time series data and the field to smooth.

Feature Layer; Table View
Time Field

The field containing the time of each record.

Field
Analysis Field

The field containing the values that will be smoothed.

Field
Grouping Method
(Optional)

Specifies the method that will be used to group records into different time series. Smoothing is performed independently for each time series.

  • By locationFeatures at the same location will be grouped in the same time series. This is the default.
  • By ID fieldRecords with the same value of the ID field will be grouped in the same time series.
  • NoneAll records will be in the same time series.
String
Smoothing Method
(Optional)

Specifies the smoothing method that will be used.

  • Backward moving averageThe smoothed value is the average of the record and the values within the time window before it. This is the default.
  • Centered moving averageThe smoothed value is the average of the record and the values before and after it. Half of the time window is used before the time of the record, and half is used after.
  • Forward moving averageThe smoothed value is the average of the record and the values within the time window after it.
  • Adaptive bandwidth local linear regressionThe smoothed value is the result of a local linear regression centered at the record. The size of the time window is optimized for each record.
String
Time Window
(Optional)

The length of the time window. The value can be provided in seconds, minutes, hours, days, weeks, months, or years. For backward, forward, and centered moving averages, the value and unit must be provided. For adaptive bandwidth local linear regression, the value can be left empty and a time window will be estimated independently for each value. Values that fall on the border of the time window will be included within the window. For example, if you have daily data and you use a backward moving average with a time window of four days, five values will be included in the window when smoothing a record: the value of the record and the values of the four previous days.

Time Unit
Append fields to input data
(Optional)

Specifies whether output fields will be appended to the input dataset or saved as a new output table or feature class. If you append the fields to the input, the output coordinate system environment will be ignored.

  • Checked—The output fields will be appended to the input features. This option modifies the input data.
  • Unchecked—The output fields will not be appended to the input. An output table or a feature class will be created containing the output fields. This is the default.

Boolean
Output Features
(Optional)

The output features containing the smoothed values as well as fields for the time window and number of neighbors.

Feature Class; Table
ID Field
(Optional)

The integer or text field containing a unique ID for each time series. All records with the same value of this field are part of the same time series.

Field
Apply shorter time window at start and end
(Optional)

Specifies whether the time window will be shortened at the start and end of each time series.

  • Checked—The time window will be shortened at the start and end of the time series so that the time window does not extend before the start or after the end of the time series.
  • Unchecked—The time window will not be shortened. If the time window extends before the start or after the end of the time series, the smoothed value will be null. This is the default.

Boolean
Enable time series pop-ups
(Optional)

Specifies whether the output features or table will include pop-up charts showing the original and smoothed values of the time series.

  • Checked—The output will include pop-up charts. This is the default.
  • Unchecked—The output will not include pop-up charts.

Boolean

Derived Output

LabelExplanationData Type
Updated Features or Table

The updated input table or feature class with the output fields appended.

Feature Class, Table

arcpy.stats.TimeSeriesSmoothing(in_features, time_field, analysis_field, {group_method}, {method}, {time_window}, {append_to_input}, {output_features}, {id_field}, {apply_shorter_window}, {enable_time_series_popups})
NameExplanationData Type
in_features

The features or table containing the time series data and the field to smooth.

Feature Layer; Table View
time_field

The field containing the time of each record.

Field
analysis_field

The field containing the values that will be smoothed.

Field
group_method
(Optional)

Specifies the method that will be used to group records into different time series. Smoothing is performed independently for each time series.

  • LOCATIONFeatures at the same location will be grouped in the same time series. This is the default.
  • ID_FIELDRecords with the same value of the ID field will be grouped in the same time series.
  • NONEAll records will be in the same time series.
String
method
(Optional)

Specifies the smoothing method that will be used.

  • BACKWARDThe smoothed value is the average of the record and the values within the time window before it. This is the default.
  • CENTEREDThe smoothed value is the average of the record and the values before and after it. Half of the time window is used before the time of the record, and half is used after.
  • FORWARDThe smoothed value is the average of the record and the values within the time window after it.
  • ADAPTIVEThe smoothed value is the result of a local linear regression centered at the record. The size of the time window is optimized for each record.
String
time_window
(Optional)

The length of the time window. The value can be provided in seconds, minutes, hours, days, weeks, months, or years. For backward, forward, and centered moving averages, the value and unit must be provided. For adaptive bandwidth local linear regression, the value can be left empty and a time window will be estimated independently for each value. Values that fall on the border of the time window will be included within the window. For example, if you have daily data and you use a backward moving average with a time window of four days, five values will be included in the window when smoothing a record: the value of the record and the values of the four previous days.

Time Unit
append_to_input
(Optional)

Specifies whether the output fields will be appended to the input dataset or saved as a new output table or feature class. If you append the fields to the input, the output coordinate system environment will be ignored.

  • APPEND_TO_INPUTThe output fields will be appended to the input features. This option modifies the input data.
  • NEW_OUTPUTThe output fields will not be appended to the input. An output table or a feature class will be created containing the output fields. This is the default.
Boolean
output_features
(Optional)

The output features containing the smoothed values as well as fields for the time window and number of neighbors.

Feature Class; Table
id_field
(Optional)

The integer or text field containing a unique ID for each time series. All records with the same value of this field are part of the same time series.

Field
apply_shorter_window
(Optional)

Specifies whether the time window will be shortened at the beginning and end of each time series.

  • APPLY_SHORTER_WINDOWThe time window will be shortened at the start and end of the time series so that the time window does not extend before the start or after the end of the time series.
  • NOT_APPLY_SHORTER_WINDOWThe time window will not be shortened. If the time window extends before the start or after the end of the time series, the smoothed value will be null. This is the default.
Boolean
enable_time_series_popups
(Optional)

Specifies whether the output features or table will include pop-up charts showing the original and smoothed values of the time series.

  • CREATE_POPUPThe output will include pop-up charts. This is the default.
  • NO_POPUPThe output will not include pop-up charts.
Boolean

Derived Output

NameExplanationData Type
updated_features

The updated input table or feature class with the output fields appended.

Feature Class, Table

Code sample

TimeSeriesSmoothing example 1 (Python window)

The following Python script demonstrates how to use the TimeSeriesSmoothing function.

import arcpy
arcpy.stats.TimeSeriesSmoothing("temperature_CA", "START_DATE", "VALUE", 
            "LOCATION", "BACKWARD", "1 Months", "NEW_OUTPUT", "temperature_smoothed", 
            None, "NOT_APPLY_SHORTER_WINDOW", "CREATE_POPUP")
TimeSeriesSmoothing example 2 (stand-alone script)

The following Python script demonstrates how to use the TimeSeriesSmoothing function to forecast population.

import arcpy
arcpy.env.workspace = "C:/Analysis/data.gdb"

# Smooth temperature data using adaptive method by ID Field and revise input 
arcpy.stats.TimeSeriesSmoothing("temperature_CA", "START_DATE", "VALUE", 
            "ID_FIELD", "ADAPTIVE", None, "APPEND_TO_INPUT", None, "FIPS", 
            "NOT_APPLY_SHORTER_WINDOW", "NO_POPUP")