getY: Get Model Response Variable

Description Usage Arguments Details Value Examples

View source: R/stdEff-fun.R

Description

Extract the response variable from a fitted model on the original or link scale.

Usage

1
getY(mod, data = NULL, link = FALSE, offset = FALSE, env = NULL)

Arguments

mod

A fitted model object, or a list or nested list of such objects.

data

An optional dataset, used to first refit the model(s).

link

Logical. If TRUE, return the GLM response variable on the link scale (see Details).

offset

Logical. If TRUE, include model offset(s) in the response.

env

Environment in which to look for model data (if none supplied). Defaults to the formula() environment.

Details

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 glt()).

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).

Value

A numeric vector comprising the response variable on the original or link scale, or an array, list of vectors/arrays, or nested list.

Examples

1
2
3
4
5
# All SEM responses (original scale)
head(getY(shipley.sem))

# Estimated response in link scale from binomial model
head(getY(shipley.sem$Live, link = TRUE))

semEff documentation built on Oct. 12, 2021, 5:06 p.m.