-
Notifications
You must be signed in to change notification settings - Fork 20
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
method for augment
or fortify
.
#377
Comments
Using the lm method for augment *almost* works, but fails:
augment.lm_robust <- broom:::augment.lm
m <- lm_robust(extra~group, sleep)
augment(m) fails:
Error in eval(predvars, data, env) : object 'group' not found
Pop into the debugger, see the line it fails on:
df$.fitted <- predict(x, na.action = na.pass, ...) %>% unname()
This is because lm_robust doesn't retain the data set, so you need to
provide newdata explicitly:
augment(m, newdata=sleep)
# A tibble: 20 x 5
extra group ID .fitted .resid
<dbl> <fct> <fct> <dbl> <dbl>
1 0.7 1 1 0.750 -0.0500
2 -1.6 1 2 0.750 -2.35
3 -0.2 1 3 0.750 -0.950
4 -1.2 1 4 0.750 -1.95
5 -0.1 1 5 0.750 -0.850
6 3.4 1 6 0.750 2.65
7 3.7 1 7 0.750 2.95
8 0.8 1 8 0.750 0.05
9 0 1 9 0.750 -0.750
10 2 1 10 0.750 1.25
11 1.9 2 1 2.33 -0.43
12 0.8 2 2 2.33 -1.53
13 1.1 2 3 2.33 -1.23
14 0.1 2 4 2.33 -2.23
15 -0.1 2 5 2.33 -2.43
16 4.4 2 6 2.33 2.07
17 5.5 2 7 2.33 3.17
18 1.6 2 8 2.33 -0.73
19 4.6 2 9 2.33 2.27
20 3.4 2 10 2.33 1.07
…On Mon, Feb 8, 2021 at 6:26 PM Andrew McCartney ***@***.***> wrote:
Hi guys,
I am trying to use {estimatr} with a lot of downstream packages (such as
{lindia} or {report}, or to do added variable plots with my own package)
that rely on a model matrix that we would usually get from
broom::augment() or ggplot2::fortify().
I know this is in your heads because I found this issue for
broom::fortify():
tidymodels/broom#237 <tidymodels/broom#237>
I'm just including it here as an issue because I took a first stab at
trying to do it myself and got very stuck, very quickly.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#377>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADGGTRKMCYEQC7GA2RX53TS6CMJTANCNFSM4XKEAORA>
.
|
I got this to work! Let me play with it a bit in my use case but this is super helpful. I guess the next issue is just dealing with the problem of standard errors given the heteroskedasticity issue. Have to make some judgment calls. Thanks. |
@nfultz, should we create our own augment method that requires newdata? Is that advisable? |
Since
|
Correct me if I'm wrong, but isn't it current practice with {broom} that they're no longer adding new model objects and things like this? or am I thinking of a different ecosystem? EDIT: From the {broom} main website:
|
That makes sense. estimatr is a bad case, because the model objects are generally compatible with other methods for Something like the below might work, but it's ugly as sin and will probably fail somewhere down the line if/when broom relies on other methods for lm that are similarly incompatible.
|
Hi guys,
I am trying to use {estimatr} with a lot of downstream packages (such as {lindia} or {report}, or to do added variable plots with my own package) that rely on a model matrix that we would usually get from
broom::augment()
orggplot2::fortify()
.I know this is in your heads because I found this issue for
broom::fortify()
:tidymodels/broom#237
I'm just including it here as an issue because I took a first stab at trying to do it myself and got very stuck, very quickly.
The text was updated successfully, but these errors were encountered: