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

Show term name in only-one-level error #229

Open
jtrakk opened this issue Jul 24, 2021 · 2 comments
Open

Show term name in only-one-level error #229

jtrakk opened this issue Jul 24, 2021 · 2 comments

Comments

@jtrakk
Copy link

jtrakk commented Jul 24, 2021

ArgumentError: only one level found: foo (need at least two to compute contrasts).
Stacktrace:
  [1] StatsModels.ContrastsMatrix(contrasts::DummyCoding, levels::Vector{Int64})
    @ StatsModels ~/.julia/packages/StatsModels/MDeyQ/src/contrasts.jl:185

it would be helpful if it would say which column/term the problem is in.

@kleinschmidt
Copy link
Member

I agree that would be nice to have. It's currently a bit tricky since you'll see that it's the ContrastsMatrix constructor that does that check and throws the error, and that doesn't know about the context in which it's being called (including the term name). So we'd have to catch and re-throw the error at the term construction site (probably concrete_term if memory serves) but that seems a bit icky to me somehow.

@kleinschmidt
Copy link
Member

(I will say that the idea with printing the actual level it did find is to help track down which column it is that caused the problem, even though giving the column name would be even better)

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