Rev 27525 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{logLik}\alias{logLik}\alias{print.logLik}\alias{str.logLik}% \alias{as.data.frame.logLik}\alias{logLik.lm}\title{Extract Log-Likelihood}\usage{logLik(object, \dots)\method{logLik}{lm}(object, REML = FALSE, \dots)%%\method{as.data.frame}{logLik}(x, row.names = NULL, optional = FALSE)%notyet print(logLik(*), ...)%notyet str(logLik(*), ...)}\arguments{\item{object}{any object from which a log-likelihood value, or acontribution to a log-likelihood value, can be extracted.}\item{\dots}{some methods for this generic function require additionalarguments.}\item{REML}{an optional logical value. If \code{TRUE} the restrictedlog-likelihood is returned, else, if \code{FALSE}, thelog-likelihood is returned. Defaults to \code{FALSE}.}% \item{x}{an object of class \code{logLik}.}% \item{row.names, optional}{arguments to the \code{\link{as.data.frame}}% method; see its documentation.}}\description{This function is generic; method functions can be written to handlespecific classes of objects. Classes which already have methods forthis function include: \code{glm}, \code{lm}, \code{nls}and \code{gls}, \code{lme} and others in package \pkg{nlme}.% \code{corStruct}, \code{lmList}, \code{lmeStruct}, \code{reStruct}, and% \code{varFunc}.}\details{For a \code{glm} fit the \code{\link{family}} does not have to specifyhow to calculate the log-likelihood, so this is based on thefamily's function to computethe AIC. For \code{\link{gaussian}}, \code{\link{Gamma}} and\code{\link{inverse.gaussian}}families it assumed that the dispersion of the GLM is estimated andhas been included in the AIC, and for all other families it is assumedthat the dispersion is known.Note that this procedure is not completely accurate for the gamma andinverse gaussian families, as the estimate of dispersion used is notthe MLE.}\value{Returns an object, say \code{r}, of class \code{logLik} which is anumber with attributes, \code{attr(r, "df")} (\bold{d}egrees of\bold{f}reedom) giving the number of parameters in the model.There's a simple \code{print} method for \code{logLik} objects.The details depend on the method function used; see the appropriatedocumentation.}\seealso{\code{\link[nlme]{logLik.gls}}, \code{\link[nlme]{logLik.lme}}, etc.}\references{For \code{logLik.lm}:Harville, D.A. (1974).Bayesian inference for variance components using only error contrasts.\emph{Biometrika}, \bold{61}, 383--385.}\author{Jose Pinheiro and Douglas Bates}\examples{x <- 1:5lmx <- lm(x ~ 1)logLik(lmx) # using print.logLik() methodstr(logLik(lmx))## lm methoddata(attitude)(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))}}\keyword{models}