EVOLUTION-MANAGER
Edit File: logLik.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Extract Log-Likelihood</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for logLik {stats}"><tr><td>logLik {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Extract Log-Likelihood</h2> <h3>Description</h3> <p>This function is generic; method functions can be written to handle specific classes of objects. Classes which have methods for this function include: <code>"glm"</code>, <code>"lm"</code>, <code>"nls"</code> and <code>"Arima"</code>. Packages contain methods for other classes, such as <code>"fitdistr"</code>, <code>"negbin"</code> and <code>"polr"</code> in package <a href="https://CRAN.R-project.org/package=MASS"><span class="pkg">MASS</span></a>, <code>"multinom"</code> in package <a href="https://CRAN.R-project.org/package=nnet"><span class="pkg">nnet</span></a> and <code>"gls"</code>, <code>"gnls"</code> <code>"lme"</code> and others in package <a href="https://CRAN.R-project.org/package=nlme"><span class="pkg">nlme</span></a>. </p> <h3>Usage</h3> <pre> logLik(object, ...) ## S3 method for class 'lm' logLik(object, REML = FALSE, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>object</code></td> <td> <p>any object from which a log-likelihood value, or a contribution to a log-likelihood value, can be extracted.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>some methods for this generic function require additional arguments.</p> </td></tr> <tr valign="top"><td><code>REML</code></td> <td> <p>an optional logical value. If <code>TRUE</code> the restricted log-likelihood is returned, else, if <code>FALSE</code>, the log-likelihood is returned. Defaults to <code>FALSE</code>.</p> </td></tr> </table> <h3>Details</h3> <p><code>logLik</code> is most commonly used for a model fitted by maximum likelihood, and some uses, e.g. by <code><a href="AIC.html">AIC</a></code>, assume this. So care is needed where other fit criteria have been used, for example REML (the default for <code>"lme"</code>). </p> <p>For a <code>"glm"</code> fit the <code><a href="family.html">family</a></code> does not have to specify how to calculate the log-likelihood, so this is based on using the family's <code>aic()</code> function to compute the AIC. For the <code><a href="family.html">gaussian</a></code>, <code><a href="family.html">Gamma</a></code> and <code><a href="family.html">inverse.gaussian</a></code> families it assumed that the dispersion of the GLM is estimated and has been counted as a parameter in the AIC value, and for all other families it is assumed that the dispersion is known. Note that this procedure does not give the maximized likelihood for <code>"glm"</code> fits from the Gamma and inverse gaussian families, as the estimate of dispersion used is not the MLE. </p> <p>For <code>"lm"</code> fits it is assumed that the scale has been estimated (by maximum likelihood or REML), and all the constants in the log-likelihood are included. That method is only applicable to single-response fits. </p> <h3>Value</h3> <p>Returns an object of class <code>logLik</code>. This is a number with at least one attribute, <code>"df"</code> (<b>d</b>egrees of <b>f</b>reedom), giving the number of (estimated) parameters in the model. </p> <p>There is a simple <code>print</code> method for <code>"logLik"</code> objects. </p> <p>There may be other attributes depending on the method used: see the appropriate documentation. One that is used by several methods is <code>"nobs"</code>, the number of observations used in estimation (after the restrictions if <code>REML = TRUE</code>). </p> <h3>Author(s)</h3> <p>José Pinheiro and Douglas Bates </p> <h3>References</h3> <p>For <code>logLik.lm</code>: </p> <p>Harville, D.A. (1974). Bayesian inference for variance components using only error contrasts. <em>Biometrika</em>, <b>61</b>, 383–385. doi: <a href="https://doi.org/10.2307/2334370">10.2307/2334370</a>. </p> <h3>See Also</h3> <p><code><a href="../../nlme/html/logLik.lme.html">logLik.gls</a></code>, <code><a href="../../nlme/html/logLik.lme.html">logLik.lme</a></code>, in package <a href="https://CRAN.R-project.org/package=nlme"><span class="pkg">nlme</span></a>, etc. </p> <p><code><a href="AIC.html">AIC</a></code> </p> <h3>Examples</h3> <pre> x <- 1:5 lmx <- lm(x ~ 1) logLik(lmx) # using print.logLik() method utils::str(logLik(lmx)) ## lm method (fm1 <- lm(rating ~ ., data = attitude)) logLik(fm1) logLik(fm1, REML = TRUE) utils::data(Orthodont, package = "nlme") fm1 <- lm(distance ~ Sex * age, Orthodont) logLik(fm1) logLik(fm1, REML = TRUE) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>