in reply to Correlation plots
If you prefer a simple specialised module over full-blown solutions like PDL or Statistics::R, you could use Statistics::LineFit (which is 27k pure Perl, without any external dependencies).
Here's a simple example, which computes intercept, slope and R2 for one data set (100 x/y data points):
use Statistics::LineFit; my $x = [ 1..100 ]; my $y = [ map $_*2, 11..110 ]; my $lfit = Statistics::LineFit->new(); $lfit->setData($x, $y); printf "a=%.4f, b=%.4f, R2=%.4f\n", $lfit->coefficients(), $lfit->rSq +uared(); # which outputs: a=20.0000, b=2.0000, R2=1.0000
( Looking at the input data, it's not too surprising that the R2 is exactly 1.0 )
The module also allows to compute a number of related values, like residuals, standard error, etc. - in case you should need them.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |