Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
PharmCat committed Mar 18, 2023
1 parent 45f1e6c commit 4d50073
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/src/examples.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Example 1 - Continuous and categorical predictors

```@example lmmexample
using Metida, CSV, DataFrames, MixedModels, CategoricalArrays;
using Metida, CSV, DataFrames, CategoricalArrays;
import Pkg
Pkg.activate("MixedModels")
Expand Down
10 changes: 10 additions & 0 deletions src/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ function rand!(rng::AbstractRNG, v::AbstractVector, lmm::LMM)
if !lmm.result.fit error("Model not fitted!") end
rand!(rng, v, lmm, lmm.result.theta, lmm.result.beta)
end
"""
rand!(v::AbstractVector, lmm::LMM) = rand!(default_rng(), v, lmm, lmm.result.theta, lmm.result.beta)
Generate random responce vector for fitted 'lmm' model, store results in `v`.
"""
rand!(v::AbstractVector, lmm::LMM) = rand!(default_rng(), v, lmm, lmm.result.theta, lmm.result.beta)
"""
rand(rng::AbstractRNG, lmm::LMM{T}; theta) where T
Expand All @@ -22,6 +27,11 @@ function rand(rng::AbstractRNG, lmm::LMM{T}, theta::AbstractVector) where T
v = Vector{T}(undef, nobs(lmm))
rand!(rng, v, lmm, theta)
end
"""
rand!(rng::AbstractRNG, lmm::LMM{T}; theta) where T
Generate random responce vector 'lmm' model, theta covariance vector, and zero means, store results in `v`.
"""
function rand!(rng::AbstractRNG, v::AbstractVector, lmm::LMM{T}, theta::AbstractVector) where T
n = length(lmm.covstr.vcovblock)
if length(v) != nobs(lmm) error("Wrong v length!") end
Expand Down

0 comments on commit 4d50073

Please sign in to comment.