0

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

但是,当我使用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);
    }
4

1 回答 1

0

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

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

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

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

于 2013-08-19T04:31:14.130 回答