| pm_data | R Documentation |
pm_data() returns the rows used to fit a model (after subset and missing values), with the response
on the scale of the model and on the original scale: .y is the response as modelled (e.g.
log(y + 1); for a GLM the observed response, as a proportion for cbind(successes, failures)), and
.y_orig the response on the original scale (y), taken from the data or, when only the transformed
response is available, computed with the inverse transformation. A transformation given to
predictmeans as trans (for a response transformed before the fit) is used the same way.
It is also the generic through which a new model class can say where its data are (see pm_coef).
pm_data(model, ...)
## Default S3 method:
pm_data(model, data = NULL, trans = NULL, ...)
model |
A fitted model, or a |
... |
Not used. |
data |
Optional: the data the model was fitted to, when they cannot be found from the model. |
trans |
Optional: a function that back-transforms the response (as |
A data frame with the variables of the data, .y, .y_orig and .weights (prior weights,
when there are any), and attribute "response": a list with expr (the response as written, e.g.
"log(y + 1)"), name (the response variable, e.g. "y"), scale of the model's means
("identity", "transformed" or "link"), link, family and back (what
back-transforms the means: "link", "formula", "trans" or NA).
oats <- as.data.frame(nlme::Oats)
fm <- lm(log(yield + 1) ~ Variety, data = oats)
d <- pm_data(fm)
head(d[c("yield", ".y", ".y_orig")])
attr(d, "response")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.