Skip to content

Commit df10bbb

Browse files
committed
Concrete matrix types change to Abstract ones
1 parent 313a007 commit df10bbb

36 files changed

Lines changed: 153 additions & 152 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# v0.11.1 (Upcoming Release)
2+
- Concrete types of X and y changed to AbstractMatrix{Float64} and AbstractVector{Float64}
23

34

45
# v0.11.0

src/asm2000.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function asm2000(setting::RegressionSetting)::Dict
5757
end
5858

5959

60-
function asm2000(X::Matrix{Float64}, y::Vector{Float64})::Dict
60+
function asm2000(X::AbstractMatrix{Float64}, y::AbstractVector{Float64})::Dict
6161
n, p = size(X)
6262
h = floor((n + p - 1) / 2)
6363
ltsreg = lts(X, y)

src/atkinson94.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ function atkinson94(setting::RegressionSetting; iters = nothing, crit = 3.0)::Di
5959
end
6060

6161
function atkinson94(
62-
X::Matrix{Float64},
63-
y::Vector{Float64};
62+
X::AbstractMatrix{Float64},
63+
y::AbstractVector{Float64};
6464
iters = nothing,
6565
crit = 3.0,
6666
)::Dict

src/atkinsonstalactiteplot.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ function atkinsonstalactiteplot(
3434
end
3535

3636
function atkinsonstalactiteplot(
37-
X::Matrix{Float64},
38-
y::Vector{Float64};
37+
X::AbstractMatrix{Float64},
38+
y::AbstractVector{Float64};
3939
iters = nothing,
4040
crit = 3.0,
4141
)::Nothing
@@ -46,7 +46,7 @@ function atkinsonstalactiteplot(
4646
end
4747

4848
function generate_stalactite_plot(
49-
residuals_matrix::Matrix{Float64},
49+
residuals_matrix::AbstractMatrix{Float64},
5050
n::Int64,
5151
p::Int64,
5252
crit,

src/bacon.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Two methods V1 and V2 are defined in the paper which use Mahalanobis distance or
2424
- `method`: The distance method to use for selecting the points for initial subset
2525
"""
2626
function initial_basic_subset_multivariate_data(
27-
X::Matrix{Float64},
27+
X::AbstractMatrix{Float64},
2828
m::Int;
2929
method::String = "mahalanobis",
3030
)
@@ -53,7 +53,7 @@ It also guarantees that at least m indices are returned and that the selected in
5353
- `m`: The minimum number of points to include in the subset indices.
5454
- `distances`: The distances vector used for selecting minumum distance indices.
5555
"""
56-
function select_subset(X::Matrix{Float64}, m::Int, distances::Array{Float64})
56+
function select_subset(X::AbstractMatrix{Float64}, m::Int, distances::Array{Float64})
5757
rank_x = rank(X)
5858
sorted_distances = sortperm(distances)
5959
subset = sorted_distances[1:m]
@@ -88,7 +88,7 @@ This function performs the outlier detection for multivariate data according to
8888
- `alpha`: The quantile used for cutoff
8989
"""
9090
function bacon_multivariate_outlier_detection(
91-
X::Matrix{Float64},
91+
X::AbstractMatrix{Float64},
9292
m::Int;
9393
method::String = "mahalanobis",
9494
alpha::Float64 = 0.025,
@@ -146,7 +146,7 @@ This function computes the t distance for each point and returns the distance ve
146146
- `y`: The output vector
147147
- `subset`: The vector which denotes the points inside the subset, used to scale the residuals accordingly.
148148
"""
149-
function compute_t_distance(X::Matrix{Float64}, y::Array{Float64}, subset::Array{Int64})
149+
function compute_t_distance(X::AbstractMatrix{Float64}, y::Array{Float64}, subset::Array{Int64})
150150

151151
n, p = size(X)
152152

@@ -187,7 +187,7 @@ This function computes the initial subset having at least m elements which are l
187187
- `alpha`: The quantile used for cutoff
188188
"""
189189
function bacon_regression_initial_subset(
190-
X::Matrix{Float64},
190+
X::AbstractMatrix{Float64},
191191
y::Array{Float64},
192192
m::Int;
193193
method::String = "mahalanobis",
@@ -259,7 +259,7 @@ Billor, Nedret, Ali S. Hadi, and Paul F. Velleman. "BACON: blocked adaptive comp
259259
Computational statistics & data analysis 34.3 (2000): 279-298.
260260
"""
261261
function bacon(
262-
X::Matrix{Float64},
262+
X::AbstractMatrix{Float64},
263263
y::Array{Float64};
264264
m::Int,
265265
method::String = "mahalanobis",

src/basis.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ julia> designMatrix(setting)
160160
1.0 73.0
161161
```
162162
"""
163-
function designMatrix(setting::RegressionSetting)::Matrix{Float64}
163+
function designMatrix(setting::RegressionSetting)::AbstractMatrix{Float64}
164164
mf = ModelFrame(setting.formula, setting.data)
165165
mm = ModelMatrix(mf)
166166
return convert(Matrix{Float64}, mm.m)
@@ -209,7 +209,7 @@ julia> responseVector(setting)
209209
29.0
210210
```
211211
"""
212-
function responseVector(setting::RegressionSetting)::Vector{Float64}
212+
function responseVector(setting::RegressionSetting)::AbstractVector{Float64}
213213
mf = ModelFrame(setting.formula, setting.data)
214214
return convert(Vector{Float64}, setting.data[:, mf.f.lhs.sym])
215215
end
@@ -292,7 +292,7 @@ end
292292
- `f::Function`: A function that takes a one dimensional array as argument.
293293
- `data::Matrix`: A Matrix object.
294294
"""
295-
function applyColumns(f::Function, data::Matrix)
295+
function applyColumns(f::Function, data::AbstractMatrix{Float64})
296296
return [f(col) for col in eachcol(data)]
297297
end
298298

@@ -305,20 +305,20 @@ end
305305
Return minimum of numbers greater than zero.
306306
307307
# Arguments
308-
- `arr::Vector{Float64}`: A function that takes a one dimensional array as argument.
308+
- `arr::AbstractVector{Float64}`: A function that takes a one dimensional array as argument.
309309
310310
# Example
311311
```julia-repl
312312
julia> find_minimum_nonzero([0.0, 0.0, 5.0, 1.0])
313313
1.0
314314
```
315315
"""
316-
function find_minimum_nonzero(arr::Vector{Float64})
316+
function find_minimum_nonzero(arr::AbstractVector{Float64})
317317
return minimum(filter(x -> x > 0, arr))
318318
end
319319

320320

321-
function zstandardize(v::Vector{Float64})::Vector{Float64}
321+
function zstandardize(v::AbstractVector{Float64})::AbstractVector{Float64}
322322
return (v .- mean(v)) ./ std(v)
323323
end
324324

src/bch.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ end
7575

7676

7777
function bch(
78-
Xdesign::Matrix{Float64},
79-
y::Vector{Float64};
78+
Xdesign::AbstractMatrix{Float64},
79+
y::AbstractVector{Float64};
8080
alpha = 0.05,
8181
maxiter = 1000,
8282
epsilon = 0.000001,

src/bchplot.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ function bchplot(
4242
end
4343

4444
function bchplot(
45-
Xdesign::Matrix{Float64},
46-
y::Vector{Float64};
45+
Xdesign::AbstractMatrix{Float64},
46+
y::AbstractVector{Float64};
4747
alpha = 0.05,
4848
maxiter = 1000,
4949
epsilon = 0.00001,

src/ccf.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Perform signed gradient descent for clipped convex functions for a given regress
1919
2020
# Arguments
2121
- `setting::RegressionSetting`: RegressionSetting object with a formula and dataset.
22-
- `starting_lambdas::Vector{Float64}`: Starting values of weighting parameters used by signed gradient descent.
22+
- `starting_lambdas::AbstractVector{Float64}`: Starting values of weighting parameters used by signed gradient descent.
2323
- `alpha::Float64`: Loss at which a point is labeled as an outlier (points with loss ≥ alpha will be called outliers).
2424
- `max_iter::Int64`: Maximum number of iterations to run signed gradient descent.
2525
- `beta::Float64`: Step size parameter.
@@ -79,9 +79,9 @@ end
7979
Perform signed gradient descent for clipped convex functions for a given regression setting.
8080
8181
# Arguments
82-
- `X::Matrix{Float64}`: Design matrix of the linear model.
83-
- `y::Vector{Float64}`: Response vector of the linear model.
84-
- `starting_lambdas::Vector{Float64}`: Starting values of weighting parameters used by signed gradient descent.
82+
- `X::AbstractMatrix{Float64}`: Design matrix of the linear model.
83+
- `y::AbstractVector{Float64}`: Response vector of the linear model.
84+
- `starting_lambdas::AbstractVector{Float64}`: Starting values of weighting parameters used by signed gradient descent.
8585
- `alpha::Float64`: Loss at which a point is labeled as an outlier. If unspecified, will be chosen as p*mean(residuals.^2), where residuals are OLS residuals.
8686
- `p::Float64`: Points that have squared OLS residual greater than p times the mean squared OLS residual are considered outliers.
8787
- `max_iter::Int64`: Maximum number of iterations to run signed gradient descent.
@@ -100,8 +100,8 @@ Barratt, S., Angeris, G. & Boyd, S. Minimizing a sum of clipped convex functions
100100
101101
"""
102102
function ccf(
103-
X::Matrix{Float64},
104-
y::Vector{Float64};
103+
X::AbstractMatrix{Float64},
104+
y::AbstractVector{Float64};
105105
starting_lambdas = nothing,
106106
alpha = nothing,
107107
p = 3,

src/cm97.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ end
5050

5151

5252

53-
function cm97(X::Matrix{Float64}, y::Vector{Float64}; maxiter::Int = 1000)::Dict
53+
function cm97(X::AbstractMatrix{Float64}, y::AbstractVector{Float64}; maxiter::Int = 1000)::Dict
5454

5555
n, p = size(X)
5656
pbar::Float64 = p / n

0 commit comments

Comments
 (0)