termPredictors              package:gnm              R Documentation

_E_x_t_r_a_c_t _T_e_r_m _C_o_n_t_r_i_b_u_t_i_o_n_s _t_o _P_r_e_d_i_c_t_o_r

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

     'termPredictors' is a generic function which extracts the
     contribution of each term to the predictor from a fitted model
     object.

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

     termPredictors(object, ...)

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

  object: a fitted model object. 

     ...: additional arguments for method functions.  

_D_e_t_a_i_l_s:

     The default method assumes that the predictor is linear and
     calculates the contribution of each term from the model matrix and
     fitted coefficients. A method is also available for 'gnm' objects.

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

     A matrix with the additive components of the predictor in labelled
     columns.

_A_u_t_h_o_r(_s):

     Heather Turner

_S_e_e _A_l_s_o:

     'gnm'

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

     ## Linear model
     G <- gl(4, 6)
     x <- 1:24
     y <- rnorm(24, 0, 1)
     lmGx <- lm(y ~ G + x)
     contrib <- termPredictors(lmGx)
     contrib
     all.equal(as.numeric(rowSums(contrib)), as.numeric(lmGx$fitted)) #TRUE

     ## Generalized linear model
     y <- cbind(rbinom(24, 10, 0.5), rep(10, 24))
     glmGx <- glm(y ~ G + x, family = binomial)
     contrib <- termPredictors(glmGx)
     contrib
     all.equal(as.numeric(rowSums(contrib)),
               as.numeric(glmGx$linear.predictors)) #TRUE

     ## Generalized nonlinear model
     A <- gl(4, 6)
     B <- gl(6, 1, 24)
     y <- cbind(rbinom(24, 10, 0.5), rep(10, 24))
     set.seed(1)
     gnmAB <- gnm(y ~ A + B + Mult(A - 1, B - 1), family = binomial)
     contrib <- termPredictors(gnmAB)
     contrib
     all.equal(as.numeric(rowSums(contrib)),
               as.numeric(gnmAB$predictors)) #TRUE

