Skip to contents

Add RegressionTransform to a vega-lite spec.

Usage

vl_regression(
  spec,
  regression = NULL,
  on = NULL,
  as = NULL,
  extent = NULL,
  groupby = NULL,
  method = NULL,
  order = NULL,
  params = NULL,
  .object = NULL
)

Arguments

spec

An input vega-lite spec

regression

The data field of the dependent variable to predict.

on

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

as

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

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

extent

A [min, max] domain over the independent (x) field for the starting and ending points of the generated trend line.

groupby

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

method

The functional form of the regression model. One of "linear", "log", "exp", "pow", "quad", or "poly".

Default value: "linear"

order

The polynomial order (number of coefficients) for the 'poly' method.

Default value: 3

params

A boolean flag indicating if the transform should return the regression model parameters (one object per group), rather than trend line points. The resulting objects include a coef array of fitted coefficient values (starting with the intercept term and then including terms of increasing order) and an rSquared value (indicating the total variance explained by the model).

Default value: false

.object

Directly input an object, rather than creating one via the other arguments. Should not be used in conjunction with the other arguments other than spec. Objects can be of type: RegressionTransform

Value

A modified Vega-Lite Spec