#!/usr/bin/perl
#
# dbcolsregression.pm
# Copyright (C) 1997-2022 by John Heidemann <johnh@isi.edu>
#
# This program is distributed under terms of the GNU general
# public license, version 2. See the file COPYING
# in $dblibdir for details.
#
=head1 NAME
dbcolsregression - compute linear regression between two columns
=head1 SYNOPSIS
dbcolsregression [-a] column1 column2
=head1 DESCRIPTION
Compute linear regression over C<column1> and C<column2>.
Outputs slope, intercept, and correlation coefficient.
=head1 OPTIONS
=over 4
=item B<-a> or B<--include-non-numeric>
Compute stats over all records (treat non-numeric records
as zero rather than just ignoring them).
=item B<-f FORMAT> or B<--format FORMAT>
Specify a L<printf(3)>-style format for output statistics.
Defaults to C<%.5g>.
=back
=for comment
begin_standard_fsdb_options
This module also supports the standard fsdb options:
=over 4
=item B<-d>
Enable debugging output.
=item B<-i> or B<--input> InputSource
Read from InputSource, typically a file name, or C<-> for standard input,
or (if in Perl) a IO::Handle, Fsdb::IO or Fsdb::BoundedQueue objects.
=item B<-o> or B<--output> OutputDestination
Write to OutputDestination, typically a file name, or C<-> for standard output,
or (if in Perl) a IO::Handle, Fsdb::IO or Fsdb::BoundedQueue objects.
=item B<--autorun> or B<--noautorun>
By default, programs process automatically,
but Fsdb::Filter objects in Perl do not run until you invoke
the run() method.
The C<--(no)autorun> option controls that behavior within Perl.
=item B<--help>
Show help.
=item B<--man>
Show full manual.
=back
=for comment
end_standard_fsdb_options
=head1 SAMPLE USAGE
=head2 Input:
#fsdb x y
160 126
180 103
200 82
220 75
240 82
260 40
280 20
=head2 Command:
cat DATA/xy.fsdb | dbcolsregression x y | dblistize
=head2 Output:
#fsdb -R C slope:d intercept:d confcoeff:d n:q
slope: -0.79286
intercept: 249.86
confcoeff: -0.95426
n: 7
# | dbcolsregression x y
# confidence intervals assume normal distribution and small n.
# | dblistize
Sample data from
L<http://people.hofstra.edu/faculty/Stefan_Waner/RealWorld/calctopic1/regression.html>
by Stefan Waner and Steven R. Costenoble.
=head1 SEE ALSO
L<dbcolstats>,
L<dbcolscorrelate>,
L<Fsdb>.
=cut
# WARNING: This code is derived from dbcolsregression.pm; that is the master copy.
use Fsdb::Filter::dbcolsregression;
my $f = new Fsdb::Filter::dbcolsregression(@ARGV);
$f->setup_run_finish; # or could just --autorun
exit 0;
=head1 AUTHOR and COPYRIGHT
Copyright (C) 1997-2022 by John Heidemann <johnh@isi.edu>
This program is distributed under terms of the GNU general
public license, version 2. See the file COPYING
with the distribution for details.
=cut
1;