Skip to content

Commit 79b56a6

Browse files
committed
fix lts for singular design matrix
1 parent 7fed5e1 commit 79b56a6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/lts.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export lts
44
export iterateCSteps
55

66
import ..Basis: RegressionSetting, @extractRegressionSetting, designMatrix, responseVector
7+
import ..OrdinaryLeastSquares: ols, residuals, coef
78

89
import Distributions: sample, mean
910

@@ -49,8 +50,10 @@ function iterateCSteps(
4950
objective::Float64 = Inf64
5051
iter::Int = 0
5152
while iter < maxiter
52-
betas = X[subsetindices, :] \ y[subsetindices]
53-
res = y - X * betas
53+
#betas = X[subsetindices, :] \ y[subsetindices]
54+
#res = y - X * betas
55+
tempols = ols(X[subsetindices, :], y[subsetindices])
56+
res = y - X * coef(tempols)
5457
sortedresindices = sortperm(abs.(res))
5558
subsetindices = sortedresindices[1:h]
5659
objective = sum(sort(res .^ 2.0)[1:h])

0 commit comments

Comments
 (0)