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

Corner case in @formula parsing #278

Open
bkamins opened this issue Feb 20, 2023 · 2 comments
Open

Corner case in @formula parsing #278

bkamins opened this issue Feb 20, 2023 · 2 comments

Comments

@bkamins
Copy link

bkamins commented Feb 20, 2023

julia> @formula(return ~ dkr + eps + nentinc + salary)
ERROR: LoadError: ArgumentError: expected formula separator ~, got return

(real life case from Wooldridge 7e)

@bkamins
Copy link
Author

bkamins commented Feb 20, 2023

Also:

julia> @formula(price ~ bdrms + identity(sqrft - 150.0 * bdrms))
┌ Warning: Number 150.0 removed from interaction term 150.0 & bdrms
└ @ StatsModels C:\Users\bogum\.julia\packages\StatsModels\fK0P3\src\formula.jl:158
FormulaTerm
Response:
  price(unknown)
Predictors:
  bdrms(unknown)
  (sqrft,bdrms)->identity(sqrft - 150.0bdrms)

(the warning is incorrect as we protected * with identity)

@kleinschmidt
Copy link
Member

Ah yeah that's a tricky one. We might need to require that formula expressions don't contain reserved symbols. You could manually construct it with Term("return") of necessary.

The second one may be fixed on master if you're feeling brave! And on master, protect does the thing that identity does in your example...

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