Skip to content

Commit

Permalink
replace model frame member with fixef coefnames (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
kleinschmidt authored and dmbates committed Apr 5, 2017
1 parent 979ae6e commit ec01fdf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/mixedmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function StatsBase.coeftable(m::MixedModel)
z = fe ./ se
pvalue = ccdf(Chisq(1), abs2.(z))
CoefTable(hcat(fe, se, z, pvalue), ["Estimate", "Std.Error", "z value", "P(>|z|)"],
coefnames(lmm(m).mf), 4)
lmm(m).fixefnames, 4)
end

"""
Expand Down
10 changes: 5 additions & 5 deletions src/pls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Linear mixed-effects model representation
# Members
* `formula`: the formula for the model
* `mf`: the model frame, mostly used to get the `terms` component for labelling fixed effects
* `fixefnames`: names of the fixed effects (for displaying coefficients)
* `wttrms`: a length `nt` vector of weighted model matrices. The last two elements are `X` and `y`.
* `trms`: a vector of unweighted model matrices. If `isempty(sqrtwts)` the same object as `wttrms`
* `Λ`: a length `nt - 2` vector of lower triangular matrices
Expand All @@ -71,7 +71,7 @@ Linear mixed-effects model representation
"""
type LinearMixedModel{T <: AbstractFloat} <: MixedModel
formula::Formula
mf::ModelFrame
fixefnames::Vector{String}
wttrms::Vector
trms::Vector
sqrtwts::Diagonal{T}
Expand Down Expand Up @@ -122,7 +122,7 @@ function densify(S::SparseMatrixCSC, threshold::Real = 0.3)
end
densify(A::AbstractMatrix, threshold::Real = 0.3) = A

function LinearMixedModel(f, mf, trms, Λ, wts)
function LinearMixedModel(f, fixefnames, trms, Λ, wts)
n = size(trms[1], 1)
T = eltype(trms[end])
sqrtwts = Diagonal([sqrt(x) for x in wts])
Expand All @@ -149,7 +149,7 @@ function LinearMixedModel(f, mf, trms, Λ, wts)
optsum = OptSummary(mapreduce(getθ, vcat, Λ), mapreduce(lowerbd, vcat, Λ), :LN_BOBYQA;
ftol_rel = 1.0e-12, ftol_abs = 1.0e-8)
fill!(optsum.xtol_abs, 1.0e-10)
LinearMixedModel(f, mf, wttrms, trms, sqrtwts, Λ, A, R, optsum)
LinearMixedModel(f, fixefnames, wttrms, trms, sqrtwts, Λ, A, R, optsum)
end

"""
Expand All @@ -176,7 +176,7 @@ function lmm(f::Formula, fr::AbstractDataFrame; weights::Vector = [])
Λ = LowerTriangular{T, Matrix{T}}[LT(t) for t in trms]
push!(trms, X.m)
push!(trms, reshape(convert(Vector{T}, DataFrames.model_response(mf)), (size(X, 1), 1)))
LinearMixedModel(f, mf, trms, Λ, convert(Vector{T}, weights))
LinearMixedModel(f, coefnames(mf), trms, Λ, convert(Vector{T}, weights))
end

function cfactor!(m::LinearMixedModel)
Expand Down

0 comments on commit ec01fdf

Please sign in to comment.