Skip to content

Commit f373812

Browse files
authored
make zerocorr!(mod) mark the model as unfitted (#251)
* make zerocorr!(mod) marks the model as unfitted * tests for preserved vals * simplify zeroing out of non-diagonal entries
1 parent d239959 commit f373812

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/linearmixedmodel.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ function zerocorr!(m::LinearMixedModel{T}, trmns) where {T}
869869
optsum.initial_step = T[]
870870

871871
# the model is no longer fitted
872-
optsum.feval == -1
872+
optsum.feval = -1
873873

874874
m
875875
end

src/remat.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,7 @@ vsize(A::ReMat{T,S}) where {T,S} = S
550550
function zerocorr!(A::ReMat{T}) where {T}
551551
λ = A.λ
552552
A.inds = intersect(A.inds, diagind(λ))
553-
fill!.data, 0)
554-
for i in A.inds
555-
λ.data[i] = 1
556-
end
553+
# zero out all entries not on the diagonal
554+
λ[setdiff(A.inds, diagind(λ))] .= 0
557555
A
558556
end

test/pls.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,13 @@ end
220220

221221
simulate!(fm) # to test one of the unscaledre methods
222222

223-
fmnc = zerocorr!(LinearMixedModel(@formula(reaction ~ 1+days+ (1+days|subj)), slp))
223+
fmnc = zerocorr!(deepcopy(fm))
224+
@test fmnc.optsum.feval < 0
225+
@test size(fmnc) == (180,2,36,1)
226+
@test fmnc.θ == [fm.θ[1], fm.θ[3]]
227+
@test lowerbd(fmnc) == zeros(2)
228+
229+
fmnc = zerocorr!(LMM(@formula(reaction ~ 1 + days + (1+days|subj)), slp));
224230
@test size(fmnc) == (180,2,36,1)
225231
@test fmnc.θ == ones(2)
226232
@test lowerbd(fmnc) == zeros(2)

0 commit comments

Comments
 (0)