【问题标题】:Linear Regression, Standard Error Issue线性回归,标准误差问题
【发布时间】:2013-08-20 17:01:37
【问题描述】:

好的,我有一个双精度列表,我首先想将其用作回归数据,然后将观察结果与相应的估计值(标准误差)进行比较。

但是,当我使用 SimpleRegression 时,它只记录 2 个参数(我猜是第一个和最后一个),所以当我尝试检查标准错误时,我得到了 OutOfRangeException。

我做错了什么?我应该使用 SimpleRegression 以外的其他东西吗?似乎很奇怪,它没有将每对 (x,y) 估计值都存储在 RegressionResults 变量中。

这是我的代码

//Linear Least Squares method
    SimpleRegression regression = new SimpleRegression();

    for (int i = 0; i < list.size(); i++) {
        regression.addData(i, list.get(i));
    }
    //I want to see how much a certain max differs from its estimate value.
    int indexOfTop = list.indexOf(secondTop);
    RegressionResults results = regression.regress();

    //How much this calculated top differ from the regression line

    double errorOfEstimate = 0;
    try {
        System.out
                .println("Parameters: " + results.getNumberOfParameters());
        errorOfEstimate = results.getStdErrorOfEstimate(indexOfTop);
    } catch (OutOfRangeException e) {
        System.out.println(e);
    }

【问题讨论】:

    标签: java math apache-commons


    【解决方案1】:

    但是,当我使用 SimpleRegression 时,它只记录 2 个参数(我是 猜测第一个和最后一个),所以当我尝试检查 标准错误我得到一个 OutOfRangeException。

    您只估计两个参数,X 和 Y 用于简单回归,如果您想查看添加了多少样本,请查看 getN() 方法 http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/stat/regression/RegressionResults.html#getN()

    我做错了什么?我应该使用其他东西吗 简单回归?它不存储每个 (x,y) 似乎很奇怪 RegressionResults 变量中的一对估计值。

    我认为您想获得预测并与您的观察结果进行比较,这在此处进行了解释 http://commons.apache.org/proper/commons-math/userguide/stat.html#a1.4_Simple_regression

    【讨论】:

    • 你知道我可以用什么来估计两个以上的参数吗?我想要对我基本上添加的每个观察点进行估计。编辑:从头开始,我是个傻瓜。显然我可以使用线性函数,只需添加 x 值...斜率*x + 截距!感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-20
    • 1970-01-01
    • 1970-01-01
    • 2021-07-16
    • 1970-01-01
    • 1970-01-01
    • 2017-06-06
    相关资源
    最近更新 更多