Skip to content

l() error with named parameter #499

@MaelAstruc

Description

@MaelAstruc

Hello,

I have encountered an issue with the feols() function when using l() with named parameters.

Here is a short example with a panel data from plm:

data("EmplUK", package="plm")

EmplUK <- fixest::panel(EmplUK, panel.id = ~firm+year)

fixest::feols(output ~ l(capital, 1L), EmplUK)

# NOTE: 140 observations removed because of NA values (RHS: 140).
# OLS estimation, Dep. Var.: output
# Observations: 891
# Standard-errors: Clustered (firm) 
# Estimate Std. Error    t value  Pr(>|t|)    
# (Intercept)   102.950589   0.326763 315.061991 < 2.2e-16 ***
#   l(capital, 1)  -0.023391   0.044998  -0.519814   0.60402    
# ---
#   Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# RMSE: 9.56003   Adj. R2: -8.885e-4

fixest::feols(output ~ l(capital, lag = 1L), EmplUK)

# Erreur dans fixest::feols(output ~ l(capital, lag = 1L), EmplUK) : 
#  Problem in the formula regarding lag/leads: 
#  In l__expand(capital, lag = 1): argument inutilisé (lag = 1)

From my understanding, the error rises because l__expand() expects a parameter 'k' instead of 'lag' or 'lead'.

I think this could be fixed by:

  • Renaming the 'lead' and 'lag' parameters at the f(), d() and l() level, this would be the easiest solution
  • Expecting the 'lead' and 'lag' parameters at The l__expand() level, but this would be a bad idea
  • Updating the expand_lags_internal() function when parsing the function, this would be a bit more fastidious but feasible
  • Assuming that nobody uses the named parameter and ignore this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions