Skip to content

Commit

Permalink
types
Browse files Browse the repository at this point in the history
  • Loading branch information
PharmCat committed Jan 19, 2024
1 parent ff49c81 commit 66cd0aa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/reml.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ function reml_sweep_β(lmm, data, θ::Vector{T}; maxthreads::Int = 16) where T #
logdetθ₂ = logdet(rθs₂)
=#
β .= NaN
return Inf, β, Inf, Inf, false
θ₂ .= NaN
return Inf, β, θs₂, Inf, false

Check warning on line 128 in src/reml.jl

View check run for this annotation

Codecov / codecov/patch

src/reml.jl#L127-L128

Added lines #L127 - L128 were not covered by tests
end
# θ₃
#@inbounds @simd for i = 1:n
Expand Down Expand Up @@ -184,7 +185,8 @@ function reml_sweep_β_nlopt(lmm, data, θ::Vector{T}; maxthreads::Int = 16) whe
noerror = all(erroracc)
if !noerror
β = fill(NaN, lmm.rankx)
return Inf, β, Inf, Inf, false
θ₂ .= NaN
return Inf, β, θ₂, Inf, false
end
θ₁ = sum(accθ₁)
θ₂tc = sum(accθ₂)
Expand All @@ -194,7 +196,8 @@ function reml_sweep_β_nlopt(lmm, data, θ::Vector{T}; maxthreads::Int = 16) whe
ldθ₂, info = LinearAlgebra.LAPACK.potrf!('U', θ₂tc)
if info != 0
β = fill(NaN, lmm.rankx)
return Inf, β, Inf, Inf, false
θ₂ .= NaN
return Inf, β, θ₂, Inf, false

Check warning on line 200 in src/reml.jl

View check run for this annotation

Codecov / codecov/patch

src/reml.jl#L199-L200

Added lines #L199 - L200 were not covered by tests
end
LinearAlgebra.LAPACK.potrs!('U', θ₂tc, βtc)
β = βtc
Expand Down
8 changes: 4 additions & 4 deletions src/vartypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ struct ZERO <: AbstractCovarianceType end
Make covariance type with AbstractCovmatMethod.
"""
struct CovarianceType
s::AbstractCovarianceType
struct CovarianceType{T <: AbstractCovarianceType}
s::T
z::Bool
function CovarianceType(s::AbstractCovarianceType, z::Bool)
new(s, z)
function CovarianceType(s::T, z::Bool) where T <: AbstractCovarianceType
new{T}(s, z)
end
function CovarianceType(s::AbstractCovarianceType)
CovarianceType(s, true)
Expand Down
4 changes: 3 additions & 1 deletion test/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ include("testdata.jl")
random = Metida.VarEffect(Metida.@covstr(formulation|nosubj), Metida.DIAG),
)
Metida.fit!(lmm)
@test Metida.m2logreml(lmm) 25.129480634331067 atol=1E-6
@test Metida.m2logreml(lmm, ) 25.129480634331067 atol=1E-6
# Test -2 reml for provided theta
@test Metida.m2logreml(lmm, Metida.theta(lmm)) 25.129480634331067 atol=1E-6

# Casuistic case - random
lmm = Metida.LMM(@formula(var~sequence+period+formulation), df0;
Expand Down

0 comments on commit 66cd0aa

Please sign in to comment.