Closed 95goo closed 11 months ago
Hi. The error is normal. You should construct the proper fomrula before sending it to feols
.
BTW your use case is covered with the (native) dot square bracket operator to interpolate variables into formulas: .[outcome] ~ treated
library(fixest)
y = "Petal.Length"
feols(.[y] ~ Sepal.Length, iris)
#> OLS estimation, Dep. Var.: Petal.Length
#> Observations: 150
#> Standard-errors: IID
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) -7.10144 0.506662 -14.0161 < 2.2e-16 ***
#> Sepal.Length 1.85843 0.085856 21.6460 < 2.2e-16 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> RMSE: 0.86201 Adj. R2: 0.758333
See https://lrberge.github.io/fixest/articles/fixest_walkthrough.html#the-dot-square-bracket-operator.
Finally, please try to provide a fully reproducible example using dummy data (like in my example). It helps a lot to pinpoint the problem.
hi this is my code:
I get the following error:
I do 100% have the "happiness" and "income" variables in the"cat" data frame. The code works without !!sym(outcome). My goal is: within the function,
!!sym(outcome)
to dynamically specify the dependent variable in the regression formula. I have to do this for many dependent variables and have more models than I have shared above, so this seems to be the most efficient way to do this. Any advice here would be so helpful.