Skip to content

Corner case in @formula parsing #278

Open

Description

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

(real life case from Wooldridge 7e)

Activity

  1. bkamins commented on Feb 20, 2023

    @bkamins
    Author

    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)

  2. kleinschmidt commented on Feb 20, 2023

    @kleinschmidt
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions