Rev 84534 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/stats/man/nobs.Rd% Part of the R package, https://www.R-project.org% Copyright 1995-2012 R Core Team% Distributed under GPL 2 or later\name{nobs}\alias{nobs}\alias{nobs.default}\title{Extract the Number of Observations from a Fit}\description{Extract the number of \sQuote{observations} from a model fit. This isprincipally intended to be used in computing BIC (see \code{\link{AIC}}).}\usage{nobs(object, ...)\method{nobs}{default}(object, use.fallback = FALSE, ...)}\arguments{\item{object}{a fitted model object.}\item{use.fallback}{logical: should fallback methods be used to try toguess the value?}\item{\dots}{further arguments to be passed to methods.}}\details{This is a generic function, with an S4 generic in package \pkg{stats4}.There are methods in this package for objects of classes\code{"\link{lm}"}, \code{"\link{glm}"}, \code{"\link{nls}"} and\code{"\link{logLik}"}, as well as a default method (which throws anerror, unless \code{use.fallback = TRUE} when it looks for\code{weights} and \code{residuals} components -- use with care!).The main usage is in determining the appropriate penalty for BIC, but\code{nobs} is also used by the stepwise fitting methods\code{\link{step}}, \code{\link{add1}} and \code{\link{drop1}} as aquick check that different fits have been fitted to the same set ofdata (and not, say, that further rows have been dropped because of NAsin the new predictors).For \code{lm}, \code{glm} and \code{nls} fits, observations with zeroweight are not included.}\value{A single number, normally an integer. Could be \code{NA}.}\seealso{\code{\link{AIC}}.}\keyword{models}