Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
PharmCat committed Jan 10, 2021
1 parent 41eab05 commit b979ca6
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Metida"
uuid = "a1dec852-9fe5-11e9-361f-8d9fde67cfa2"
authors = ["Vladimir Arnautov <[email protected]>"]
version = "0.1.10"
version = "0.1.11"

[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Expand Down
2 changes: 2 additions & 0 deletions src/Metida.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ function _precompile_()
precompile(Tuple{typeof(Metida.ffxpone), Int64})

precompile(Tuple{typeof(Metida.reml_sweep_β), Metida.LMM{Float64}, Array{Float64, 1}})
precompile(Tuple{typeof(Metida.reml_sweep_β3), Metida.LMM{Float64}, Array{Float64, 1}})

precompile(Tuple{typeof(Metida.rholinkpsigmoid), Float64})

precompile(Tuple{typeof(Metida.varlinkvecapply!), Array{Float64, 1}, Array{Function, 1}})
Expand Down
3 changes: 1 addition & 2 deletions src/fit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ function fit!(lmm::LMM{T}; verbose::Symbol = :auto, varlinkf = :exp, rholinkf =
grf(x) = optfunc(lmm, x)[1]
ai = ForwardDiff.hessian(aif, θ)
gr = ForwardDiff.gradient(grf, θ)
#println("vec: ", θ)
try
θ .-= (inv(ai) ./4 )*gr
catch
Expand All @@ -73,7 +72,7 @@ function fit!(lmm::LMM{T}; verbose::Symbol = :auto, varlinkf = :exp, rholinkf =
if θ[i] > initθ*1.25 θ[i] = initθ*1.25 end
end
end
push!(lmm.log, "First step with AI like method, θ: "*string(θ))
push!(lmm.log, "First step with AI-like method, θ: "*string(θ))
end
#println("new: ", θ)
#varlinkvecapply!(θ, fvr)
Expand Down
2 changes: 1 addition & 1 deletion src/reml.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function reml_sweep_β2(lmm::LMM{T2}, @nospecialize θ::Vector{T}) where T <: Nu
Vpv .= Vi
Vx = view(Vp, 1:q, q+1:q+lmm.rankx)
#Vxt = view(Vp, N+1:qswm, 1:N)
Vx .= view(lmm.data.xv, lmm.data.block[i],:)
Vx .= view(lmm.data.xv, lmm.data.block[i], :)

sweep!(Vp, 1:q)
V⁻¹[i] = Symmetric(utriaply!(x -> -x, Vpv))
Expand Down
3 changes: 2 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ function intersectdf(df, s)::Vector
end
for i2 = 1:size(u, 1)
for i = 1:length(s)
v2[i] = sort!(v[i][u[i2, i]])
v2[i] = v[i][u[i2, i]]
end
res[i2] = collect(intersect(Set.(v2)...))
#res[i2] = intersect(v2...)
sort!(res[i2])
end
res
end
Expand Down
1 change: 0 additions & 1 deletion src/varstruct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ struct CovStructure{T} <: AbstractCovarianceStructure
end
end
view(rcnames, tr[end]) .= rcoefnames(schema[end], t[end], Val{repeated.covtype.s}())

for i = 1:length(blocks)
sblock[i] = Vector{Vector{Vector{UInt32}}}(undef, alleffl)
for s = 1:alleffl
Expand Down
6 changes: 3 additions & 3 deletions test/ar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ transform!(df, :Day => categorical, renamecols=false)
subject = :Time
)
Metida.fit!(lmm)
@test lmm.result.reml 451.06614967014093 atol=1E-6
@test lmm.result.reml 453.3395435627574 atol=1E-6

lmm = Metida.LMM(@formula(Pulse~1), df;
repeated = Metida.VarEffect(Metida.@covstr(1), Metida.AR),
subject = :Time
)
Metida.fit!(lmm)
@test lmm.result.reml 463.9964183016498 atol=1E-6
@test lmm.result.reml 471.85107712169827 atol=1E-6
end

#=
Expand All @@ -44,7 +44,7 @@ transform!(df, :Diet => categorical, renamecols=false)
subject = :Chick
)
Metida.fit!(lmm)
@test lmm.result.reml 5451.857613990478 atol=1E-6
@test lmm.result.reml 4439.254893054906 atol=1E-6

lmm = Metida.LMM(@formula(weight~1 + Diet & Time), df;
random = Metida.VarEffect(Metida.@covstr(Diet), Metida.ARH),
Expand Down

0 comments on commit b979ca6

Please sign in to comment.