prediction.frame           package:memisc           R Documentation

_P_r_o_d_u_c_e _a _D_a_t_a _F_r_a_m_e _o_f _P_r_e_d_i_c_t_i_o_n_s _a_n_d _I_n_d_e_p_e_n_d_e_n_t _V_a_r_i_a_b_l_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     'prediction.frame' produces a data frame that contains the
     independent variables of a model together with model generated
     predictions.

_U_s_a_g_e:

       ## Default S3 method:
       prediction.frame(object,newdata=NULL,...,
               residuals=c("none", "deviance", "pearson", "working",
                           "standardized", "studentized"))

_A_r_g_u_m_e_n_t_s:

  object: a model object from which predictions are generated.

 newdata: an optional data frame for out-of-sample predictions.

     ...: further arguments passed to 'predict'.

residuals: a character vector that specifies residuals that are added
          to the resulting data frame.

_V_a_l_u_e:

     A data frame.

_E_x_a_m_p_l_e_s:

     lm1 <- lm(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings)
     lm2 <- lm(sr ~ pop15 + pop75 + dpi + ddpi + pop15*dpi, data = LifeCycleSavings)

     str(prediction.frame(lm1))
     str(prediction.frame(lm1, se.fit=TRUE))
     str(prediction.frame(lm1, interval="prediction"))
     str(prediction.frame(lm1, type="terms"))
     str(prediction.frame(lm1,
                       se.fit=TRUE,
                       type="terms"))

     str(prediction.frame(lm1,
                       se.fit=TRUE,
                       type="terms",
                       residuals="working"))

     str(prediction.frame(lm1,
                       se.fit=TRUE,
                       type="terms",
                       residuals="deviance"))

     str(prediction.frame(lm2,
                       se.fit=TRUE,
                       type="terms",
                       residuals="standardized"))

     berkeley <- aggregate(Table(Admit,Freq)~.,data=UCBAdmissions)
     berk2 <- glm(cbind(Admitted,Rejected)~Gender+Dept,data=berkeley,family="binomial")

     str(prediction.frame(berk2,
                       se.fit=TRUE,
                       type="terms",
                       residuals="studentized"))

