/** * Returns the half-width of a 95% confidence interval for the slope * estimate. * <p> * The 95% confidence interval is</p> * <p> * <code>(getSlope() - getSlopeConfidenceInterval(), * getSlope() + getSlopeConfidenceInterval())</code></p> * <p> * If there are fewer that <strong>three</strong> observations in the * model, or if there is no variation in x, this returns * <code>Double.NaN</code>.</p> * <p> * <strong>Usage Note</strong>:<br> * The validity of this statistic depends on the assumption that the * observations included in the model are drawn from a * <a href="http://mathworld.wolfram.com/BivariateNormalDistribution.html"> * Bivariate Normal Distribution</a>.</p> * * @return half-width of 95% confidence interval for the slope estimate * @throws OutOfRangeException if the confidence interval can not be computed. */ public double getSlopeConfidenceInterval() throws OutOfRangeException { return getSlopeConfidenceInterval(0.05d); }
/** * Returns the half-width of a 95% confidence interval for the slope * estimate. * <p> * The 95% confidence interval is</p> * <p> * <code>(getSlope() - getSlopeConfidenceInterval(), * getSlope() + getSlopeConfidenceInterval())</code></p> * <p> * If there are fewer that <strong>three</strong> observations in the * model, or if there is no variation in x, this returns * <code>Double.NaN</code>.</p> * <p> * <strong>Usage Note</strong>:<br> * The validity of this statistic depends on the assumption that the * observations included in the model are drawn from a * <a href="http://mathworld.wolfram.com/BivariateNormalDistribution.html"> * Bivariate Normal Distribution</a>.</p> * * @return half-width of 95% confidence interval for the slope estimate * @throws OutOfRangeException if the confidence interval can not be computed. */ public double getSlopeConfidenceInterval() throws OutOfRangeException { return getSlopeConfidenceInterval(0.05d); }
/** * Returns the half-width of a 95% confidence interval for the slope * estimate. * <p> * The 95% confidence interval is</p> * <p> * <code>(getSlope() - getSlopeConfidenceInterval(), * getSlope() + getSlopeConfidenceInterval())</code></p> * <p> * If there are fewer that <strong>three</strong> observations in the * model, or if there is no variation in x, this returns * <code>Double.NaN</code>.</p> * <p> * <strong>Usage Note</strong>:<br> * The validity of this statistic depends on the assumption that the * observations included in the model are drawn from a * <a href="http://mathworld.wolfram.com/BivariateNormalDistribution.html"> * Bivariate Normal Distribution</a>.</p> * * @return half-width of 95% confidence interval for the slope estimate * @throws OutOfRangeException if the confidence interval can not be computed. */ public double getSlopeConfidenceInterval() throws OutOfRangeException { return getSlopeConfidenceInterval(0.05d); }
@NonNull private static PredictionData getPredictionData(int attempt, String tagId, ArrayList<GlucoseData> trendList) { PredictionData predictedGlucose = new PredictionData(); SimpleRegression regression = new SimpleRegression(); for (int i = 0; i < trendList.size(); i++) { regression.addData(trendList.size() - i, (trendList.get(i)).glucoseLevel); } predictedGlucose.glucoseLevel = (int)regression.predict(15 + PREDICTION_TIME); predictedGlucose.trend = regression.getSlope(); predictedGlucose.confidence = regression.getSlopeConfidenceInterval(); predictedGlucose.errorCode = PredictionData.Result.OK; predictedGlucose.realDate = trendList.get(0).realDate; predictedGlucose.sensorId = tagId; predictedGlucose.attempt = attempt; predictedGlucose.sensorTime = trendList.get(0).sensorTime; return predictedGlucose; } }
map.put("RSquared", regression.getRSquare()); map.put("regressionSumSquares", regression.getRegressionSumSquares()); map.put("slopeConfidenceInterval", regression.getSlopeConfidenceInterval()); map.put("interceptStdErr", regression.getInterceptStdErr()); map.put("totalSumSquares", regression.getTotalSumSquares());
@Override LR.ModelResult asResult() { LR.ModelResult r = new LR.ModelResult(name, framework, hasConstant(), getNumVars(), state, getNTrain(), getNTest()); if (state != State.created) { List<Double> params = new ArrayList<>(); params.add(R.getIntercept()); params.add(R.getSlope()); r.withTrainInfo("parameters", params, "RSquared", R.getRSquare(), "significance", R.getSignificance(), "slope confidence interval", R.getSlopeConfidenceInterval(), "intercept std error", R.getInterceptStdErr(), "slope std error", R.getSlopeStdErr(), "SSE", R.getSumSquaredErrors(), "MSE", R.getMeanSquareError(), "correlation", R.getR(), "SSR", R.getRegressionSumSquares(), "SST", R.getTotalSumSquares()); } if (tester.isReady()) r.withTestInfo(tester.getStatistics()); return r; }