{"action":"created","issue":{"url":"https://api.github.com/repos/tidyverse/broom/issues/158","repository_url":"https://api.github.com/repos/tidyverse/broom","labels_url":"https://api.github.com/repos/tidyverse/broom/issues/158/labels{/name}","comments_url":"https://api.github.com/repos/tidyverse/broom/issues/158/comments","events_url":"https://api.github.com/repos/tidyverse/broom/issues/158/events","html_url":"https://github.com/tidyverse/broom/issues/158","id":173924349,"node_id":"MDU6SXNzdWUxNzM5MjQzNDk=","number":158,"title":"Clarity regarding GLM","user":{"login":"jonocarroll","id":9496865,"node_id":"MDQ6VXNlcjk0OTY4NjU=","avatar_url":"https://avatars2.githubusercontent.com/u/9496865?v=4","gravatar_id":"","url":"https://api.github.com/users/jonocarroll","html_url":"https://github.com/jonocarroll","followers_url":"https://api.github.com/users/jonocarroll/followers","following_url":"https://api.github.com/users/jonocarroll/following{/other_user}","gists_url":"https://api.github.com/users/jonocarroll/gists{/gist_id}","starred_url":"https://api.github.com/users/jonocarroll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonocarroll/subscriptions","organizations_url":"https://api.github.com/users/jonocarroll/orgs","repos_url":"https://api.github.com/users/jonocarroll/repos","events_url":"https://api.github.com/users/jonocarroll/events{/privacy}","received_events_url":"https://api.github.com/users/jonocarroll/received_events","type":"User","site_admin":false},"labels":[{"id":954411753,"node_id":"MDU6TGFiZWw5NTQ0MTE3NTM=","url":"https://api.github.com/repos/tidyverse/broom/labels/feature-request","name":"feature-request","color":"d074db","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-30T03:52:39Z","updated_at":"2018-07-14T00:34:56Z","closed_at":null,"author_association":"NONE","body":"This took me far too long to solve, so some additional notes might be useful to others.\n\nIt seems there's no specific method for `augment`ing GLMs, and as such they fall back to `augment.lm`, since \n\n> glm returns an object of class inheriting from \"glm\" which inherits from the class \"lm\".\n\nThis isn't particularly clear if one tries searching for `augment.glm`. The context for this is that I was trying to find out which residuals are being calculated as the `.resid` column, which differs for `lm` and `glm`; these are (by default) deviance residuals for `glm` and working residuals for `lm`. The README claims that for `augment`:\n\n> .resid: residuals: the actual y values minus the fitted values\n\nwhich isn't the case for `glm`.\n\nAfter hunting through the source, I eventually found that I needed to specify `type.residuals` in the call to `augment`. This took some time though, as `augment.lm` doesn't show up as an exported function (can't use it by name) for whatever reason, so I couldn't even check the raw code for it quickly. `?augment` does link to `augment.lm` which is where I did find the required argument.\n\nCould I suggest at least adding an alias for `augment.glm` that points to `augment.lm`? Or better yet, its own `tidy.glm` help page with useful examples?\n\nPotential examples:\n\n```\nmtcarsglm <- glm(cyl ~ mpg, data = mtcars, family = poisson())\n\nsummary(mtcarsglm)\n#> Deviance Residuals: \n#>   Min       1Q   Median       3Q      Max  \n#> -0.7316  -0.2582   0.1041   0.2098   0.6794  \n\nfivenum(residuals(mtcarsglm, type = \"deviance\"))\n#> Volvo 142E    Porsche 914-2        Mazda RX4      AMC Javelin Pontiac Firebird \n#> -0.7316372       -0.2674050        0.1041252        0.2190416        0.6793560 \n\nfivenum(augment(mtcarsglm)$.resid)  ## **default**\n#> -0.7316372 -0.2674050  0.1041252  0.2190416  0.6793560\n\nfivenum(residuals(mtcarsglm, type = \"working\"))\n#> Volvo 142E    Porsche 914-2        Mazda RX4      AMC Javelin Pontiac Firebird \n#> -0.29164500      -0.11270417       0.04374193       0.08164739       0.28428369 \n\nfivenum(augment(mtcarsglm, type.residuals = \"working\")$.resid)\n#> [1] -0.29164500 -0.11270417  0.04374193  0.08164739  0.28428369\n\n```\n"},"comment":{"url":"https://api.github.com/repos/tidyverse/broom/issues/comments/404985305","html_url":"https://github.com/tidyverse/broom/issues/158#issuecomment-404985305","issue_url":"https://api.github.com/repos/tidyverse/broom/issues/158","id":404985305,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNDk4NTMwNQ==","user":{"login":"alexpghayes","id":15078251,"node_id":"MDQ6VXNlcjE1MDc4MjUx","avatar_url":"https://avatars3.githubusercontent.com/u/15078251?v=4","gravatar_id":"","url":"https://api.github.com/users/alexpghayes","html_url":"https://github.com/alexpghayes","followers_url":"https://api.github.com/users/alexpghayes/followers","following_url":"https://api.github.com/users/alexpghayes/following{/other_user}","gists_url":"https://api.github.com/users/alexpghayes/gists{/gist_id}","starred_url":"https://api.github.com/users/alexpghayes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexpghayes/subscriptions","organizations_url":"https://api.github.com/users/alexpghayes/orgs","repos_url":"https://api.github.com/users/alexpghayes/repos","events_url":"https://api.github.com/users/alexpghayes/events{/privacy}","received_events_url":"https://api.github.com/users/alexpghayes/received_events","type":"User","site_admin":false},"created_at":"2018-07-14T00:34:56Z","updated_at":"2018-07-14T00:34:56Z","author_association":"COLLABORATOR","body":"Now that `augment.glm` has it's own documentation, that would be a natural place to put this."}}
{"actor":{"display_login":"alexpghayes"}}