\Header{model.extract}{Extract Components from a Model Frame}
\alias{model.offset}{model.extract}
\alias{model.response}{model.extract}
\alias{model.weights}{model.extract}
\keyword{manip}{model.extract}
\keyword{programming}{model.extract}
\keyword{models}{model.extract}
\begin{Description}\relax
Returns the response, offset, subset, weights or other
special components of a model frame passed as optional arguments to
\code{\Link{model.frame}}.\end{Description}
\begin{Usage}
\begin{verbatim}
model.extract(frame, component)
model.offset(x)
model.response(data, type = "any")
model.weights(x)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{frame, x, data}] A model frame.
\item[\code{component}] literal character string or name. The name of a
component to extract, such as \code{"weights"}, \code{"subset"}.
\item[\code{type}] One of \code{"any"}, \code{"numeric"}, \code{"double"}.
Using the either of latter two coerces the result to have
storage mode \code{"double"}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{model.extract} is provided for compatibility with S, which does
not have the more specific functions.

\code{model.offset} and
\code{model.response} are equivalent to \code{model.frame(, "offset")}
and \code{model.frame(, "response")} respectively.

\code{model.weights} is slightly different from
\code{model.frame(, "weights")} in not naming the vector it returns.\end{Details}
\begin{Value}
The specified component of the model frame, usually a vector.\end{Value}
\begin{SeeAlso}\relax
\code{\Link{model.frame}}, \code{\Link{offset}}\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
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)
\end{ExampleCode}
\end{Examples}

