统计::回归无法运行单变量回归?

发布于 2024-12-10 12:42:47 字数 548 浏览 0 评论 0原文

我正在使用 Statistics::Regression 的 Perl 模块。它可以很好地运行多变量回归。但是,如果我在构造函数中只提供一个回归量,

my $reg = Statistics::Regression->new("Sample Regression", ['X']);

它会抱怨以下消息:

Statistics::Regression:new: Cannot run a regression without at least two variables.

人们有同样的问题吗?错误消息的措辞不明确,因此我解释为好像我没有提供响应变量。但事实并非如此,因为根据它的文档和我在侧面测试的一些示例脚本,构造函数中的列表引用应该只包含回归量。

无论如何,如何使用此模块运行单变量回归(无常数项)? (我知道Statistics::OLS可以做到这一点,但为了简单起见,我希望这个模块能够工作。无论如何,如果它真的无法处理这个问题,感觉就像是一个愚蠢的遗漏。)谢谢!

I'm using the Perl module of Statistics::Regression. It runs multi-variate regressions fine. However, if I only supply one regressor in the constructor

my $reg = Statistics::Regression->new("Sample Regression", ['X']);

It complains with this message:

Statistics::Regression:new: Cannot run a regression without at least two variables.

Do people have the same problem? The error message is not clearly worded so that I interpreted as if I'm not supplying the response variable. But that turns out not to be the case as based on its doc and some sample scripts I tested on the side, the list reference in the constructor should only include regressors.

IN any case, how do you run a single variable regression (no constant term) using this module? (I know Statistics::OLS can do that but for simplicity I would like this module to work. At any rate, feels like a stupid omission if it truly cannot handle that.) Thx!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流年里的时光 2024-12-17 12:42:47

模块的描述内容如下:

Regression.pm 是一个多元线性回归包。

鉴于此,您似乎不太可能让它进行单变量回归。

不过,您可以尝试向作者发送电子邮件。自从 Statistics::Regression 发布到 CPAN 以来已经四年了,所以他可能已经停止支持它(或者它的状态很好,不需要更多版本),但值得一试听取他的意见。他可能有一些关于修补它以处理单变量回归的想法。

The module's description reads:

Regression.pm is a multivariate linear regression package.

Given this, it seems unlikely that you'll be able to get it to do univariate regressions.

You could try emailing the author, though. It's been four years since Statistics::Regression was released to CPAN so he might have stopped supporting it (or it's in such a good state that it doesn't need more releases), but it's worth a shot getting his opinion. He might have some idea as to patching it to handle univariate regressions.

谢绝鈎搭 2024-12-17 12:42:47

要使其适用于单变量,请指定一个常量,如下所示:
(include 的第一个参数是 y,第二个参数是 [constant, x])。如果您不需要截距,也可以指定 0 作为常量。

my $reg=Statistics::Regression->new("Title", ["Intercept", "Slope"]);
 
$reg->include(1.3, [1.0, 1.0]);
$reg->include(2.9, [1.0, 2.0]);
$reg->include(4.2, [1.0, 3.0]);
$reg->include(5.4, [1.0, 4.0]);

在此 博客

To make this work for univariate, specify a constant, like this:
(include's first argument is y, second is [ constant, x ]). You can also specify 0 as the constant if you don't want the intercept

my $reg=Statistics::Regression->new("Title", ["Intercept", "Slope"]);
 
$reg->include(1.3, [1.0, 1.0]);
$reg->include(2.9, [1.0, 2.0]);
$reg->include(4.2, [1.0, 3.0]);
$reg->include(5.4, [1.0, 4.0]);

Find a detailed explanation in this blog

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文