Class LMResiduals

    • Constructor Detail

      • LMResiduals

        public LMResiduals​(LMProblem problem,
                           Vector fitted)
        Performs residual analysis for a linear regression problem.
        Parameters:
        problem - the linear regression problem to be solved
        fitted - the fitted values, y^
    • Method Detail

      • getProblem

        public LMProblem getProblem()
        Gets the linear regression problem.
        Returns:
        the linear regression problem
      • fitted

        public ImmutableVector fitted()
        Gets the fitted values, y^.
        Returns:
        the fitted values, y^
      • residuals

        public ImmutableVector residuals()
        Gets the residuals, ε, the differences between sample and fitted values.
        Returns:
        the residuals, ε
      • weightedFittedValues

        public ImmutableVector weightedFittedValues()
        Gets the weighted, fitted values.
        Returns:
        the weighted, fitted values
      • weightedResiduals

        public ImmutableVector weightedResiduals()
        Gets the weighted residuals.
        Returns:
        the weighted residuals
      • RSS

        public double RSS()
        Gets the diagnostic measure: sum of squared residuals, \(\sum \epsilon^2\).
        Returns:
        sum of squared residuals, \(\sum \epsilon^2\)
      • TSS

        public double TSS()
        Gets the diagnostic measure: total sum of squares, \(\sum (y-y_mean)^2 \).
        Returns:
        total sum of squares, \(\sum (y-y_mean)^2 \)
      • R2

        public double R2()
        Gets the diagnostic measure: R-squared.
        Returns:
        R-squared
      • AR2

        public double AR2()
        Gets the diagnostic measure: adjusted R-squared
        Returns:
        adjusted R-squared
      • stderr

        public double stderr()
        Gets the standard error of the residuals.
        Returns:
        the standard error of the residuals
      • Fstat

        public double Fstat()
        Gets the diagnostic measure: F statistics
        
         mean of regression / mean squared error =
         sum((y_i_hat-y_mean)^2) / mean squared error =
         [(TSS-RSS)/n] / [RSS/(m-n)]
         
        y_i_hat are the fitted values of the regression.
        Returns:
        F statistics
      • hHat

        public ImmutableMatrix hHat()
        Gets the projection matrix, H-hat.
        Returns:
        the projection matrix
      • leverage

        public ImmutableVector leverage()
        Gets the leverage. The bigger the leverage for an observation, the bigger influence on the prediction.
        Returns:
        the leverage
      • standardized

        public ImmutableVector standardized()
        standard residual = residual / v1 / sqrt(RSS / (n-m))
        Returns:
        standardized residuals
      • studentized

        public ImmutableVector studentized()
        studentized residual = standardized * sqrt((n-m-1) / (n-m-standardized^2))
        Returns:
        studentized residuals
        See Also:
        • "Chatterjee, Hadi and Price, "p.90 (4.15), Section 4.3," Regression Analysis by Example, 3rd edition, 2000. Wiley Series in Probability and Statistics."
        • @see Wikipedia: Studentized residual
      • df

        public int df()
        Gets the degree of freedom.

        TODO: User should be able to modify this method for a different regression.

        Returns:
        the degree of freedom