From df4d33242e34574847132b23f917352a4750272b Mon Sep 17 00:00:00 2001 From: Douglas Bates Date: Thu, 26 Oct 2017 15:49:14 -0500 Subject: [PATCH] Begin modifications for beta profiles --- src/MixedModels.jl | 1 + src/modelterms.jl | 6 ++++++ src/profile.jl | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 src/profile.jl diff --git a/src/MixedModels.jl b/src/MixedModels.jl index e34a58007..0ba3b4ced 100644 --- a/src/MixedModels.jl +++ b/src/MixedModels.jl @@ -87,5 +87,6 @@ include("pls.jl") include("simulate.jl") include("PIRLS.jl") include("mixedmodel.jl") +include("profile.jl") end # module diff --git a/src/modelterms.jl b/src/modelterms.jl index a867f7b7c..85a3469a2 100644 --- a/src/modelterms.jl +++ b/src/modelterms.jl @@ -30,6 +30,12 @@ function reweight!(A::MatrixTerm{T}, sqrtwts::Vector{T}) where T A end +function dropcolumn(A::MatrixTerm, i::Integer) + n, p = size(A) + inds = deleteat!(collect(1:p), i) + MatrixTerm(A.x[:, inds], A.cnames[inds]) +end + eltype(A::MatrixTerm) = eltype(A.wtx) Base.size(A::MatrixTerm) = size(A.wtx) diff --git a/src/profile.jl b/src/profile.jl new file mode 100644 index 000000000..ad6404fc7 --- /dev/null +++ b/src/profile.jl @@ -0,0 +1,20 @@ +""" + dropXcolumn!(m::LinearMixedModel, i::Integer) + +Return `m` with column `i` of the fixed-effects model matrix, `X`, dropped + +This operation changes dimensions of some blocks in `m.A` and `m.L` +FIXME: It looks as if A and L need to be generated anew. +""" +function dropXcolumn!(m::LinearMixedModel, i::Integer) + trms = m.trms + xpos = length(trms) - 1 + xtrm = trms[xpos] = reweight!(dropcolumn(trms[xpos], i), m.sqrtwts) + for j in 1:xpos + Axj = m.A[Block(xpos, j)] = xtrm'trms[j] + m.L[Block(xpos, j)] = deepcopy(Axj) + end + Axp1x = m.A[Block(xpos + 1, xpos)] = trms[xpos + 1]'xtrm + m.L[Block(xpos + 1, xpos)] = deepcopy(Axp1x) + m +end