model.extract             package:stats             R Documentation

_E_x_t_r_a_c_t _C_o_m_p_o_n_e_n_t_s _f_r_o_m _a _M_o_d_e_l _F_r_a_m_e

_D_e_s_c_r_i_p_t_i_o_n:

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

_U_s_a_g_e:

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

_A_r_g_u_m_e_n_t_s:

frame, x, data: A model frame.

component: literal character string or name. The name of a component 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"'.

_D_e_t_a_i_l_s:

     '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 'etastart' and 'mustart' components of a 'glm'
     fit.

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

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

_V_a_l_u_e:

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

_S_e_e _A_l_s_o:

     'model.frame', 'offset'

_E_x_a_m_p_l_e_s:

     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)

