Loess

Edit this page

The loess transform (for locally-estimated scatterplot smoothing) uses locally-estimated regression to produce a trend line. Loess performs a sequence of local weighted regressions over a sliding window of nearest-neighbor points. For standard parametric regression options, see the regression transform.

// Any View Specification
{
  ...
  "transform": [
    {"loess": ...} // Loess Transform
     ...
  ],
  ...
}

Loess Transform Definition

Property Type Description
loess String

Required. The data field of the dependent variable to smooth.

on String

Required. The data field of the independent variable to use a predictor.

groupby String[]

The data fields to group by. If not specified, a single group containing all data objects will be used.

bandwidth Number

A bandwidth parameter in the range [0, 1] that determines the amount of smoothing.

Default value: 0.3

as String[]

The output field names for the smoothed points generated by the loess transform.

Default value: The field names of the input x and y values.

Usage

{"loess": "y", "on": "x", "bandwidth": 0.5}

Generate a loess trend line that models field "y" as a function of "x", using a bandwidth parameter of 0.5. The output data stream can then be visualized with a line mark, and takes the form:

[
  {"x": 1, "y": 2.3},
  {"x": 2, "y": 2.9},
  {"x": 3, "y": 2.7},
  ...
]

If the groupby parameter is provided, separate trend lines will be fit per-group, and the output records will additionally include all groupby field values.

Example