统计::回归无法运行单变量回归?
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
模块的描述内容如下:
鉴于此,您似乎不太可能让它进行单变量回归。
不过,您可以尝试向作者发送电子邮件。自从
Statistics::Regression
发布到 CPAN 以来已经四年了,所以他可能已经停止支持它(或者它的状态很好,不需要更多版本),但值得一试听取他的意见。他可能有一些关于修补它以处理单变量回归的想法。The module's description reads:
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.要使其适用于单变量,请指定一个常量,如下所示:
(include 的第一个参数是 y,第二个参数是 [constant, x])。如果您不需要截距,也可以指定 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
Find a detailed explanation in this blog