Skip to content

Commit 7f0f5a2

Browse files
committed
edit docstrings and docs
1 parent 6d3abdd commit 7f0f5a2

File tree

3 files changed

+39
-13
lines changed

3 files changed

+39
-13
lines changed

docs/src/examples.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ model = MRVCModel(Y_miss, X, V; se = false)
9494
```
9595

9696
# Special case: ``m = 2``
97-
When there are __two__ variance components, you can accelerate fitting by avoiding large matrix inversion per iteration. To illustrate this, you can first simulate data as we did previously but with larger ``n \cdot d`` and ``m = 2``.
97+
When there are __two__ variance components, you can accelerate fitting by avoiding large matrix inversion per iteration. To illustrate this, you can first simulate data as done previously but with larger ``nd`` and ``m = 2``.
9898
```@repl 1
9999
function simulate(n, d, p, m)
100100
X = rand(n, p)

src/MultiResponseVarianceComponentModels.jl

+32-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
`MRVCModels.jl` permits maximum likelihood (ML) and residual maximum likelihood (REML) estimation
3-
as well as inference for multivariate response variance components linear mixed models.
2+
`MRVCModels.jl` permits maximum likelihood (ML) or residual maximum likelihood (REML) estimation
3+
and inference for multivariate response variance components linear mixed models.
44
"""
55
module MultiResponseVarianceComponentModels
66

@@ -109,21 +109,20 @@ end
109109
X::Union{Nothing, AbstractVecOrMat},
110110
V::Union{AbstractMatrix, Vector{<:AbstractMatrix}}
111111
)
112-
MRTVCModel(
113-
Y::AbstractVecOrMat,
114-
X::Union{Nothing, AbstractVecOrMat},
115-
V::Vector{<:AbstractMatrix}
116-
)
117112
118-
Create a new `MRVCModel` or `MRTVCModel` instance from response matrix `Y`,
119-
predictor matrix `X`, and kernel matrices `V`. For `MRTVCModel` instance,
120-
the number of variance components must be two.
113+
Create a new `MRVCModel` instance from response matrix `Y`, predictor matrix `X`,
114+
and kernel matrices `V`.
121115
122116
# Keyword arguments
123117
```
124118
se::Bool calculate standard errors; default true
125119
reml::Bool pursue REML estimation instead of ML estimation; default false
126120
```
121+
122+
# Extended help
123+
When there are two variance components, computation in each iteration can be
124+
reduced, which is attained with `MRTVCModel` instance. `MRVCModel` is more general.
125+
For `MRTVCModel`, the number of variance components must be two.
127126
"""
128127
function MRVCModel(
129128
Y :: Union{AbstractMatrix{T}, AbstractMatrix{Union{Missing, T}}},
@@ -350,6 +349,22 @@ struct MRTVCModel{T <: BlasReal} <: VCModel
350349
reml :: Bool
351350
end
352351

352+
"""
353+
MRTVCModel(
354+
Y::AbstractVecOrMat,
355+
X::Union{Nothing, AbstractVecOrMat},
356+
V::Vector{<:AbstractMatrix}
357+
)
358+
359+
Create a new `MRTVCModel` instance from response matrix `Y`, predictor matrix `X`,
360+
and kernel matrices `V`. The number of variance components must be two.
361+
362+
# Keyword arguments
363+
```
364+
se::Bool calculate standard errors; default true
365+
reml::Bool pursue REML estimation instead of ML estimation; default false
366+
```
367+
"""
353368
function MRTVCModel(
354369
Y :: AbstractMatrix{T},
355370
X :: Union{Nothing, AbstractMatrix{T}},
@@ -472,10 +487,16 @@ function Base.show(io::IO, model::VCModel)
472487
else
473488
n, d, p, m = size(model.Y, 1), size(model.Y, 2), size(model.X, 2), length(model.V)
474489
end
475-
if d == 1
490+
if d == 1 && model isa MRTVCModel
491+
printstyled(io, "A univariate response two variance component model\n"; underline = true)
492+
elseif d == 1
476493
printstyled(io, "A univariate response variance component model\n"; underline = true)
494+
elseif d == 2 && model isa MRTVCModel
495+
printstyled(io, "A bivariate response two variance component model\n"; underline = true)
477496
elseif d == 2
478497
printstyled(io, "A bivariate response variance component model\n"; underline = true)
498+
elseif model isa MRTVCModel
499+
printstyled(io, "A multivariate response two variance component model\n"; underline = true)
479500
else
480501
printstyled(io, "A multivariate response variance component model\n"; underline = true)
481502
end

src/fit.jl

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ reltol::Real relative tolerance for convergence; default 1e-6
1111
verbose::Bool display algorithmic information; default true
1212
init::Symbol initialization strategy; :default initializes by least squares, while
1313
:user uses user-supplied values at model.B and model.Σ
14-
algo::Symbol optimization algorithm; :MM (default) or EM (for MRVCModel)
14+
algo::Symbol optimization algorithm; :MM (default) or :EM (for MRVCModel)
1515
log::Bool record iterate history or not; default false
1616
```
17+
18+
# Extended help
19+
MM algorithm is provably faster than EM algorithm in this setting, so recommend trying
20+
MM algorithm first, which is default, and switching to EM algorithm if there are
21+
convergence issues.
1722
"""
1823
function fit!(
1924
model :: MRVCModel{T};

0 commit comments

Comments
 (0)