Skip to content

Commit

Permalink
Merge branch 'main' into db/RegressionTests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmbates committed Jun 22, 2024
2 parents da3647c + ce5b604 commit 45918c0
Show file tree
Hide file tree
Showing 22 changed files with 67 additions and 42 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
4 changes: 2 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: "1"
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- name: Benchmark run
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/current.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
- macOS-14 # apple silicon!
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
with:
cache-compiled: "true"
- uses: julia-actions/julia-buildpkg@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/documenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: 1.8
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
with:
cache-compiled: "true"
- uses: julia-actions/julia-buildpkg@latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/minimum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
os: [ubuntu-22.04, macos-11, windows-2019]
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
with:
cache-compiled: "true"
- uses: julia-actions/julia-buildpkg@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
with:
cache-compiled: true
- uses: julia-actions/julia-runtest@v1
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
MixedModels v4.24.1 Release Notes
==============================
Add type notations in `pwrss(::LinearMixedModel)` and `logdet(::LinearMixedModel)` to enhance type inference. [#773]

MixedModels v4.24.0 Release Notes
==============================
* Properties for `GeneralizedLinearMixedModel` now default to delegation to the internal weighted `LinearMixedModel` when that property is not explicitly handled by `GeneralizedLinearMixedModel`. Previously, properties were delegated on an explicit basis, which meant that they had to be added manually as use cases were discovered. The downside to the new approach is that it is now possible to access properties whose definition in the LMM case doesn't match the GLMM definition when the GLMM definition hasn't been explicitly been implemented. [#767]

MixedModels v4.23.1 Release Notes
==============================
* Fix for `simulate!` when only the estimable coefficients for a rank-deficient model are provided. [#756]
Expand Down Expand Up @@ -516,3 +524,5 @@ Package dependencies
[#748]: https://github.com/JuliaStats/MixedModels.jl/issues/748
[#755]: https://github.com/JuliaStats/MixedModels.jl/issues/755
[#756]: https://github.com/JuliaStats/MixedModels.jl/issues/756
[#767]: https://github.com/JuliaStats/MixedModels.jl/issues/767
[#773]: https://github.com/JuliaStats/MixedModels.jl/issues/773
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MixedModels"
uuid = "ff71e718-51f3-5ec2-a782-8ffcbfa3c316"
author = ["Phillip Alday <[email protected]>", "Douglas Bates <[email protected]>", "Jose Bayoan Santiago Calderon <[email protected]>"]
version = "4.23.1"
version = "4.24.1"

[deps]
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
Expand Down
9 changes: 8 additions & 1 deletion docs/src/bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,20 @@ For computers with many processors (as opposed to a single processor with severa

```@example Main
using Distributed
using ProgressMeter
# you already have 1 proc by default, so add the number of additional cores with `addprocs`
# you need at least as many RNGs as cores you want to use in parallel
# but you shouldn't use all of your cores because nested within this
# is the multithreading of the linear algebra
# addprocs(1)
@info "Currently using $(nprocs()) processors total and $(nworkers()) for work"
# Load the necessary packages on all workers
# For clusters, you will also need to make sure that the Julia
# environment (Project.toml) is set up and activated on each worker.
@everywhere begin
using ProgressMeter
using MixedModels
end
# copy everything to workers
@showprogress for w in workers()
remotecall_fetch(() -> coefnames(m2), w)
Expand Down
11 changes: 6 additions & 5 deletions src/MixedModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using BSplineKit: BSplineKit, BSplineOrder, Natural, Derivative, SplineInterpola
using BSplineKit: interpolate
using DataAPI: DataAPI, levels, refpool, refarray, refvalue
using Distributions: Distributions, Bernoulli, Binomial, Chisq, Distribution, Gamma
using Distributions: InverseGaussian, Normal, Poisson, ccdf, estimate
using Distributions: InverseGaussian, Normal, Poisson, ccdf
using GLM: GLM, GeneralizedLinearModel, IdentityLink, InverseLink, LinearModel
using GLM: Link, LogLink, LogitLink, ProbitLink, SqrtLink
using GLM: canonicallink, glm, linkinv, dispersion, dispersion_parameter
Expand All @@ -16,10 +16,10 @@ using LinearAlgebra: Diagonal, Hermitian, HermOrSym, I, LAPACK, LowerTriangular
using LinearAlgebra: PosDefException, SVD, SymTridiagonal, Symmetric
using LinearAlgebra: UpperTriangular, cond, diag, diagind, dot, eigen, isdiag
using LinearAlgebra: ldiv!, lmul!, logdet, mul!, norm, normalize, normalize!, qr
using LinearAlgebra: rank, rdiv!, rmul!, svd, tr, tril!
using LinearAlgebra: rank, rdiv!, rmul!, svd, tril!
using Markdown: Markdown
using MixedModelsDatasets: dataset, datasets
using NLopt: NLopt, Opt, ftol_abs, ftol_rel, initial_step, maxtime, xtol_abs, xtol_rel
using NLopt: NLopt, Opt, ftol_abs, ftol_rel, initial_step, xtol_abs, xtol_rel
using PooledArrays: PooledArrays, PooledArray
using PrecompileTools: PrecompileTools, @setup_workload, @compile_workload
using ProgressMeter: ProgressMeter, Progress, ProgressUnknown, finish!, next!
Expand All @@ -38,9 +38,9 @@ using StatsModels: StatsModels, AbstractContrasts, AbstractTerm, CategoricalTerm
using StatsModels: ConstantTerm, DummyCoding, EffectsCoding, FormulaTerm, FunctionTerm
using StatsModels: HelmertCoding, HypothesisCoding, InteractionTerm, InterceptTerm
using StatsModels: MatrixTerm, SeqDiffCoding, TableRegressionModel, Term
using StatsModels: apply_schema, drop_term, formula, modelcols, term, @formula
using StatsModels: apply_schema, drop_term, formula, lrtest, modelcols, term, @formula
using StructTypes: StructTypes
using Tables: Tables, columntable, rows
using Tables: Tables, columntable
using TypedTables: TypedTables, DictTable, FlexTable, Table

export @formula,
Expand Down Expand Up @@ -114,6 +114,7 @@ export @formula,
logdet,
loglikelihood,
lowerbd,
lrtest,
meanresponse,
modelmatrix,
model_response,
Expand Down
12 changes: 6 additions & 6 deletions src/generalizedlinearmixedmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ function GeneralizedLinearMixedModel(
tbl,
d::Distribution,
l::Type;
kwargs...
kwargs...,
)
throw(ArgumentError("Expected a Link instance (`$l()`), got a type (`$l`)."))
end
Expand All @@ -376,7 +376,7 @@ function GeneralizedLinearMixedModel(
tbl::Tables.ColumnTable,
d::Normal,
l::IdentityLink;
kwargs...
kwargs...,
)
return throw(
ArgumentError("use LinearMixedModel for Normal distribution with IdentityLink")
Expand Down Expand Up @@ -489,12 +489,12 @@ function Base.getproperty(m::GeneralizedLinearMixedModel, s::Symbol)
σs(m)
elseif s == :σρs
σρs(m)
elseif s (:A, :L, :optsum, :reterms, :Xymat, :feterm, :formula, :parmap)
getfield(m.LMM, s)
elseif s (:dims, , :lowerbd, :corr, :PCA, :rePCA, :X)
getproperty(m.LMM, s)
elseif s == :y
m.resp.y
elseif !hasfield(GeneralizedLinearMixedModel, s) && s propertynames(m.LMM, true)
# automatically delegate as much as possible to the internal local linear approximation
# NB: the !hasfield call has to be first since we're calling getproperty() with m.LMM...
getproperty(m.LMM, s)
else
getfield(m, s)
end
Expand Down
2 changes: 1 addition & 1 deletion src/likelihoodratiotest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ function _iscomparable(m::LinearMixedModel...)
if any(getproperty.(getproperty.(m, :optsum), :REML))
isconstant(coefnames.(m)) || throw(
ArgumentError(
"Likelihood-ratio tests for REML-fitted models are only valid when the fixed-effects specifications are identical",
"Likelihood-ratio tests for REML-fitted models are only valid when the fixed-effects specifications are identical"
),
)
end
Expand Down
6 changes: 3 additions & 3 deletions src/linalg/logdet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ lower Cholesky factor.
"""
function LinearAlgebra.logdet(m::LinearMixedModel{T}) where {T}
L = m.L
@inbounds s = sum(j -> LD(L[kp1choose2(j)]), axes(m.reterms, 1))
@inbounds s = sum(j -> LD(L[kp1choose2(j)])::T, axes(m.reterms, 1))
if m.optsum.REML
lastL = last(L)
lastL = last(L)::Matrix{T}
s += LD(lastL) # this includes the log of sqrtpwrss
s -= log(last(lastL)) # so we need to subtract it from the sum
end
return s + s # multiply by 2 b/c the desired det is of the symmetric mat, not the factor
return (s + s)::T # multiply by 2 b/c the desired det is of the symmetric mat, not the factor
end
2 changes: 1 addition & 1 deletion src/linalg/rankUpdate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function rankUpdate! end

function rankUpdate!(C::AbstractMatrix, a::AbstractArray, α, β)
return error(
"We haven't implemented a method for $(typeof(C)), $(typeof(a)). Please file an issue on GitHub.",
"We haven't implemented a method for $(typeof(C)), $(typeof(a)). Please file an issue on GitHub."
)
end

Expand Down
10 changes: 5 additions & 5 deletions src/linearmixedmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function LinearMixedModel(
end

const _MISSING_RE_ERROR = ArgumentError(
"Formula contains no random effects; this isn't a mixed model. Perhaps you want to use GLM.jl?",
"Formula contains no random effects; this isn't a mixed model. Perhaps you want to use GLM.jl?"
)

function LinearMixedModel(
Expand All @@ -62,7 +62,7 @@ function LinearMixedModel(
fvars tvars ||
throw(
ArgumentError(
"The following formula variables are not present in the table: $(setdiff(fvars, tvars))",
"The following formula variables are not present in the table: $(setdiff(fvars, tvars))"
),
)

Expand Down Expand Up @@ -226,7 +226,7 @@ end
function _offseterr()
return throw(
ArgumentError(
"Offsets are not supported in linear models. You can simply shift the response by the offset.",
"Offsets are not supported in linear models. You can simply shift the response by the offset."
),
)
end
Expand Down Expand Up @@ -372,7 +372,7 @@ function StatsBase.confint(m::MixedModel{T}; level=0.95) where {T}
return DictTable(;
coef=coefnames(m),
lower=β .- cutoff .* std,
upper=β .+ cutoff .* std
upper=β .+ cutoff .* std,
)
end

Expand Down Expand Up @@ -895,7 +895,7 @@ end
The penalized, weighted residual sum-of-squares.
"""
pwrss(m::LinearMixedModel) = abs2(last(last(m.L)))
pwrss(m::LinearMixedModel{T}) where {T} = abs2(last(last(m.L)::Matrix{T}))

"""
ranef!(v::Vector{Matrix{T}}, m::MixedModel{T}, β, uscale::Bool) where {T}
Expand Down
4 changes: 2 additions & 2 deletions src/mixedmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function StatsAPI.fit(
tbl,
d::Type,
args...;
kwargs...
kwargs...,
)
throw(ArgumentError("Expected a Distribution instance (`$d()`), got a type (`$d`)."))
end
Expand All @@ -91,7 +91,7 @@ function StatsAPI.fit(
tbl,
d::Distribution,
l::Type;
kwargs...
kwargs...,
)
throw(ArgumentError("Expected a Link instance (`$l()`), got a type (`$l`)."))
end
Expand Down
2 changes: 1 addition & 1 deletion src/predict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function _predict(m::MixedModel{T}, newdata, β; new_re_levels) where {T}
any(any(ismissing, Tables.getcolumn(newdata, col)) for col in respvars)
throw(
ArgumentError(
"Response column must be initialized to a non-missing numeric value.",
"Response column must be initialized to a non-missing numeric value."
),
)
end
Expand Down
2 changes: 1 addition & 1 deletion src/profile/thetapr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function optsumj(os::OptSummary, j::Integer)
return OptSummary(
deleteat!(copy(os.final), j),
deleteat!(copy(os.lowerbd), j),
os.optimizer
os.optimizer,
)
end

Expand Down
2 changes: 1 addition & 1 deletion src/randomeffectsterm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function StatsModels.apply_schema(
if !(typeof(first) <: CategoricalTerm)
throw(
ArgumentError(
"nesting terms requires categorical grouping term, got $first. Manually specify $first as `CategoricalTerm` in hints/contrasts",
"nesting terms requires categorical grouping term, got $first. Manually specify $first as `CategoricalTerm` in hints/contrasts"
),
)
end
Expand Down
4 changes: 2 additions & 2 deletions src/remat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ end
function copyscaleinflate!(
Ljj::UniformBlockDiagonal{T},
Ajj::UniformBlockDiagonal{T},
Λj::ReMat{T,S}
Λj::ReMat{T,S},
) where {T,S}
λ = Λj.λ
dind = diagind(S, S)
Expand All @@ -604,7 +604,7 @@ end
function copyscaleinflate!(
Ljj::Matrix{T},
Ajj::UniformBlockDiagonal{T},
Λj::ReMat{T,S}
Λj::ReMat{T,S},
) where {T,S}
copyto!(Ljj, Ajj)
n = LinearAlgebra.checksquare(Ljj)
Expand Down
2 changes: 1 addition & 1 deletion src/simulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function _simulate!(
ismissing(σ) ||
throw(
ArgumentError(
"You must not specify a dispersion parameter for model families without a dispersion parameter",
"You must not specify a dispersion parameter for model families without a dispersion parameter"
),
)

Expand Down
2 changes: 1 addition & 1 deletion src/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function replicate(
)
use_threads && Base.depwarn(
"use_threads is deprecated and will be removed in a future release",
:replicate
:replicate,
)
if !isnothing(hide_progress)
Base.depwarn(
Expand Down

0 comments on commit 45918c0

Please sign in to comment.