This function performs loess regression. Loess regression is a local regression procedure, where a prediction of the dependent (y) variable is made from an observation of the independent (x) variable by weighted least squares over x values in the neighborhood of the value being evaluated.
In the future a separate function may be included to perform loess regression with multiple predictors. However, one predictor is the much more common case and the multiple predictor case will require a much different API and implementation, so for now only one predictor is supported.
Observations of the dependent variable.
Observations of the independent variable.
The fraction of x observations considered to be "in the neighborhood" when performing local regression to predict the y value for a new x. For example, if 8 observations are provided and span == 0.5, the 4 nearest neighbors will be used on evaluation.
The polynomial degree of the local regression. Must be less than the number of neighbors (span * x.length).
A Loess1D object. This object can be used to make predictions based on the loess model. The computations involved are done lazily, i.e. this function sets up the Loess1D instance and returns without computing any regression models.
1 auto x = [1, 2, 3, 4, 5, 6, 7]; 2 auto y = [3, 6, 2, 4, 3, 6, 8]; 3 4 // Build the Loess1D object. 5 auto model = loess1D(y, x, 0.5); 6 7 // Compute the weights for robust regression. 8 model.computeRobustWeights(2); 9 10 // Predict the value of y when x == 5.5, using a robustness level of 2. 11 auto prediction = model.predict(5.5, 2);
Cleveland, W.S. (1979). "Robust Locally Weighted Regression and Smoothing Scatterplots". Journal of the American Statistical Association 74 (368): 829-836.