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 OLSBetabeta()Gets \(\hat{\beta}\) and statistics.LMDiagnosticsdiagnostics()Gets the diagnostic measures of an OLS regression.doubleEy(Vector x)Computes the expectation \(E(y(x))\) given an input.static doubleEy(Vector beta, Vector x, boolean intercept)LMInformationCriteriainformationCriteria()Gets the model selection criteria.OLSResidualsresiduals()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:LinearModelComputes the expectation \(E(y(x))\) given an input.- Specified by:
Eyin interfaceLinearModel- Parameters:
x- an input- Returns:
- \(E(y(x))\)
-
beta
public OLSBeta beta()
Description copied from interface:LinearModelGets \(\hat{\beta}\) and statistics.- Specified by:
betain interfaceLinearModel- Returns:
- \(\hat{\beta}\) and statistics
-
residuals
public OLSResiduals residuals()
Description copied from interface:LinearModelGets the residual analysis of an OLS regression.- Specified by:
residualsin 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
-
-