logLik                 package:stats                 R Documentation

_E_x_t_r_a_c_t _L_o_g-_L_i_k_e_l_i_h_o_o_d

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

     This function is generic; method functions can be written to
     handle specific classes of objects.  Classes which already have
     methods for this function include: 'glm', 'lm', 'nls' and 'gls',
     'lme' and others in package 'nlme'.

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

     logLik(object, ...)

     ## S3 method for class 'lm':
     logLik(object, REML = FALSE, ...)

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

  object: any object from which a log-likelihood value, or a
          contribution to a log-likelihood value, can be extracted.

     ...: some methods for this generic function require additional
          arguments.

    REML: an optional logical value.  If 'TRUE' the restricted
          log-likelihood is returned, else, if 'FALSE', the
          log-likelihood is returned.  Defaults to 'FALSE'.

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

     For a 'glm' fit the 'family' does not have to specify how to
     calculate the log-likelihood, so 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.

     Note 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:

     Returns an object, say 'r', of class 'logLik' which is a number
     with attributes, 'attr(r, "df")' (*d*egrees of *f*reedom) giving
     the number of parameters in the model. There's a simple 'print'
     method for 'logLik' objects.

     The details depend on the method function used; see the
     appropriate documentation.

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

     Jose Pinheiro and Douglas Bates

_R_e_f_e_r_e_n_c_e_s:

     For 'logLik.lm':

     Harville, D.A. (1974). Bayesian inference for variance components
     using only error contrasts. _Biometrika_, *61*, 383-385.

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

     'logLik.gls', 'logLik.lme', in package 'nlme', etc.

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

     x <- 1:5
     lmx <- lm(x ~ 1)
     logLik(lmx) # using print.logLik() method
     str(logLik(lmx))

     ## lm method
     (fm1 <- lm(rating ~ ., data = attitude))
     logLik(fm1)
     logLik(fm1, REML = TRUE)

     res <- try(data(Orthodont, package="nlme"))
     if(!inherits(res, "try-error")) {
       fm1 <- lm(distance ~ Sex * age, Orthodont)
       print(logLik(fm1))
       print(logLik(fm1, REML = TRUE))
     }

