diff --git a/Project.toml b/Project.toml index f8e6af9e..9b80f5af 100644 --- a/Project.toml +++ b/Project.toml @@ -1,9 +1,9 @@ name = "StatsModels" uuid = "3eaba693-59b7-5ba5-a881-562e759f1c8d" -version = "0.6.6" +version = "0.6.7" [deps] -CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" +DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" ShiftedArrays = "1277b4bf-5013-50f5-be3d-901d8477a67a" @@ -12,13 +12,15 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" [compat] -StatsBase = "≥0.22.0" julia = "1" +DataAPI = "1.1" +StatsBase = "≥0.22.0" [extras] +CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["DataFrames", "Statistics", "Test"] +test = ["CategoricalArrays", "DataFrames", "Statistics", "Test"] diff --git a/src/StatsModels.jl b/src/StatsModels.jl index 847932be..4d01d13c 100644 --- a/src/StatsModels.jl +++ b/src/StatsModels.jl @@ -3,8 +3,8 @@ module StatsModels using Tables using StatsBase using ShiftedArrays: lag, lead -using CategoricalArrays using DataStructures +using DataAPI: levels using SparseArrays using LinearAlgebra diff --git a/src/modelframe.jl b/src/modelframe.jl index 8500265f..c5759ebc 100644 --- a/src/modelframe.jl +++ b/src/modelframe.jl @@ -47,17 +47,9 @@ end function _nonmissing!(res, col) # workaround until JuliaLang/julia#21256 is fixed eltype(col) >: Missing || return - - @inbounds for (i, el) in enumerate(col) - res[i] &= !ismissing(el) - end + res .&= .!ismissing.(col) end -function _nonmissing!(res, col::CategoricalArray{>: Missing}) - @inbounds for (i, el) in enumerate(col.refs) - res[i] &= el > 0 - end -end function missing_omit(d::T) where T<:ColumnTable nonmissings = trues(length(first(d))) diff --git a/src/statsmodel.jl b/src/statsmodel.jl index 0e4b6ea4..be5cd250 100644 --- a/src/statsmodel.jl +++ b/src/statsmodel.jl @@ -132,19 +132,19 @@ StatsBase.r2(mm::TableRegressionModel, variant::Symbol) = r2(mm.model, variant) StatsBase.adjr2(mm::TableRegressionModel, variant::Symbol) = adjr2(mm.model, variant) function _return_predictions(T, yp::AbstractVector, nonmissings, len) - out = missings(eltype(yp), len) + out = Vector{Union{eltype(yp),Missing}}(missing, len) out[nonmissings] = yp out end function _return_predictions(T, yp::AbstractMatrix, nonmissings, len) - out = missings(eltype(yp), (len, 3)) + out = Matrix{Union{eltype(yp),Missing}}(missing, len, 3) out[nonmissings, :] = yp T((prediction = out[:,1], lower = out[:,2], upper = out[:,3])) end function _return_predictions(T, yp::NamedTuple, nonmissings, len) - y = missings(eltype(yp[:prediction]), len) + y = Vector{Union{eltype(yp.prediction),Missing}}(missing, len) l, h = similar(y), similar(y) out = (prediction = y, lower = l, upper = h) for key in (:prediction, :lower, :upper)