From 63c32db95beb7fc1d3143d39bcd41cf89c2ad9f4 Mon Sep 17 00:00:00 2001 From: Phillip Alday Date: Tue, 2 Mar 2021 12:24:16 +0000 Subject: [PATCH] doc hints --- src/Xymat.jl | 13 ++++++++++++- src/linearmixedmodel.jl | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Xymat.jl b/src/Xymat.jl index 71a4e3e6a..e198ae819 100644 --- a/src/Xymat.jl +++ b/src/Xymat.jl @@ -3,6 +3,11 @@ Term with an explicit, constant matrix representation +Typically, an `FeTerm` represents the model matrix for the fixed effects. + +!!! note + `FeTerm` is not the same as [`FeMat`](@ref)! + # Fields * `x`: full model matrix * `piv`: pivot `Vector{Int}` for moving linearly dependent columns to the right @@ -79,6 +84,12 @@ isfullrank(A::FeTerm) = A.rank == length(A.piv) A matrix and a (possibly) weighted copy of itself. + +Typically, an `FeMat` represents the fixed-effects model matrix with the response (`y`) concatenated as a final column. + +!!! note + `FeMat` is not the same as [`FeTerm`](@ref). + # Fields - `xy`: original matrix, called `xy` b/c in practice this is `hcat(fullrank(X), y)` - `wtxy`: (possibly) weighted copy of `xy` (shares storage with `xy` until weights are applied) @@ -101,7 +112,7 @@ Base.eltype(::FeMat{T}) where {T} = T Base.getindex(A::FeMat, i, j) = getindex(A.xy, i, j) -Base.length(A::FeMat) = length(A.wtxy) +Base.length(A::FeMat) = length(A.xy) function *(adjA::Adjoint{T,<:FeMat{T}}, B::FeMat{T}) where {T} adjoint(adjA.parent.wtxy) * B.wtxy diff --git a/src/linearmixedmodel.jl b/src/linearmixedmodel.jl index e4763f92e..56d99e9b7 100644 --- a/src/linearmixedmodel.jl +++ b/src/linearmixedmodel.jl @@ -8,7 +8,7 @@ Linear mixed-effects model representation * `formula`: the formula for the model * `reterms`: a `Vector{AbstractReMat{T}}` of random-effects terms. * `Xymat`: horizontal concatenation of a full-rank fixed-effects model matrix `X` and response `y` as an `FeMat{T}` -* `feterm`: the fixed-effects model matrix as an `FeMat{T}` +* `feterm`: the fixed-effects model matrix as an `FeTerm{T}` * `sqrtwts`: vector of square roots of the case weights. Can be empty. * `parmap` : Vector{NTuple{3,Int}} of (block, row, column) mapping of θ to λ * `dims` : NamedTuple{(:n, :p, :nretrms),NTuple{3,Int}} of dimensions. `p` is the rank of `X`, which may be smaller than `size(X, 2)`. @@ -295,6 +295,7 @@ function pushALblock!(A, L, blk) push!(L, blk) push!(A, deepcopy(isa(blk, BlockedSparse) ? blk.cscmat : blk)) end + function createAL(reterms::Vector{AbstractReMat{T}}, Xy::FeMat{T}) where {T} k = length(reterms) vlen = kchoose2(k+1)