IT CU
IT CU

Reputation: 15

Trying to decode and recode Perl Statistics::Regression code to R

I have some perl code I am trying to understand. I can figure most of it out. The part I am having an issue translating to R is my @theta = $reg->theta(); What is the theta part had how would I get that from an R code?

foreach my $id (keys(%$row_col_values)) {
    my $reg = Statistics::Regression->new( "title", [ "intercept", "slope"] );
    foreach my $row (keys(%$row_ids)) {
        foreach my $col (keys(%$col_ids)) {
            # Add data points
            if ($row_col_testplot_means->{$id}{$row}{$col} && $row_col_values->{$id}{$row}{$col}) {
                $reg->include( $row_col_testplot_means->{$id}{$row}{$col}, [ 1.0, $row_col_values->{$id}{$row}{$col}]);
            }
        }
    }
    my @theta = $reg->theta();

Upvotes: 0

Views: 68

Answers (1)

Sirius
Sirius

Reputation: 5429

If you look at the manual for Statistics::Regression:

https://metacpan.org/pod/Statistics::Regression

You will see that theta most likely is the R's coef() of your model (the coefficients).

See also the source where the theta method is defined:

https://metacpan.org/release/Statistics-Regression/source/Regression.pm#L448

It says outright that its the coefficients.

According to Peter Flom's answer here the greek letter theta is used to denote the set of estimated parameters from an ordinary least squares regression.

Upvotes: 3

Related Questions