Skip to content

Commit

Permalink
Begin modifications for beta profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
dmbates committed Oct 26, 2017
1 parent 5f9f555 commit df4d332
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/MixedModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,6 @@ include("pls.jl")
include("simulate.jl")
include("PIRLS.jl")
include("mixedmodel.jl")
include("profile.jl")

end # module
6 changes: 6 additions & 0 deletions src/modelterms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions src/profile.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit df4d332

Please sign in to comment.