Extract the response variable from a fitted model on the original or link scale.
getY(mod, data = NULL, link = FALSE, offset = FALSE, env = NULL)
A fitted model object, or a list or nested list of such objects.
An optional dataset, used to first refit the model(s).
Environment in which to look for model data (if none supplied).
Defaults to the
A numeric vector comprising the response variable on the original or link scale, or an array, list of vectors/arrays, or nested list.
getY() will return the response variable from a model by summing
the fitted values and the response residuals. If
link = TRUE and the
model is a GLM, the response is transformed to the link scale. If this
results in undefined values, an estimate based on the 'working' response
variable of the GLM is returned instead (see
Any offset variables are subtracted from the response by default. This means that, for example, rates rather than raw counts will be returned for poisson GLMs (where applicable).
# All SEM responses (original scale) head(getY(shipley.sem))#> DD Date Growth Live #> 1 160.5703 115.4956 61.36852 1 #> 2 158.9896 118.4959 43.77182 1 #> 3 159.9262 115.8836 44.74663 1 #> 4 161.1282 110.9889 48.20004 1 #> 5 157.3778 120.9946 50.02237 1 #> 6 160.6120 114.2315 56.29615 1# Estimated response in link scale from binomial model head(getY(shipley.sem$Live, link = TRUE))#> 1 2 3 4 5 6 #> 18.56607 18.56607 18.56607 18.56607 18.56607 18.56607