有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java线性回归,标准误差问题

好的,我有一个双倍的列表,我首先想用它作为回归的数据,然后将观察值与各自的估计值(标准误差)进行比较

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

我做错了什么?我是不是应该使用简单回归之外的东西?似乎很奇怪,它没有将每一(x,y)对估计值存储在回归结果变量中

这是我的密码

//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);
    }

共 (1) 个答案

  1. # 1 楼答案

    But, when I use SimpleRegression it just records 2 parameters (I'm guessing the first and the last), so when I try to check for the standard error I get a OutOfRangeException.

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

    What am I doing wrong? Should I be using something else than SimpleRegression? It seems strange that it doesn't store every (x,y) pair of estimates in the RegressionResults variable.

    我想你想得到预测,并与你的观察结果进行比较,这里解释了一些事情http://commons.apache.org/proper/commons-math/userguide/stat.html#a1.4_Simple_regression