From 25acfb6505712b2a66cb90de92f72f8f0d0717cb Mon Sep 17 00:00:00 2001 From: Greg Sterijevski Date: Sat, 10 Sep 2011 05:20:56 +0000 Subject: [PATCH] Changing doc to reflect revised constructor for SimpleRegression git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1167460 13f79535-47bb-0310-9956-ffa450edef68 --- src/site/xdoc/userguide/stat.xml | 35 ++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/site/xdoc/userguide/stat.xml b/src/site/xdoc/userguide/stat.xml index d2601378d..86f42f2c3 100644 --- a/src/site/xdoc/userguide/stat.xml +++ b/src/site/xdoc/userguide/stat.xml @@ -365,6 +365,10 @@ System.out.println(f.getCumPct("z")); // displays 1 y = intercept + slope * x

+ or +

+ y = slope * x +

Standard errors for intercept and slope are available as well as ANOVA, r-square and Pearson's r statistics.

@@ -408,7 +412,6 @@ System.out.println(f.getCumPct("z")); // displays 1 Here are some examples.
Estimate a model based on observations added one at a time
-

Instantiate a regression instance and add data points regression = new SimpleRegression(); @@ -445,8 +448,8 @@ System.out.println(regression.predict(1.5d) More data points can be added and subsequent getXxx calls will incorporate additional data in statistics.
+

Estimate a model from a double[][] array of data points
-

Instantiate a regression object and load dataset double[][] data = { { 1, 3 }, {2, 5 }, {3, 7 }, {4, 14 }, {5, 11 }}; @@ -468,6 +471,34 @@ System.out.println(regression.getSlopeStdErr()); More data points -- even another double[][] array -- can be added and subsequent getXxx calls will incorporate additional data in statistics.
+

+
Estimate a model from a double[][] array of data points, excluding the intercept
+
Instantiate a regression object and load dataset + +double[][] data = { { 1, 3 }, {2, 5 }, {3, 7 }, {4, 14 }, {5, 11 }}; +SimpleRegression regression = new SimpleRegression(false); +//the argument, false, tells the class not to include a constant +regression.addData(data); + +
+
Estimate regression model based on data + +System.out.println(regression.getIntercept()); +// displays intercept of regression line, since we have constrained the constant, 0.0 is returned + +System.out.println(regression.getSlope()); +// displays slope of regression line + +System.out.println(regression.getSlopeStdErr()); +// displays slope standard error + +System.out.println(regression.getInterceptStdErr() ); +// will return Double.NaN, since we constrained the parameter to zero + + Caution must be exercised when interpreting the slope when no constant is being estimated. The slope + may be biased. +
+