Class OLSRegression
- java.lang.Object
-
- dev.nm.stat.regression.linear.ols.OLSRegression
-
- All Implemented Interfaces:
LinearModel
public class OLSRegression extends Object implements LinearModel
(Weighted) Ordinary Least Squares (OLS) is a method for fitting a linear regression model. This method minimizes the (weighted) sum of squared distances between the observed responses in the dataset, and the responses predicted by the linear approximation. The OLS estimator is consistent when the regressors are exogenous and there is no multicollinearity, and optimal in the class of linear unbiased estimators when the errors are homoscedastic and serially uncorrelated. OLS can be derived as a maximum likelihood estimator under the assumption that the errors are normally distributed, however the method has good statistical properties for a much broader class of distributions (except for efficiency).
-
-
Constructor Summary
Constructors Constructor Description OLSRegression(LMProblem problem)
Constructs an OLSRegression instance.OLSRegression(LMProblem problem, double epsilon)
Constructs an OLSRegression instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description OLSBeta
beta()
Gets \(\hat{\beta}\) and statistics.LMDiagnostics
diagnostics()
Gets the diagnostic measures of an OLS regression.double
Ey(Vector x)
Computes the expectation \(E(y(x))\) given an input.static double
Ey(Vector beta, Vector x, boolean intercept)
LMInformationCriteria
informationCriteria()
Gets the model selection criteria.OLSResiduals
residuals()
Gets the residual analysis of an OLS regression.
-
-
-
Constructor Detail
-
OLSRegression
public OLSRegression(LMProblem problem, double epsilon)
Constructs an OLSRegression instance.- Parameters:
problem
- the linear regression problem to be solvedepsilon
- a precision parameter: when a number |x| ≤ ε, it is considered 0
-
OLSRegression
public OLSRegression(LMProblem problem)
Constructs an OLSRegression instance.- Parameters:
problem
- the linear regression problem to be solved
-
-
Method Detail
-
Ey
public double Ey(Vector x)
Description copied from interface:LinearModel
Computes the expectation \(E(y(x))\) given an input.- Specified by:
Ey
in interfaceLinearModel
- Parameters:
x
- an input- Returns:
- \(E(y(x))\)
-
beta
public OLSBeta beta()
Description copied from interface:LinearModel
Gets \(\hat{\beta}\) and statistics.- Specified by:
beta
in interfaceLinearModel
- Returns:
- \(\hat{\beta}\) and statistics
-
residuals
public OLSResiduals residuals()
Description copied from interface:LinearModel
Gets the residual analysis of an OLS regression.- Specified by:
residuals
in interfaceLinearModel
- Returns:
- the residual analysis
-
diagnostics
public LMDiagnostics diagnostics()
Gets the diagnostic measures of an OLS regression.- Returns:
- the diagnostic measures of an OLS regression
-
informationCriteria
public LMInformationCriteria informationCriteria()
Gets the model selection criteria.- Returns:
- the model selection criteria
-
-