-
Notifications
You must be signed in to change notification settings - Fork 74
Unquoted weights argument #605
Copy link
Copy link
Open
Description
Okay, here's a bit of a strange one. Trying to use fixest::feglm with ggplot2 for estimation (so I can fit an exponential curve and have standard errors on the fitted values).
But internally, they pass the argument weights = weight where weight is a vector in the data argument.
I.e. non-standard evaluation.
This creates problems since this errors in feols.
The simplest solution would be to patch fixest to allow for NSE for weights argument.
I was trying to patch this using method.args = list(family = "poisson", weights = NULL) but I get an error: ! formal argument "weights" matched by multiple actual arguments.
@teunbrand is this something that could be addressed on the ggplot2 side?
library(fixest)
library(ggplot2)
base <- mtcars
base$w <- runif(nrow(base), 0.5, 1.5)
lm(mpg ~ hp, base, weights = w)
#>
#> Call:
#> lm(formula = mpg ~ hp, data = base, weights = w)
#>
#> Coefficients:
#> (Intercept) hp
#> 29.66891 -0.06503
feols(mpg ~ hp, base, weights = w)
#> Error in feols(mpg ~ hp, base, weights = w): Argument `weights` could not be evaluated: object 'w' not found
ggplot(aes(x = hp, y = mpg), data = mtcars) +
geom_point() +
geom_smooth(method = "lm")
#> `geom_smooth()` using formula = 'y ~ x'ggplot(aes(x = hp, y = mpg), data = mtcars) +
geom_point() +
geom_smooth(method = fixest::feols)
#> `geom_smooth()` using formula = 'y ~ x'
#> Warning: Failed to fit group -1.
#> Caused by error in `method()`:
#> ! Argument `weights` could not be evaluated: object 'weight' not foundReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

