Created
September 1, 2016 08:49
-
-
Save joaofig/7537e92ca6110acad31c43c82d5ef97c to your computer and use it in GitHub Desktop.
Linear regression model outlier detector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public bool IsOutlier(double radius, double x, double y) | |
| { | |
| double yHat = GetValue( x ); | |
| double studentizedResidue = Math.Abs(y - yHat) / Math.Sqrt( GetResidualVariance() ); | |
| return studentizedResidue > radius; | |
| } | |
| private double GetResidualVariance() | |
| { | |
| return GetRSS() / (count - 2); | |
| } | |
| private double GetRSS() | |
| { | |
| return beta * beta * sumXX | |
| -2 * beta * sumXY | |
| +2 * alpha * beta * sumX | |
| +sumYY | |
| -2 * alpha * sumY | |
| +alpha * alpha * count; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment