From 8833bb0b7383ec2214755b1f3708635e81015335 Mon Sep 17 00:00:00 2001 From: PharmCat Date: Thu, 22 Aug 2024 14:48:09 +0300 Subject: [PATCH] cosmetics --- src/gmat.jl | 31 +++++++++---------- src/linearalgebra.jl | 14 ++++----- src/reml.jl | 6 ++-- src/rmat.jl | 36 +++++++++++----------- src/statsbase.jl | 22 +++++++------- src/sweep.jl | 8 ++--- src/typeiii.jl | 2 +- src/utils.jl | 71 ++++++++++++++++++++++---------------------- src/varstruct.jl | 14 ++++----- src/vartypes.jl | 4 +-- 10 files changed, 104 insertions(+), 104 deletions(-) diff --git a/src/gmat.jl b/src/gmat.jl index 452cf9f..d4b0418 100644 --- a/src/gmat.jl +++ b/src/gmat.jl @@ -9,7 +9,7 @@ gmat!(gt[r].data, view(θ, covstr.tr[r]), covstr.random[r].covtype.s) end end - gt + return gt end # Main @noinline function zgz_base_inc!(mx::AbstractArray, G, covstr, bi) @@ -23,7 +23,7 @@ end end end end - mx + return mx end ################################################################################ ################################################################################ @@ -32,7 +32,7 @@ function gmat!(::Any, ::Any, ::AbstractCovarianceType) error("No gmat! method defined for thit structure!") end function gmat!(mx, ::Any, ::ZERO) - mx + return mx end #SI Base.@propagate_inbounds function gmat!(mx, θ, ::SI_) @@ -40,14 +40,14 @@ Base.@propagate_inbounds function gmat!(mx, θ, ::SI_) @inbounds @simd for i = 1:size(mx, 1) mx[i, i] = val end - mx + return mx end #DIAG function gmat!(mx, θ, ::DIAG_) @inbounds @simd for i = 1:size(mx, 1) mx[i, i] = θ[i] ^ 2 end - mx + return mx end #AR function gmat!(mx, θ, ::AR_) @@ -64,7 +64,7 @@ function gmat!(mx, θ, ::AR_) end end end - mx + return mx end #ARH function gmat!(mx, θ, ::ARH_) @@ -84,7 +84,7 @@ function gmat!(mx, θ, ::ARH_) @inbounds @simd for m = 1:s mx[m, m] *= mx[m, m] end - mx + return mx end #CS function gmat!(mx, θ, ::CS_) @@ -99,7 +99,7 @@ function gmat!(mx, θ, ::CS_) end end end - mx + return mx end #CSH function gmat!(mx, θ, ::CSH_) @@ -118,7 +118,7 @@ function gmat!(mx, θ, ::CSH_) @inbounds @simd for m = 1:s mx[m, m] *= mx[m, m] end - mx + return mx end ################################################################################ #ARMA @@ -136,7 +136,7 @@ function gmat!(mx, θ, ::ARMA_) end end end - mx + return mx end #TOEP function gmat!(mx, θ, ::TOEP_) @@ -152,7 +152,7 @@ function gmat!(mx, θ, ::TOEP_) end end end - mx + return mx end function gmat!(mx, θ, ct::TOEPP_) de = θ[1] ^ 2 #diagonal element @@ -167,7 +167,7 @@ function gmat!(mx, θ, ct::TOEPP_) end end end - mx + return mx end #TOEPH function gmat!(mx, θ, ::TOEPH_) @@ -186,7 +186,7 @@ function gmat!(mx, θ, ::TOEPH_) @inbounds @simd for m = 1:s mx[m, m] *= mx[m, m] end - mx + return mx end #TOEPHP function gmat!(mx, θ, ct::TOEPHP_) @@ -205,7 +205,7 @@ function gmat!(mx, θ, ct::TOEPHP_) @inbounds @simd for m = 1:s mx[m, m] *= mx[m, m] end - mx + return mx end #UN function gmat!(mx, θ, ::UN_) @@ -224,7 +224,7 @@ function gmat!(mx, θ, ::UN_) @inbounds @simd for m = 1:s mx[m, m] *= mx[m, m] end - mx + return mx end function tpnum(m, n, s) @@ -233,4 +233,5 @@ function tpnum(m, n, s) b += s - i end b -= s - n + return b end diff --git a/src/linearalgebra.jl b/src/linearalgebra.jl index 4de882a..1f5de27 100644 --- a/src/linearalgebra.jl +++ b/src/linearalgebra.jl @@ -23,7 +23,7 @@ Change θ (only upper triangle). B is symmetric. end end end - θ + return θ end #= function mulαβαtinc!(θ::AbstractMatrix{T}, A::AbstractMatrix{T}, B::AbstractMatrix{T}) where T <: AbstractFloat @@ -55,7 +55,7 @@ Change θ (only upper triangle). B is symmetric. end end end - θ + return θ end """ mulαβαtinc!(θ::AbstractVector{T}, A::AbstractMatrix, B::AbstractMatrix, a::AbstractVector, b::AbstractVector, alpha) where T @@ -78,7 +78,7 @@ Change θ (only upper triangle). B is symmetric. end end end - θ + return θ end """ @@ -137,7 +137,7 @@ Change θ. end @inbounds θ[n] += θn end - θ + return θ end # Diagonal(b) * A * Diagonal(b) - chnage only A upper triangle @noinline function mulβdαβd!(A::AbstractMatrix, b::AbstractVector) @@ -149,7 +149,7 @@ end @inbounds A[m, n] *= b[m] * b[n] end end - A + return A end @@ -162,7 +162,7 @@ end @inbounds vec[r] += rz[r, i] * θi end end - vec + return vec end @inline function diag!(f, v, m) @@ -171,5 +171,5 @@ end @simd for i = 1:l @inbounds v[i] = f(m[i, i]) end - v + return v end diff --git a/src/reml.jl b/src/reml.jl index 3da0e5d..84c5fe1 100644 --- a/src/reml.jl +++ b/src/reml.jl @@ -7,7 +7,7 @@ function subutri!(a, b) @inbounds a[m,n] -= b[m,n] end end - a + return a end function fillzeroutri!(a::AbstractArray{T}) where T @@ -28,7 +28,7 @@ function checkmatrix!(mx::AbstractMatrix{T}) where T e = false end end - e + return e end ################################################################################ # REML without provided β @@ -270,7 +270,7 @@ function core_sweep_β(lmm, data, θ::Vector{T}, β, n; maxthreads::Int = 16) wh accθ₃[t] += mulθ₃(data.yv[i], data.xv[i], β, V) end end - sum(accθ₁), sum(accθ₂), sum(accθ₃), all(erroracc) + return sum(accθ₁), sum(accθ₂), sum(accθ₃), all(erroracc) end ### function reml_sweep_β(lmm, data, θ::Vector{T}, β; kwargs...) where T diff --git a/src/rmat.jl b/src/rmat.jl index cb8d024..8c4a098 100644 --- a/src/rmat.jl +++ b/src/rmat.jl @@ -13,7 +13,7 @@ rmat!(view(mx, sb, sb), view(θ, rθ[j]), view(zblock, sb, :), covstr.repeated[j].covtype.s, bi) end end - mx + return mx end ################################################################################ function rmat!(::Any, ::Any, ::Any, ::AbstractCovarianceType, ::Int) @@ -40,7 +40,7 @@ function rmat!(mx, θ, ::AbstractMatrix, ct::SWC_, sbj::Int) else @inbounds mx[1, 1] += de * ct.wtsb[sbj][1, 1] end - mx + return mx end #DIAG function rmat!(mx, θ, rz, ::DIAG_, ::Int) @@ -49,7 +49,7 @@ function rmat!(mx, θ, rz, ::DIAG_, ::Int) mx[i, i] += rz[i, c] * θ[c] ^ 2 end end - mx + return mx end #AR function rmat!(mx, θ, ::AbstractMatrix, ::AR_, ::Int) @@ -65,7 +65,7 @@ function rmat!(mx, θ, ::AbstractMatrix, ::AR_, ::Int) end end end - mx + return mx end #ARH function rmat!(mx, θ, rz, ::ARH_, ::Int) @@ -81,7 +81,7 @@ function rmat!(mx, θ, rz, ::ARH_, ::Int) @inbounds for m ∈ axes(mx, 1) mx[m, m] += vec[m] * vec[m] end - mx + return mx end #CS function rmat!(mx, θ, ::AbstractMatrix, ::CS_, ::Int) @@ -98,7 +98,7 @@ function rmat!(mx, θ, ::AbstractMatrix, ::CS_, ::Int) end end end - mx + return mx end #CSH function rmat!(mx, θ, rz, ::CSH_, ::Int) @@ -116,7 +116,7 @@ function rmat!(mx, θ, rz, ::CSH_, ::Int) @inbounds for m ∈ axes(mx, 1) mx[m, m] += vec[m] * vec[m] end - mx + return mx end ################################################################################ #ARMA @@ -134,7 +134,7 @@ function rmat!(mx, θ, ::AbstractMatrix, ::ARMA_, ::Int) end end end - mx + return mx end ################################################################################ #TOEPP @@ -151,7 +151,7 @@ function rmat!(mx, θ, ::AbstractMatrix, ct::TOEPP_, ::Int) end end end - mx + return mx end ################################################################################ #TOEPHP @@ -169,7 +169,7 @@ function rmat!(mx, θ, rz, ct::TOEPHP_, ::Int) @inbounds @simd for m = 1:s mx[m, m] += vec[m] * vec[m] end - mx + return mx end ################################################################################ #= @@ -213,7 +213,7 @@ function rmat!(mx, θ, rz, ::SPEXP_, ::Int) end end end - mx + return mx end ################################################################################ #SPPOW @@ -233,7 +233,7 @@ function rmat!(mx, θ, rz, ::SPPOW_, ::Int) end end end - mx + return mx end #SPGAU @@ -255,7 +255,7 @@ function rmat!(mx, θ, rz, ::SPGAU_, ::Int) end end end - mx + return mx end ################################################################################ #SPEXPD cos(pidij) @@ -275,7 +275,7 @@ function rmat!(mx, θ, rz, ::SPEXPD_, ::Int) end end end - mx + return mx end #SPPOWD function rmat!(mx, θ, rz, ::SPPOWD_, ::Int) @@ -293,7 +293,7 @@ function rmat!(mx, θ, rz, ::SPPOWD_, ::Int) end end end - mx + return mx end #SPGAUD function rmat!(mx, θ, rz, ::SPGAUD_, ::Int) @@ -312,7 +312,7 @@ function rmat!(mx, θ, rz, ::SPGAUD_, ::Int) end end end - mx + return mx end #UN @@ -333,14 +333,14 @@ function unrmat(θ::AbstractVector{T}, rz) where T @inbounds @simd for m = 1:rm mx[m, m] *= mx[m, m] end - Symmetric(mx) + return Symmetric(mx) end function rmat!(mx, θ, rz::AbstractMatrix, ::UN_, ::Int) vec = tmul_unsafe(rz, θ) rm = size(mx, 1) rcov = unrmat(θ, rz) mulαβαtinc!(mx, rz, rcov) - mx + return mx end ############################################################################### ############################################################################### diff --git a/src/statsbase.jl b/src/statsbase.jl index 888be62..a29b318 100644 --- a/src/statsbase.jl +++ b/src/statsbase.jl @@ -75,7 +75,7 @@ Model coefficients (β). StatsBase.coef(lmm::LMM) = copy(coef_(lmm)) function coef_(lmm::LMM) - lmm.result.beta + return lmm.result.beta end """ StatsBase.coefnames(lmm::LMM) = StatsBase.coefnames(lmm.mf) @@ -99,7 +99,7 @@ end DOF residuals: N - rank(X), where N - total number of observations. """ function StatsBase.dof_residual(lmm::LMM) - nobs(lmm) - lmm.rankx + return nobs(lmm) - lmm.rankx end """ @@ -108,7 +108,7 @@ end DOF. """ function StatsBase.dof(lmm::LMM) - lmm.nfixed + lmm.covstr.tl + return lmm.nfixed + lmm.covstr.tl end """ @@ -117,7 +117,7 @@ end Return loglikelihood value. """ function StatsBase.loglikelihood(lmm::LMM) - -lmm.result.reml/2 + return -lmm.result.reml/2 end """ @@ -128,7 +128,7 @@ Akaike Information Criterion. function StatsBase.aic(lmm::LMM) l = loglikelihood(lmm) d = lmm.covstr.tl - -2l + 2d + return -2l + 2d end """ @@ -140,7 +140,7 @@ function StatsBase.bic(lmm::LMM) l = loglikelihood(lmm) d = lmm.covstr.tl n = nobs(lmm) - lmm.nfixed - -2l + d * log(n) + return -2l + d * log(n) end """ @@ -152,7 +152,7 @@ function StatsBase.aicc(lmm::LMM) l = loglikelihood(lmm) d = lmm.covstr.tl n = nobs(lmm) - lmm.nfixed - -2l + (2d * n) / (n - d - 1.0) + return -2l + (2d * n) / (n - d - 1.0) end """ @@ -164,14 +164,14 @@ function caic(lmm::LMM) l = loglikelihood(lmm) d = lmm.covstr.tl n = nobs(lmm) - lmm.nfixed - -2l + d * (log(n) + 1.0) + return -2l + d * (log(n) + 1.0) end """ StatsBase.isfitted(lmm::LMM) """ function StatsBase.isfitted(lmm::LMM) - lmm.result.fit + return lmm.result.fit end """ StatsBase.vcov(lmm::LMM) @@ -187,7 +187,7 @@ Standard error StatsBase.stderror(lmm::LMM) = copy(stderror_(lmm)) function stderror_(lmm::LMM) - lmm.result.se + return lmm.result.se end stderror!(v, lmm::LMM) = copyto!(v, lmm.result.se) @@ -239,7 +239,7 @@ end Responce varible name. """ function StatsBase.responsename(lmm::LMM) - StatsBase.coefnames(lmm.f)[1] + return StatsBase.coefnames(lmm.f)[1] end diff --git a/src/sweep.jl b/src/sweep.jl index acd5bff..744e21a 100644 --- a/src/sweep.jl +++ b/src/sweep.jl @@ -13,11 +13,11 @@ function nsyrk!(α, x, A) return A end function nsyrk!(α, x, A::AbstractArray{T}) where T <: AbstractFloat - BLAS.syrk!('U', 'N', α, x, one(T), A) + return BLAS.syrk!('U', 'N', α, x, one(T), A) end function sweep!(A::AbstractArray{T}, k::Integer, inv::Bool = false) where T - sweepb!(Vector{T}(undef, size(A, 2)), A, k, inv) + return sweepb!(Vector{T}(undef, size(A, 2)), A, k, inv) end function sweepb!(akk::AbstractArray{T, 1}, A::AbstractArray{T, 2}, k::Integer, inv::Bool = false) where T <: Number p = checksquare(A) @@ -48,7 +48,7 @@ function sweepb!(akk::AbstractArray{T, 1}, A::AbstractArray{T, 2}, k::Integer, i end function sweep!(A::AbstractArray{T, 2}, ks::AbstractVector{I}, inv::Bool = false; logdet::Bool = false) where {T <: Number, I <: Integer} akk = Vector{T}(undef, size(A,2)) - sweepb!(akk, A, ks, inv; logdet = logdet) + return sweepb!(akk, A, ks, inv; logdet = logdet) end function sweepb!(akk::AbstractArray{T, 1}, A::AbstractArray{T, 2}, ks::AbstractVector{I}, inv::Bool = false; logdet::Bool = false) where {T <: Number, I<:Integer} @@ -75,5 +75,5 @@ function sweepb!(akk::AbstractArray{T, 1}, A::AbstractArray{T, 2}, ks::AbstractV sweepb!(akk, A, k, inv) end end - A, ld, noerror + return A, ld, noerror end diff --git a/src/typeiii.jl b/src/typeiii.jl index 7128330..c7e2345 100644 --- a/src/typeiii.jl +++ b/src/typeiii.jl @@ -84,7 +84,7 @@ function contrast(lmm, l::AbstractMatrix; name::String = "Contrast", ddf = :satt else pval = NaN end - ContrastTable([name], [F], [ndf], [df], [pval]) + return ContrastTable([name], [F], [ndf], [df], [pval]) end function Base.show(io::IO, at::ContrastTable) diff --git a/src/utils.jl b/src/utils.jl index a142c87..b714afa 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -7,7 +7,7 @@ function initvar(y::Vector, X::Matrix{T}) where T r = copy(y) LinearAlgebra.BLAS.gemv!('N', one(T), X, β, -one(T), r) #r = y .- X * β - dot(r, r)/(length(r) - size(X, 2)), β + return dot(r, r)/(length(r) - size(X, 2)), β end ################################################################################ function fixedeffn(f::FormulaTerm) @@ -25,7 +25,7 @@ function nterms(rhs::Union{Tuple{Vararg{AbstractTerm}}, Nothing, AbstractTerm}) else p = 0 end - p + return p end """ Term name. @@ -68,7 +68,7 @@ function lcontrast(lmm::LMM, i::Int) mx[j, inds[j]] = 1 end end - mx + return mx end ################################################################################ # VAR LINK @@ -76,17 +76,17 @@ end function vlink(σ::T) where T <: Real if σ < -21.0 return one(T)*7.582560427911907e-10 end #Experimental - exp(σ) + return exp(σ) end function vlinkr(σ::T) where T <: Real - log(σ) + return log(σ) end function vlinksq(σ::T) where T <: Real - σ*σ + return σ*σ end function vlinksqr(σ::T) where T <: Real - sqrt(σ) + return sqrt(σ) end function rholinkpsigmoid(ρ::T) where T <: Real @@ -141,7 +141,7 @@ function varlinkvecapply!(v, p; varlinkf = :exp, rholinkf = :sigm) end end end - v + return v end function varlinkrvecapply!(v, p; varlinkf = :exp, rholinkf = :sigm) @inbounds for i = 1:length(v) @@ -165,7 +165,7 @@ function varlinkrvecapply!(v, p; varlinkf = :exp, rholinkf = :sigm) end end end - v + return v end function varlinkvecapply(v, p; varlinkf = :exp, rholinkf = :sigm) s = similar(v) @@ -192,22 +192,22 @@ function varlinkvecapply(v, p; varlinkf = :exp, rholinkf = :sigm) s[i] = v[i] end end - s + return s end ################################################################################ function m2logreml(lmm) - lmm.result.reml + return lmm.result.reml end function logreml(lmm) - -m2logreml(lmm)/2 + return -m2logreml(lmm)/2 end function m2logreml(lmm, theta; maxthreads::Int = num_cores()) - reml_sweep_β(lmm, LMMDataViews(lmm), theta; maxthreads = maxthreads)[1] + return reml_sweep_β(lmm, LMMDataViews(lmm), theta; maxthreads = maxthreads)[1] end ################################################################################ function optim_callback(os) - false + return false end ################################################################################ """ @@ -216,7 +216,7 @@ end Return true if CovarianceType is ZERO. """ function zeroeff(eff) - isa(eff.covtype.s, ZERO) + return isa(eff.covtype.s, ZERO) end """ raneffn(lmm) @@ -226,7 +226,7 @@ function raneffn(lmm) if zeroeff(lmm.covstr.random[1]) return 0 end - length(lmm.covstr.random) + return length(lmm.covstr.random) end """ @@ -237,7 +237,7 @@ function gmatrix(lmm::LMM{T}, r::Int) where T if r > length(lmm.covstr.random) error("Invalid random effect number: $(r)!") end G = zeros(T, lmm.covstr.q[r], lmm.covstr.q[r]) gmat!(G, view(lmm.result.theta, lmm.covstr.tr[r]), lmm.covstr.random[r].covtype.s) - Symmetric(G) + return Symmetric(G) end @@ -247,7 +247,7 @@ end Return true if all variance-covariance matrix (G) of random effect is positive definite. """ function gmatrixipd(lmm::LMM) - lmm.result.ipd + return lmm.result.ipd end """ @@ -260,7 +260,7 @@ function rmatrix(lmm::LMM{T}, i::Int) where T R = zeros(T, q, q) rθ = lmm.covstr.tr[lmm.covstr.rn + 1:end] rmat_base_inc!(R, lmm.result.theta, rθ, lmm.covstr, i) - Symmetric(R) + return Symmetric(R) end ##################################################################### @@ -270,11 +270,12 @@ function applywts!(::Any, ::Int, ::Nothing) end function applywts!(V::AbstractMatrix, i::Int, wts::LMMWts{<:Vector}) - mulβdαβd!(V, wts.sqrtwts[i]) + return mulβdαβd!(V, wts.sqrtwts[i]) end function applywts!(V::AbstractMatrix, i::Int, wts::LMMWts{<:Matrix}) V .*= wts.sqrtwts[i] + return V end ##################################################################### @@ -290,15 +291,14 @@ function vmatrix!(V, θ, lmm::LMM, i::Int) # pub API rθ = lmm.covstr.tr[lmm.covstr.rn + 1:end] rmat_base_inc!(V, θ, rθ, lmm.covstr, i) # Repeated vector applywts!(V, i, lmm.wts) - zgz_base_inc!(V, gvec, lmm.covstr, i) - + return zgz_base_inc!(V, gvec, lmm.covstr, i) end # !!! Main function REML used @noinline function vmatrix!(V, G, θ, rθ, lmm::LMM, i::Int) rmat_base_inc!(V, θ, rθ, lmm.covstr, i) # Repeated vector applywts!(V, i, lmm.wts) - zgz_base_inc!(V, G, lmm.covstr, i) + return zgz_base_inc!(V, G, lmm.covstr, i) end """ @@ -307,7 +307,7 @@ end Return variance-covariance matrix V for i bolock. """ function vmatrix(lmm::LMM, i::Int) - vmatrix(lmm.result.theta, lmm, i) + return vmatrix(lmm.result.theta, lmm, i) end function vmatrix(θ::AbstractVector{T}, lmm::LMM, i::Int) where T @@ -315,7 +315,7 @@ function vmatrix(θ::AbstractVector{T}, lmm::LMM, i::Int) where T gvec = gmatvec(θ, lmm.covstr) rθ = lmm.covstr.tr[lmm.covstr.rn + 1:end] vmatrix!(V, gvec, θ, rθ, lmm, i) # Repeated vector - Symmetric(V) + return Symmetric(V) end # For Multiple Imputation function vmatrix(θ::Vector, covstr::CovStructure, lmmwts, i::Int) @@ -325,11 +325,11 @@ function vmatrix(θ::Vector, covstr::CovStructure, lmmwts, i::Int) rmat_base_inc!(V, θ, rθ, covstr, i) # Repeated vector applywts!(V, i, lmmwts) zgz_base_inc!(V, gvec, covstr, i) - Symmetric(V) + return Symmetric(V) end function blockgmatrix(lmm::LMM{T}) where T - blockgmatrix(lmm, (1, 1)) + return blockgmatrix(lmm, (1, 1)) end function blockgmatrix(lmm::LMM{T}, v) where T @@ -348,7 +348,7 @@ function blockgmatrix(lmm::LMM{T}, v) where T s = e + 1 end end - G + return G end function blockzmatrix(lmm::LMM{T}, i) where T @@ -368,7 +368,7 @@ function blockzmatrix(lmm::LMM{T}, i) where T s = e + 1 mx[j] = smx end - hcat(mx...) + return hcat(mx...) end """ raneff(lmm::LMM{T}, i) @@ -399,8 +399,7 @@ function raneff(lmm::LMM{T}, block) where T rvsbj[i][j] = subjname => rv[s:e] end end - rvsbj - + return rvsbj end """ raneff(lmm::LMM{T}) @@ -418,7 +417,7 @@ function raneff(lmm::LMM) end end end - fb + return fb end """ @@ -438,19 +437,19 @@ function hessian(lmm, theta) vloptf(x) = reml_sweep_β(lmm, lmm.dv, x, lmm.result.beta)[1] chunk = ForwardDiff.Chunk{min(8, length(theta))}() hcfg = ForwardDiff.HessianConfig(vloptf, theta, chunk) - ForwardDiff.hessian(vloptf, theta, hcfg) + return ForwardDiff.hessian(vloptf, theta, hcfg) end function hessian(lmm) if !lmm.result.fit error("Model not fitted!") end - hessian(lmm, lmm.result.theta) + return hessian(lmm, lmm.result.theta) end ################################################################################ ################################################################################ function StatsModels.termvars(ve::VarEffect) - termvars(ve.formula) + return termvars(ve.formula) end function StatsModels.termvars(ve::Vector{VarEffect}) - union(termvars.(ve)...) + return union(termvars.(ve)...) end ################################################################################ diff --git a/src/varstruct.jl b/src/varstruct.jl index bf6ae3a..b2bb594 100644 --- a/src/varstruct.jl +++ b/src/varstruct.jl @@ -16,7 +16,7 @@ function StatsModels.ContrastsMatrix(contrasts::RawCoding, levels::AbstractVecto contrasts) end function StatsModels.modelcols(t::CategoricalTerm{RawCoding, T, N}, d::NamedTuple) where T where N - d[t.sym] + return d[t.sym] end ################################################################################ @@ -40,7 +40,7 @@ end function modelparse(term::FunctionTerm{typeof(|)}) eff, subj = term.args if !isa(subj, AbstractTerm) || isa(subj, FunctionTerm{typeof(*), Vector{Term}}) throw(FormulaException("Subject term type not <: AbstractTerm. Use `term` or `interaction term` only. Maybe you are using something like this: `@covstr(factor|term1*term2)` or `@covstr(factor|(term1+term2))`. Use only `@covstr(factor|term)` or `@covstr(factor|term1&term2)`.")) end - eff, subj + return eff, subj end function modelparse(term) throw(FormulaException("Model term type not <: FunctionTerm{typeof(|)}. Use model like this: `@covstr(factor|subject)`. Maybe you are using something like this: `@covstr(factor|term1+term2)`. Use only `@covstr(factor|term)` or `@covstr(factor|term1&term2)`.")) @@ -138,7 +138,7 @@ function sabjcrossdicts(d1, d2) end end end - v + return v end tabcols(data, symbs) = Tuple(Tables.getcolumn(Tables.columns(data), x) for x in symbs) @@ -168,7 +168,7 @@ function raneflenv(covstr, block) for i = 1:l v[i] = length(covstr.esb.sblock[block, i]) end - v + return v end """ Covarince structure. @@ -420,13 +420,13 @@ end ################################################################################ function fill_coding_dict!(t::T, d::Dict, data) where T <: Union{ConstantTerm, InterceptTerm, FunctionTerm} - d + return d end function fill_coding_dict!(t::T, d::Dict, data) where T <: Term if typeof(Tables.getcolumn(data, t.sym)) <: AbstractCategoricalVector || !(typeof(Tables.getcolumn(data, t.sym)) <: AbstractVector{V} where V <: Real) d[t.sym] = StatsModels.FullDummyCoding() end - d + return d end #= function fill_coding_dict!(t::T, d::Dict, data) where T <: InteractionTerm @@ -448,7 +448,7 @@ function fill_coding_dict_ct!(t, d, data) fill_coding_dict!(i, d, data) end end - d + return d end #= function fill_coding_dict!(t::T, d::Dict, data) where T <: Tuple{Vararg{AbstractTerm}} diff --git a/src/vartypes.jl b/src/vartypes.jl index a22ca84..d8bf870 100644 --- a/src/vartypes.jl +++ b/src/vartypes.jl @@ -532,7 +532,7 @@ function indfromtn(ind, s) break end end - m, s + ind - b + return m, s + ind - b end function rcoefnames(s, t, ct::UN_) @@ -572,7 +572,7 @@ function applycovschema!(ct::SWC_{<:AbstractMatrix{T}}, vcovblock) where T push!(ct.wtsb, ct.wtsm[vcovblock[i], vcovblock[i]]) end end - ct + return ct end ################################################################################