Skip to content

.resid column not present with variables are log transformed #946

@Amogh-Joshi

Description

@Amogh-Joshi

When you are ready to file the bug 🐛 report, please delete everything above this line:
< -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

The problem

I'm having trouble with getting the residual values when we transform the variable. Usually the tibble has 9 columns but for the log transformation, it just provides 8. This issue is not present when the variable is pre-transformed.

Reproducible example

## copy your code to the clipboard and run:
reprex::reprex(si = TRUE)
library(reprex)

library(alr4)
#> Loading required package: car
#> Loading required package: carData
#> Loading required package: effects
#> Registered S3 methods overwritten by 'lme4':
#>   method                          from
#>   cooks.distance.influence.merMod car 
#>   influence.merMod                car 
#>   dfbeta.influence.merMod         car 
#>   dfbetas.influence.merMod        car
#> lattice theme set by effectsTheme()
#> See ?effectsTheme for details.
library(broom)


modelUN <- lm(I(log(fertility)) ~ I(log(ppgdp)), data = UN11)

augment(modelUN)
#> # A tibble: 199 x 8
#>    .rownames `I(log(fertilit~ `I(log(ppgdp))` .fitted .std.resid    .hat .sigma
#>    <chr>             <I<dbl>>        <I<dbl>>   <dbl>   <I<dbl>>   <dbl>  <dbl>
#>  1 Afghanis~            1.79             6.21   1.38    1.34     0.0156   0.306
#>  2 Albania              0.422            8.21   0.965  -1.77     0.00516  0.305
#>  3 Algeria              0.762            8.41   0.924  -0.530    0.00503  0.308
#>  4 Angola               1.64             8.37   0.931   2.30     0.00504  0.304
#>  5 Anguilla             0.693            9.53   0.692   0.00500  0.00739  0.308
#>  6 Argentina            0.776            9.12   0.776  -0.000217 0.00593  0.308
#>  7 Armenia              0.551            8.02   1.00   -1.48     0.00544  0.306
#>  8 Aruba                0.513           10.0    0.586  -0.239    0.0102   0.308
#>  9 Australia            0.667           11.0    0.397   0.889    0.0179   0.307
#> 10 Austria              0.297           10.7    0.445  -0.486    0.0156   0.308
#> # ... with 189 more rows, and 1 more variable: .cooksd <I<dbl>>

Created on 2020-10-08 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions