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

Ignore rows with Infs? #214

Open
jmboehm opened this issue Sep 10, 2022 · 3 comments
Open

Ignore rows with Infs? #214

jmboehm opened this issue Sep 10, 2022 · 3 comments

Comments

@jmboehm
Copy link
Contributor

jmboehm commented Sep 10, 2022

The following seems like a 'classic' trap:

using FixedEffectModels, RDatasets
df = dataset("plm", "Cigar")
# assume some entries are Inf
df.Sales[1] = 0.0
df.logsales = log.(df.Sales)
reg(df, @formula(logsales ~ NDI + fe(State) + fe(Year)), Vcov.cluster(:State), weights = :Pop)

gives

ERROR: "Some observations for the dependent variable are infinite"
Stacktrace:
 [1] reg(df::Any, formula::FormulaTerm, vcov::StatsBase.CovarianceEstimator; contrasts::Dict, weights::Union{Nothing, Symbol}, save::Union{Bool, Symbol}, method::Symbol, nthreads::Integer, double_precision::Bool, tol::Real, maxiter::Integer, drop_singletons::Bool, progress_bar::Bool, dof_add::Integer, subset::Union{Nothing, AbstractVector}, first_stage::Bool)
   @ FixedEffectModels ~/.julia/packages/FixedEffectModels/kJPKw/src/fit.jl:176
 [2] top-level scope
   @ REPL[9]:1

I feel the package could automatically drop rows where the regressand or one of the regressors is infinite, similarly to how it does with missings. What's the argument against that?

@matthieugomez
Copy link
Member

It's a bit tricky because Inf is meaningful. I will leave this issue open so that people can report if they encounter the same issue.

@junder873
Copy link
Contributor

I run into this sometimes as well. The R fixest package also automatically drops those observations.

@nilshg
Copy link
Contributor

nilshg commented Nov 9, 2023

I think a "do what I mean" approach (dropping Inf) is unidiomatic in the Julia Stats ecosystem. If rows are being ignored at a minimum there should be a warning.

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

No branches or pull requests

4 participants