Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing type leads to errors #71

Closed
felixholub opened this issue Sep 9, 2019 · 1 comment
Closed

missing type leads to errors #71

felixholub opened this issue Sep 9, 2019 · 1 comment

Comments

@felixholub
Copy link

On julia-1.2.0, FixedEffectModels.jl version [9d5cd8c9] FixedEffectModels v0.8.2 I get the following error messages when including a variable which allows for missings. Take the following example:

using DataFrames, FixedEffectModels

df1 = DataFrame(a=[1.0, 2.0, 3.0, 4.0], b=[5.0, 7.0, 11.0, 13.0])
df2 = DataFrame(a=[1.0, missing, 3.0, 4.0], b=[5.0, 7.0, 11.0, 13.0])

rr1a = reg(df1,@model(a ~ b))
rr1b = reg(df1,@model(b ~ a))
rr2a = reg(df2,@model(a ~ b))
rr2b = reg(df2,@model(b ~ a))

The first two regressions work well, while the third produces

julia> rr2a = reg(df2,@model(a ~ b))

ERROR: MethodError: no method matching Array{Float64,1}(::Array{Float64,2})
Closest candidates are:
  Array{Float64,1}(::AbstractArray{S,N}) where {T, N, S} at array.jl:482
  Array{Float64,1}() where T at boot.jl:423
  Array{Float64,1}(::UndefInitializer, ::Int64) where T at boot.jl:404
  ...
rr2a = reg(df2,@model(a ~ b))

ERROR: MethodError: no method matching Array{Float64,1}(::Array{Float64,2})
Closest candidates are:
  Array{Float64,1}(::AbstractArray{S,N}) where {T, N, S} at array.jl:482
  Array{Float64,1}() where T at boot.jl:423
  Array{Float64,1}(::UndefInitializer, ::Int64) where T at boot.jl:404
  ...
Stacktrace:
 [1] convert(::Type{Array{Float64,1}}, ::Array{Float64,2}) at ./array.jl:474
 [2] #reg#38(::Nothing, ::Expr, ::Nothing, ::Nothing, ::Int64, ::Dict{Symbol,Any}, ::Float64, ::Int64, ::Bool, ::Symbol, ::Bool, ::typeof(reg), ::DataFrame, ::StatsModels.FormulaTerm{StatsModels.Term,StatsModels.Term}) at /home/holub/.julia/packages/FixedEffectModels/kANnE/src/reg.jl:158
 [3] reg(::DataFrame, ::StatsModels.FormulaTerm{StatsModels.Term,StatsModels.Term}) at /home/holub/.julia/packages/FixedEffectModels/kANnE/src/reg.jl:49
 [4] #reg#37(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}}, ::typeof(reg), ::DataFrame, ::Model) at /home/holub/.julia/packages/FixedEffectModels/kANnE/src/reg.jl:36
 [5] reg(::DataFrame, ::Model) at /home/holub/.julia/packages/FixedEffectModels/kANnE/src/reg.jl:36
 [6] top-level scope at none:0

and the fourth produces

rr2b = reg(df2,@model(b ~ a))

ERROR: ArgumentError: FDist: the condition ν1 > zero(ν1) && ν2 > zero(ν2) is not satisfied.
Stacktrace:
 [1] macro expansion at /home/holub/.julia/packages/Distributions/tfkz4/src/utils.jl:6 [inlined]
 [2] Type at /home/holub/.julia/packages/Distributions/tfkz4/src/univariate/continuous/fdist.jl:30 [inlined]
 [3] Type at /home/holub/.julia/packages/Distributions/tfkz4/src/univariate/continuous/fdist.jl:35 [inlined]
 [4] Type at /home/holub/.julia/packages/Distributions/tfkz4/src/univariate/continuous/fdist.jl:36 [inlined]
 [5] compute_Fstat(::Array{Float64,1}, ::LinearAlgebra.Symmetric{Float64,Array{Float64,2}}, ::Int64, ::Bool, ::VcovSimpleMethod, ::VcovData{LinearAlgebra.Cholesky{Float64,Array{Float64,2}},1}) at /home/holub/.julia/packages/FixedEffectModels/kANnE/src/vcov/utils.jl:14
 [6] #reg#38(::Nothing, ::Expr, ::Nothing, ::Nothing, ::Int64, ::Dict{Symbol,Any}, ::Float64, ::Int64, ::Bool, ::Symbol, ::Bool, ::typeof(reg), ::DataFrame, ::StatsModels.FormulaTerm{StatsModels.Term,StatsModels.Term}) at /home/holub/.julia/packages/FixedEffectModels/kANnE/src/reg.jl:363
 [7] reg(::DataFrame, ::StatsModels.FormulaTerm{StatsModels.Term,StatsModels.Term}) at /home/holub/.julia/packages/FixedEffectModels/kANnE/src/reg.jl:49
 [8] #reg#37(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}}, ::typeof(reg), ::DataFrame, ::Model) at /home/holub/.julia/packages/FixedEffectModels/kANnE/src/reg.jl:36
 [9] reg(::DataFrame, ::Model) at /home/holub/.julia/packages/FixedEffectModels/kANnE/src/reg.jl:36
 [10] top-level scope at none:0

Previously, I experienced that missing where simply dropped for the regression.

@felixholub felixholub changed the title missing lead to errors missing type leads to errors Sep 9, 2019
@matthieugomez
Copy link
Member

Thanks for the MWE. This is due to JuliaStats/StatsModels.jl#145.
I have pushed a fix, and tagged a new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants