Math::LOESS - Perl wrapper of the Locally-Weighted Regression package originally written by Cleveland, et al.
version 0.001000
use Math::LOESS; my $loess = Math::LOESS->new(x => $x, y => $y); $loess->fit(); my $fitted_values = $loess->outputs->fitted_values; print $loess->summary(); my $prediction = $loess->predict($new_data, 1); my $confidence_intervals = $prediction->confidence(0.05); print $confidence_internals->{fit}; print $confidence_internals->{upper}; print $confidence_internals->{lower};
new((Piddle1D|Piddle2D) :$x, Piddle1D :$y, Piddle1D :$weights=undef, Num :$span=0.75, Str :$family='gaussian')
Arguments:
$x
A ($n, $p) piddle for x data, where $p is number of predictors. It's possible to have at most 8 predictors.
($n, $p)
$p
$y
A ($n, 1) piddle for y data.
($n, 1)
$weights
Optional ($n, 1) piddle for weights to be given to individual observations. By default, an unweighted fit is carried out (all the weights are one).
$span
The parameter controls the degree of smoothing. Default is 0.75.
For span < 1, the neighbourhood used for the fit includes proportion span of the points, and these have tricubic weighting (proportional to (1 - (dist/maxdist)^3)^3). For span > 1, all points are used, with the "maximum distance" assumed to be span^(1/p) times the actual maximum distance for p explanatory variables.
span
(1 - (dist/maxdist)^3)^3)
span^(1/p)
When provided as a construction parameter, it is like a shortcut for,
$loess->model->span($span);
$family
If "gaussian" fitting is by least-squares, and if "symmetric" a re-descending M estimator is used with Tukey's biweight function.
"gaussian"
"symmetric"
$loess->model->family($family);
Bad values in $x, $y, $weights are removed.
Get an Math::LOESS::Model object.
Get an Math::LOESS::Outputs object.
Get input x data as a piddle.
Get input y data as a piddle.
Get input weights data as a piddle.
Returns a true value if the object's fit() method has been called.
fit()
predict((Piddle1D|Piddle2D) $newdata, Bool $stderr=false)
Returns a Math::LOESS::Prediction object.
Bad values in $newdata are removed.
$newdata
summary()
Returns a summary string. For example,
print $loess->summary();
https://en.wikipedia.org/wiki/Local_regression
PDL
Stephan Loyd <sloyd@cpan.org>
This software is copyright (c) 2019-2023 by Stephan Loyd.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Math::LOESS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::LOESS
CPAN shell
perl -MCPAN -e shell install Math::LOESS
For more information on module installation, please visit the detailed CPAN module installation guide.