depvar: Dependent (Response) Variable Extracted

depvarR Documentation

Dependent (Response) Variable Extracted

Description

A generic function that extracts the response/dependent variable from objects.

Usage

depvar(object, ...)

Arguments

object

An object that has some response/dependent variable.

...

Other arguments fed into the specific methods function of the model. The following mainly applies to "vglm" class objects. In particular, sometimes type = c("lm", "lm2") is available, in which case the first one is chosen if the user does not input a value. The latter value corresponds to argument form2, and sometimes a response for that is optional.

Another argument is muxypw (whose default is FALSE) which is whether object@y needs to be multiplied by the prior weight. This feature is useful for family functions that store sample proportions in object@y and the prior weights in object@prior.weights because sometimes the count response is needed, e.g., for vglmnet(). So if on object@family@infos() muxypw == FALSE and if Mux4vglmnet = TRUE then set depvar(object, muxypw = TRUE) to get the raw counts. Also, because roundmux = FALSE is the default, it is a good idea to set roundmux = TRUE to make sure the result is integer-valued, i.e., depvar(object, muxypw = TRUE, roundmux = TRUE). Note that recycling is used.

Details

By default this function is preferred to calling object@y, say.

Value

The response/dependent variable, usually as a matrix or vector.

Author(s)

Thomas W. Yee

See Also

model.matrix, vglm.

Examples

pneumo <- transform(pneumo, let = log(exposure.time))
(fit <- vglm(cbind(normal, mild, severe) ~ let, propodds, pneumo))
fit@y        # Sample proportions (not recommended)
depvar(fit)  # Better than using fit@y
weights(fit, type = "prior")  # Number of observations
# This is new:
fit@family@infos()$muxypw  # Proportion or count?
fit@family@infos()$Mux4vglmnet  # vglmnet needs counts?
fit@family@infos()$roundmux  # Product is integer-valued?
depvar(fit, muxypw = TRUE, roundmux = TRUE)  # Counts

VGAM documentation built on Dec. 4, 2025, 1:07 a.m.