Skip to content

Commit e0744f9

Browse files
committed
optional eps and maxiter in iterateCSteps of LTS
1 parent b8e7280 commit e0744f9

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# v0.11.2 (Upcoming Release)
22

3+
- Optional eps and maxiter parameters in iterateCSteps() in LTS.
4+
35

46
# v0.11.1
57

src/lts.jl

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Perform a concentration step for a given subset of a regression setting.
1717
- `setting::RegressionSetting`: RegressionSetting object with a formula and dataset.
1818
- `subsetindices::Array{Int, 1}`: Indicies of observations in the initial subset.
1919
- `h::Int`: A constant at least half of the number of observations.
20+
- `eps::Float64`: A small number, default is 0.01. If difference of last two objectives is less than eps, function terminates.
21+
- `maxiter::Int`: Maximum number of iteration. Default is 10000.
2022
2123
# Notes
2224
This function is a helper for the lts function. A concentration step starts with a
@@ -28,24 +30,24 @@ Rousseeuw, Peter J., and Katrien Van Driessen. "An algorithm for positive-breakd
2830
regression based on concentration steps." Data Analysis.
2931
Springer, Berlin, Heidelberg, 2000. 335-346.
3032
"""
31-
function iterateCSteps(setting::RegressionSetting, subsetindices::Array{Int,1}, h::Int)
33+
function iterateCSteps(setting::RegressionSetting,
34+
subsetindices::Array{Int,1},
35+
h::Int; eps::Float64 = 0.01, maxiter::Int = 10000)
3236
X, y = @extractRegressionSetting setting
33-
return iterateCSteps(X, y, subsetindices, h)
37+
return iterateCSteps(X, y, subsetindices, h, eps = eps, maxiter = maxiter)
3438
end
3539

3640

3741
function iterateCSteps(
3842
X::AbstractMatrix{Float64},
3943
y::AbstractVector{Float64},
4044
subsetindices::Array{Int,1},
41-
h::Int,
45+
h::Int; eps::Float64 = 0.01, maxiter::Int = 10000
4246
)
4347
#starterset = subsetindices
4448
oldobjective::Float64 = Inf64
4549
objective::Float64 = Inf64
4650
iter::Int = 0
47-
maxiter::Int = 10000
48-
eps::Float64 = 0.1
4951
while iter < maxiter
5052
olsreg = ols(X[subsetindices, :], y[subsetindices])
5153
betas = coef(olsreg)
@@ -66,24 +68,26 @@ function iterateCSteps(
6668
end
6769

6870

69-
function iterateCSteps(setting::RegressionSetting, initialBetas::AbstractVector{Float64}, h::Int)
71+
function iterateCSteps(setting::RegressionSetting,
72+
initialBetas::AbstractVector{Float64},
73+
h::Int; eps::Float64 = 0.01, maxiter::Int = 10000)
7074
X = designMatrix(setting)
7175
y = responseVector(setting)
72-
return iterateCSteps(X, y, initialBetas, h)
76+
return iterateCSteps(X, y, initialBetas, h, eps = eps, maxiter = maxiter)
7377
end
7478

7579
function iterateCSteps(
7680
X::AbstractMatrix{Float64},
7781
y::AbstractVector{Float64},
7882
initialBetas::AbstractVector{Float64},
79-
h::Int,
83+
h::Int; eps::Float64 = 0.01, maxiter::Int = 10000
8084
)
8185
n, p = size(X)
8286
#res = [y[i] - sum(X[i, :] .* initialBetas) for i = 1:n]
8387
res = y - X * initialBetas
8488
sortedresindices = sortperm(abs.(res))
8589
subsetindices = sortedresindices[1:p]
86-
return iterateCSteps(X, y, subsetindices, h)
90+
return iterateCSteps(X, y, subsetindices, h, eps = eps, maxiter = maxiter)
8791
end
8892

8993

0 commit comments

Comments
 (0)