Class 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).

    See Also:
    • Constructor Detail

      • OLSRegression

        public OLSRegression​(LMProblem problem,
                             double epsilon)
        Constructs an OLSRegression instance.
        Parameters:
        problem - the linear regression problem to be solved
        epsilon - 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 interface LinearModel
        Parameters:
        x - an input
        Returns:
        \(E(y(x))\)
      • Ey

        public static double Ey​(Vector beta,
                                Vector x,
                                boolean intercept)
      • beta

        public OLSBeta beta()
        Description copied from interface: LinearModel
        Gets \(\hat{\beta}\) and statistics.
        Specified by:
        beta in interface LinearModel
        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 interface LinearModel
        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