diff --git a/src/general/etable.jl b/src/general/etable.jl index 4328fcf..24cb511 100644 --- a/src/general/etable.jl +++ b/src/general/etable.jl @@ -10,21 +10,22 @@ function etable(args...; ) N = length(args) - fspec = FormatSpec("0.$(digits)f") cutpoints, symbols = _parsestars(stars) (titles == [""]) && (titles = String["(" * string(i) * ")" for i = 1:N]) - μ = Vector{Vector{String}}(N) - β = Vector{Vector{String}}(N) - σ = Vector{Vector{String}}(N) + μ = Vector{Vector{String}}(undef, N) + β = Vector{Vector{String}}(undef, N) + σ = Vector{Vector{String}}(undef, N) for (i, ai) in enumerate(args) μ[i] = coefnames(ai) - β[i] = fmt.(fspec, coef(ai)) + β[i] = format.("{:.$(digits)f}", coef(ai)) - (typeof(aux) == Void) || (σ[i] = "(" .* fmt.(fspec, aux(ai)) .* ")") + if typeof(aux) != Nothing + σ[i] = "(" .* format.("{:.$(digits)f}", aux(ai)) .* ")" + end if cutpoints != [] for (j, pj) in enumerate(pval(ai)) @@ -36,7 +37,7 @@ function etable(args...; inter = union(μ...) - if typeof(aux) == Void + if typeof(aux) == Nothing output = vcat("", inter) else output = fill("", 2 * length(inter) + 1) @@ -50,12 +51,12 @@ function etable(args...; for (i, (ni, ti, βi)) in enumerate(zip(μ, titles, β)) idx = findall((in)(ni), inter) - (typeof(aux) == Void) || (idx .= 2 * idx - 1) + (typeof(aux) == Nothing) || (idx .= 2 .* idx .- 1) w2 .= "" w2[idx] .= βi - (typeof(aux) == Void) || (w2[idx + 1] .= σ[i]) + (typeof(aux) == Nothing) || (w2[(idx .+ 1)] .= σ[i]) _alignatchar!(w2, '.') - w1[1] .= ti + w1[1] = ti w1[2:end] .= w2 _alignatchar!(w1) output .*= " " .* w1 @@ -72,7 +73,7 @@ end function _parsestars(x::Matrix{Any}) if size(x, 1) != 0 - s = sortrows(x) + s = sort(x, dims = 1, rev = true) cutpoints = vcat(0.0, convert(Vector{Float64}, s[:, 1]), 1.0) symbols = vcat(convert(Vector{String}, s[:, 2]), "") else @@ -97,7 +98,7 @@ end # ALIGN STRING VECTOR AT FIRST OCCURRENCE OF CHARACTER function _alignatchar!(x::Vector{String}, y::Char) - pos = search.(x, y) + pos = findlast.(z -> z == y, x) maxpos = maximum(pos) add = " " .^ (maxpos .- pos) x .= add .* x diff --git a/src/general/types.jl b/src/general/types.jl index 0c43181..f304920 100644 --- a/src/general/types.jl +++ b/src/general/types.jl @@ -14,7 +14,7 @@ mutable struct ParEstimate β::AbstractArray V::AbstractArray - ParObject() = new() + ParEstimate() = new() end const Par1S = Union{ParModel, GMM, ParEstimate} diff --git a/src/inference/hausman.jl b/src/inference/hausman.jl index d2a53fc..edeb9f5 100644 --- a/src/inference/hausman.jl +++ b/src/inference/hausman.jl @@ -11,10 +11,10 @@ function hausman_1s(obj₁::ParM2S, obj₂::ParM2S, name::String ) return hausman_1s(obj₁, obj₂, [name]) end -function hausman_1s(obj₁::ParM2S, obj₂::ParM2S,names::Vector{String}) +function hausman_1s(obj₁::ParM2S, obj₂::ParM2S, names::Vector{String}) - i₁ = indexin(names, coefnames(obj₁)) - i₂ = indexin(names, coefnames(obj₂)) + i₁ = findall((in)(names), coefnames(obj₁)) + i₂ = findall((in)(names), coefnames(obj₂)) w₁ = getweights(obj₁) w₂ = getweights(obj₂) corr₁ = getcorr(obj₁) @@ -202,8 +202,8 @@ end function hausman_2s(obj₁::ParM2S, obj₂::ParM2S, names::Vector{String}) - i₁ = indexin(names, coefnames(obj₁)) - i₂ = indexin(names, coefnames(obj₂)) + i₁ = findall((in)(names), coefnames(obj₁)) + i₂ = findall((in)(names), coefnames(obj₂)) (iszero(i₁) | iszero(i₂)) && throw("missing coefficients in at least one model") @@ -229,8 +229,8 @@ end function hausman_2s(obj₁::ParM2S, obj₂::ParM2S, corr::CorrStructure, names::Vector{String}) - i₁ = indexin(names, coefnames(obj₁)) - i₂ = indexin(names, coefnames(obj₂)) + i₁ = findall((in)(names), coefnames(obj₁)) + i₂ = findall((in)(names), coefnames(obj₂)) w₁ = getweights(obj₁) w₂ = getweights(obj₂) diff --git a/src/inference/utils.jl b/src/inference/utils.jl index 4ed84c8..d82cf6c 100644 --- a/src/inference/utils.jl +++ b/src/inference/utils.jl @@ -19,7 +19,7 @@ function Base.isequal(corr₁::C, corr₂::C) where {C <: CorrStructure} output = true - for k in fieldnames(corr₁) + for k in fieldnames(typeof(corr₁)) output *= isequal(getfield(corr₁, k), getfield(corr₂, k)) end