Skip to content

no .resid column with augment.lm and newdata #124

@cderv

Description

@cderv

help page says that with newdata argument supplied, 3 columns are added to the dataset.

When newdata is supplied, augment.lm returns one row for each observation, with three columns added to the new data:

  • .fitted Fitted values of model
  • .se.fit Standard errors of fitted values
  • .resid Residuals of fitted values on the new data

However only 2 are there - no .resid column is calculated

library(dplyr)
library(broom)

train <- mtcars %>%
  sample_frac(0.7)
test <- setdiff(mtcars, train)


model <- lm(mpg ~ cyl + disp, data= train)

augment(model, newdata = test) %>% 
  names()
#>  [1] "mpg"     "cyl"     "disp"    "hp"      "drat"    "wt"      "qsec"   
#>  [8] "vs"      "am"      "gear"    "carb"    ".fitted" ".se.fit"

So either, we could add a .resid column but it implies some calculation or at least the help page should be modified.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions