perl regression without intercept -


i trying achieve linear regression in perl using statistics::regression module without intercept. how can achieve regression model without having intercept? getting correct results intercept using following code:

#!/usr/bin/perl use strict; use warnings; use statistics::regression  @row=(); $reg=statistics::regression->new("sample regression",["const", "x"]);  open(my $f1, "<","ema_bid_44671_11536") or          die "cant open ema_bid_44671_11536";  while(my $line=<$f1>){     @row=split(",",$line);     chomp($row[2]);     chomp($row[1]);     $reg->include($row[2],[ 1.0, $row[1]]);  }  $reg->print(); close $f1; 

but when change 1.0 0.0 in last statement inside while loop ( include 0 constant) , code looks like:

#!/usr/bin/perl use strict; use warnings; use statistics::regression  @row=(); $reg=statistics::regression->new("sample regression",["const", "x"]);   open(my $f1, "<","ema_bid_44671_11536") or          die "cant open ema_bid_44671_11536";  while(my $line=<$f1>){     @row=split(",",$line);     chomp($row[2]);     chomp($row[1]);     $reg->include($row[2],[ 0.0, $row[1]]);  }  $reg->print(); close $f1; 

it giving me error:

regression_ema.pl::statistics::regression:standarderrors: cannot compute theta-covariance matrix variable 1 0  @ /usr/local/share/perl/5.20.2/statistics/regression.pm line 619, <$f1> line 2472.     statistics::regression::standarderrors(statistics::regression=hash(0x23f41f0)) called @ /usr/local/share/perl/5.20.2/statistics/regression.pm line 430     statistics::regression::print(statistics::regression=hash(0x23f41f0)) called @ regression_ema.pl line 23 

the documentation says:

please note you must provide constant if want one.

which lead me believe 1 can omit constant term if not wanted. but, in case, module croaks:

t.pl::statistics::regression:new: cannot run regression without @ least 2 variables.

i have long-held belief that, numerical analysis , statistical computations, 1 ought not trust well-intentioned ill-conceived amateurish contributions.

use intended used statisticians. r 1 obvious alternative.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -