-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
961 additions
and
213 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "LinRegOutliers" | ||
uuid = "6d4de0fb-32d9-4c65-aac1-cc9ed8b94b1a" | ||
authors = ["Mehmet Hakan Satman <[email protected]>", "Shreesh Adiga <[email protected]>", "Guillermo Angeris <[email protected]>", "Emre Akadal <[email protected]>"] | ||
version = "0.8.19" | ||
version = "0.9.0" | ||
|
||
[deps] | ||
Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5" | ||
|
@@ -11,7 +11,7 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" | |
GLPK = "60bf3e95-4087-53dc-ae20-288a0d20c6a6" | ||
JuMP = "4076af6c-e467-56ae-b986-b466b2749572" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" | ||
Requires = "ae029012-a4dd-5104-9daa-d747884805df" | ||
StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d" | ||
|
||
[compat] | ||
|
@@ -21,6 +21,6 @@ DataFrames = "0.22, 1" | |
Distributions = "0.17, 0.18, 0.19.1, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25" | ||
GLPK = "0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 1" | ||
JuMP = "0.19, 0.20, 0.21, 0.22, 0.23, 1" | ||
Plots = "0.22.2, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 1" | ||
Requires = "1" | ||
StatsModels = "0.4, 0.5, 0.6" | ||
julia = "1.4" |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
module BCHPlot | ||
|
||
|
||
export bchplot | ||
|
||
|
||
import ..BCH: bch | ||
import ..Basis: RegressionSetting | ||
|
||
|
||
""" | ||
bchplot(setting::RegressionSetting; alpha=0.05, maxiter=1000, epsilon=0.00001) | ||
Perform the Billor & Chatterjee & Hadi (2006) algorithm and generates outlier plot | ||
for the given regression setting. | ||
# Arguments | ||
- `setting::RegressionSetting`: RegressionSetting object with a formula and dataset. | ||
- `alpha::Float64`: Optional argument of the probability of rejecting the null hypothesis. | ||
- `maxiter::Int`: Maximum number of iterations for calculating iterative weighted least squares estimates. | ||
- `epsilon::Float64`: Accuracy for determining convergency. | ||
# References | ||
Billor, Nedret, Samprit Chatterjee, and Ali S. Hadi. "A re-weighted least squares method | ||
for robust regression estimation." American journal of mathematical and management sciences 26.3-4 (2006): 229-252. | ||
!!! warning "Dependencies" | ||
This method is enabled when the Plots package is installed and loaded. | ||
""" | ||
function bchplot( | ||
setting::RegressionSetting; | ||
alpha = 0.05, | ||
maxiter = 1000, | ||
epsilon = 0.00001, | ||
) | ||
X = designMatrix(setting) | ||
y = responseVector(setting) | ||
return bchplot(X, y, alpha = alpha, maxiter = maxiter, epsilon = epsilon) | ||
end | ||
|
||
function bchplot( | ||
Xdesign::Array{Float64,2}, | ||
y::Array{Float64,1}; | ||
alpha = 0.05, | ||
maxiter = 1000, | ||
epsilon = 0.00001, | ||
) | ||
result = bch(Xdesign, y, alpha = alpha, maxiter = maxiter, epsilon = epsilon) | ||
squared_normalized_residuals = result["squared.normalized.residuals"] | ||
squared_normalized_robust_distances = result["squared.normalized.robust.distances"] | ||
n = length(squared_normalized_robust_distances) | ||
scplot = scatter( | ||
squared_normalized_robust_distances, | ||
squared_normalized_residuals, | ||
legend = false, | ||
series_annotations = text.(1:n, :bottom), | ||
tickfont = font(10), | ||
guidefont = font(10), | ||
labelfont = font(10), | ||
) | ||
title!("Billor & Chatterjee & Hadi Plot") | ||
xlabel!("Squared Normalized Robust Distances") | ||
ylabel!("Squared Normalized Residuals") | ||
end | ||
|
||
end # end of module |
This file contains 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
This file contains 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
Oops, something went wrong.