model.extract              package:base              R Documentation

Extract Components from a Model Frame

Description:

     Returns the response, offset, subset, weights or other special
     components of a model frame passed as optional arguments to
     `model.frame'.

Usage:

     model.extract(frame, component)
     model.offset(x)
     model.response(data, type = "any")
     model.weights(x)

Arguments:

frame, x, data: A model frame.

component: The name of a components to extract, such as `"weights"',
          `"subset"'.

    type: One of `"any"', `"numeric"', `"double"'. Using the either of
          latter two coerces the result to have storage mode
          `"double"'.

Details:

     `model.offset' and `model.response' are equivalent to
     `model.frame(, "offset")' and `model.frame(, "response")'
     respectively.

     `model.weights' is slightly different from `model.frame(,
     "weights")' in not naming the vector it returns.

Value:

     The specified component of the model frame, usually a vector.

See Also:

     `model.frame', `offset'

Examples:

     data(esoph)
     a <- model.frame(cbind(ncases,ncontrols) ~ agegp+tobgp+alcgp, data=esoph)
     model.extract(a, "response")
     stopifnot(model.extract(a, "response") == model.response(a))

     a <- model.frame(ncases/(ncases+ncontrols) ~ agegp+tobgp+alcgp,
                      data = esoph, weights = ncases+ncontrols)
     model.response(a)
     model.extract(a, "weights")

     a <- model.frame(cbind(ncases,ncontrols) ~ agegp,
                      something = tobgp, data = esoph)
     names(a)
     stopifnot(model.extract(a, "something") == esoph$tobgp)

