Added a check for too few data in linear regression
JIRA: MATH-279 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@791244 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
720a0b2626
commit
e4a8fdfdf1
3
pom.xml
3
pom.xml
|
@ -108,6 +108,9 @@
|
||||||
<contributor>
|
<contributor>
|
||||||
<name>Rémi Arntzen</name>
|
<name>Rémi Arntzen</name>
|
||||||
</contributor>
|
</contributor>
|
||||||
|
<contributor>
|
||||||
|
<name>Michael Bjorkegren</name>
|
||||||
|
</contributor>
|
||||||
<contributor>
|
<contributor>
|
||||||
<name>John Bollinger</name>
|
<name>John Bollinger</name>
|
||||||
</contributor>
|
</contributor>
|
||||||
|
|
|
@ -311,12 +311,6 @@ public class MessagesResources_fr
|
||||||
{ "{0} method needs at least one previous point",
|
{ "{0} method needs at least one previous point",
|
||||||
"la m\u00e9thode {0} n\u00e9cessite au moins un point pr\u00e9c\u00e9dent" },
|
"la m\u00e9thode {0} n\u00e9cessite au moins un point pr\u00e9c\u00e9dent" },
|
||||||
|
|
||||||
// org.apache.commons.math.ode.stiff.BDFIntegrator
|
|
||||||
{ "unsupported order {0} for BDF methods, must be between {1} and {2}",
|
|
||||||
"ordre {0} non support\u00e9 pour les m\u00e9thodes BDF, doit \u00eatre entre {1} et {2}" },
|
|
||||||
{ "corrector failed to converge after {0} iterations at t = {1}",
|
|
||||||
"\u00e9chec de convergence du correcteur apr\u00e8s {0} it\u00e9rations \u00e0 t = {1}" },
|
|
||||||
|
|
||||||
// org.apache.commons.math.ode.ContinuousOutputModel
|
// org.apache.commons.math.ode.ContinuousOutputModel
|
||||||
// org.apache.commons.math.optimization.direct.DirectSearchOptimizer
|
// org.apache.commons.math.optimization.direct.DirectSearchOptimizer
|
||||||
{ "unexpected exception caught",
|
{ "unexpected exception caught",
|
||||||
|
@ -729,6 +723,10 @@ public class MessagesResources_fr
|
||||||
{ "matrix is not upper-triangular, entry ({0}, {1}) = {2} is too large",
|
{ "matrix is not upper-triangular, entry ({0}, {1}) = {2} is too large",
|
||||||
"matrice non triangulaire sup\u00e9rieure, l''\u00e9l\u00e9ment ({0}, {1}) = {2} est trop grand" },
|
"matrice non triangulaire sup\u00e9rieure, l''\u00e9l\u00e9ment ({0}, {1}) = {2} est trop grand" },
|
||||||
|
|
||||||
|
// org.apache.commons.math.stat.regression.AbstractMultipleLinearRegression
|
||||||
|
{ "not enough data ({0} rows) for this many predictors ({1} predictors)",
|
||||||
|
"pas assez de donn\u00e9es ({0} lignes) pour {1} pr\u00e9dicteurs" },
|
||||||
|
|
||||||
// org.apache.commons.math.distribution.AbstractContinuousDistribution
|
// org.apache.commons.math.distribution.AbstractContinuousDistribution
|
||||||
// org.apache.commons.math.distribution.AbstractIntegerDistribution
|
// org.apache.commons.math.distribution.AbstractIntegerDistribution
|
||||||
// org.apache.commons.math.distribution.ExponentialDistributionImpl
|
// org.apache.commons.math.distribution.ExponentialDistributionImpl
|
||||||
|
|
|
@ -91,6 +91,10 @@ public abstract class AbstractMultipleLinearRegression implements
|
||||||
"dimension mismatch {0} != {1}",
|
"dimension mismatch {0} != {1}",
|
||||||
(x == null) ? 0 : x.length,
|
(x == null) ? 0 : x.length,
|
||||||
(y == null) ? 0 : y.length);
|
(y == null) ? 0 : y.length);
|
||||||
|
} else if ((x.length > 0) && (x[0].length > x.length)) {
|
||||||
|
throw MathRuntimeException.createIllegalArgumentException(
|
||||||
|
"not enough data ({0} rows) for this many predictors ({1} predictors)",
|
||||||
|
x.length, x[0].length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,9 @@ The <action> type attribute can be add,update,fix,remove.
|
||||||
</properties>
|
</properties>
|
||||||
<body>
|
<body>
|
||||||
<release version="2.0" date="TBD" description="TBD">
|
<release version="2.0" date="TBD" description="TBD">
|
||||||
|
<action dev="luc" type="add" issue="MATH-279" due-to="Michael Bjorkegren">
|
||||||
|
Added a check for too few rows with respect to the number of predictors in linear regression
|
||||||
|
</action>
|
||||||
<action dev="luc" type="add" due-to="Dimitri Pourbaix">
|
<action dev="luc" type="add" due-to="Dimitri Pourbaix">
|
||||||
Added a getCovariance method to singular value decomposition
|
Added a getCovariance method to singular value decomposition
|
||||||
</action>
|
</action>
|
||||||
|
|
|
@ -69,6 +69,17 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
|
||||||
createRegression().newSampleData(new double[]{}, new double[][]{}, null);
|
createRegression().newSampleData(new double[]{}, new double[][]{}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected=IllegalArgumentException.class)
|
||||||
|
public void notEnoughData() {
|
||||||
|
double[] reducedY = new double[y.length - 1];
|
||||||
|
double[][] reducedX = new double[x.length - 1][];
|
||||||
|
double[][] reducedO = new double[omega.length - 1][];
|
||||||
|
System.arraycopy(y, 0, reducedY, 0, reducedY.length);
|
||||||
|
System.arraycopy(x, 0, reducedX, 0, reducedX.length);
|
||||||
|
System.arraycopy(omega, 0, reducedO, 0, reducedO.length);
|
||||||
|
createRegression().newSampleData(reducedY, reducedX, reducedO);
|
||||||
|
}
|
||||||
|
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void cannotAddCovarianceDataWithSampleSizeMismatch() {
|
public void cannotAddCovarianceDataWithSampleSizeMismatch() {
|
||||||
double[] y = new double[]{1.0, 2.0};
|
double[] y = new double[]{1.0, 2.0};
|
||||||
|
|
Loading…
Reference in New Issue