\HeaderA{model.extract}{Extract Components from a Model Frame}{model.extract}
\aliasA{model.offset}{model.extract}{model.offset}
\aliasA{model.response}{model.extract}{model.response}
\aliasA{model.weights}{model.extract}{model.weights}
\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{\LinkA{model.frame}{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 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.  It is also useful to extract
e.g. the \code{etastart} and \code{mustart} components of a
\code{\LinkA{glm}{glm}} fit.

\code{model.offset} and \code{model.response} are equivalent to
\code{model.extract(, "offset")} and \code{model.extract(, "response")}
respectively.  \code{model.offset} sums any terms specified by
\code{\LinkA{offset}{offset}} terms in the formula or by \code{offset} arguments
in the call producing the model frame: it does check that the offset
is numeric.

\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{\LinkA{model.frame}{model.frame}}, \code{\LinkA{offset}{offset}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
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}

