logLik.glm               package:base               R Documentation

_E_x_t_r_a_c_t _L_o_g-_L_i_k_e_l_i_h_o_o_d _f_r_o_m _a_n _g_l_m _O_b_j_e_c_t

_D_e_s_c_r_i_p_t_i_o_n:

     Returns the log-likelihood value of the generalized linear model
     represented by `object' evaluated at the estimated coefficients.

_U_s_a_g_e:

     logLik(object, ...)

_A_r_g_u_m_e_n_t_s:

  object: an object inheriting from class `"glm"'.

     ...: further arguments to be passed to or from methods.

_D_e_t_a_i_l_s:

     As a `family' does not have to specify how to calculate the
     log-likelihood, this is based on the family's function to compute
     the AIC.  For `gaussian', `Gamma' and `inverse.gaussian' families
     it assumed that the dispersion of the GLM is estimated and has
     been included in the AIC, and for all other families it is assumed
     that the dispersion is known.

     Not that this procedure is not completely accurate for the gamma
     and inverse gaussian families, as the estimate of dispersion used
     is not the MLE.

_V_a_l_u_e:

     the log-likelihood of the linear model represented by `object'
     evaluated at the estimated coefficients.

_S_e_e _A_l_s_o:

     `glm', `logLik.lm'

_E_x_a_m_p_l_e_s:

     ##-- Continuing the  glm(.) example:
     Eq <- function(x,y) all.equal(x,y, tol = 1e-12)
     stopifnot(Eq(AIC(anorex.1), anorex.1$aic),
               Eq(AIC(g1), g1$aic),
               Eq(AIC(g2), g2$aic))
     ## next was wrong in 1.4.1
     x <- 1:10
     lmx <- logLik(lm(x ~ 1)); glmx <- logLik(glm(x ~ 1))
     stopifnot(all.equal(as.vector(lmx), as.vector(glmx)),
               all.equal(attr(lmx, 'df'), attr(glmx, 'df')))

