Class AbstractMultipleLinearRegression
- java.lang.Object
-
- org.apache.commons.math.stat.regression.AbstractMultipleLinearRegression
-
- All Implemented Interfaces:
MultipleLinearRegression
- Direct Known Subclasses:
GLSMultipleLinearRegression,OLSMultipleLinearRegression
public abstract class AbstractMultipleLinearRegression extends java.lang.Object implements MultipleLinearRegression
Abstract base class for implementations of MultipleLinearRegression.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description AbstractMultipleLinearRegression()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubleestimateErrorVariance()Estimates the variance of the error.doubleestimateRegressandVariance()Returns the variance of the regressand, ie Var(y).double[]estimateRegressionParameters()Estimates the regression parameters b.double[]estimateRegressionParametersStandardErrors()Returns the standard errors of the regression parameters.double[][]estimateRegressionParametersVariance()Estimates the variance of the regression parameters, ie Var(b).doubleestimateRegressionStandardError()Estimates the standard error of the regression.double[]estimateResiduals()Estimates the residuals, ie u = y - X*b.booleanisNoIntercept()voidnewSampleData(double[] data, int nobs, int nvars)Loads model x and y sample data from a flat input array, overriding any previous sample.voidsetNoIntercept(boolean noIntercept)
-
-
-
Method Detail
-
isNoIntercept
public boolean isNoIntercept()
- Returns:
- true if the model has no intercept term; false otherwise
- Since:
- 2.2
-
setNoIntercept
public void setNoIntercept(boolean noIntercept)
- Parameters:
noIntercept- true means the model is to be estimated without an intercept term- Since:
- 2.2
-
newSampleData
public void newSampleData(double[] data, int nobs, int nvars)Loads model x and y sample data from a flat input array, overriding any previous sample.
Assumes that rows are concatenated with y values first in each row. For example, an input
dataarray containing the sequence of values (1, 2, 3, 4, 5, 6, 7, 8, 9) withnobs = 3andnvars = 2creates a regression dataset with two independent variables, as below:y x[0] x[1] -------------- 1 2 3 4 5 6 7 8 9
Note that there is no need to add an initial unitary column (column of 1's) when specifying a model including an intercept term. If
isNoIntercept()istrue, the X matrix will be created without an initial column of "1"s; otherwise this column will be added.Throws IllegalArgumentException if any of the following preconditions fail:
datacannot be nulldata.length = nobs * (nvars + 1)nobs > nvars
- Parameters:
data- input data arraynobs- number of observations (rows)nvars- number of independent variables (columns, not counting y)- Throws:
java.lang.IllegalArgumentException- if the preconditions are not met
-
estimateRegressionParameters
public double[] estimateRegressionParameters()
Estimates the regression parameters b.- Specified by:
estimateRegressionParametersin interfaceMultipleLinearRegression- Returns:
- The [k,1] array representing b
-
estimateResiduals
public double[] estimateResiduals()
Estimates the residuals, ie u = y - X*b.- Specified by:
estimateResidualsin interfaceMultipleLinearRegression- Returns:
- The [n,1] array representing the residuals
-
estimateRegressionParametersVariance
public double[][] estimateRegressionParametersVariance()
Estimates the variance of the regression parameters, ie Var(b).- Specified by:
estimateRegressionParametersVariancein interfaceMultipleLinearRegression- Returns:
- The [k,k] array representing the variance of b
-
estimateRegressionParametersStandardErrors
public double[] estimateRegressionParametersStandardErrors()
Returns the standard errors of the regression parameters.- Specified by:
estimateRegressionParametersStandardErrorsin interfaceMultipleLinearRegression- Returns:
- standard errors of estimated regression parameters
-
estimateRegressandVariance
public double estimateRegressandVariance()
Returns the variance of the regressand, ie Var(y).- Specified by:
estimateRegressandVariancein interfaceMultipleLinearRegression- Returns:
- The double representing the variance of y
-
estimateErrorVariance
public double estimateErrorVariance()
Estimates the variance of the error.- Returns:
- estimate of the error variance
- Since:
- 2.2
-
estimateRegressionStandardError
public double estimateRegressionStandardError()
Estimates the standard error of the regression.- Returns:
- regression standard error
- Since:
- 2.2
-
-