nobs

0th

Percentile

Extract the Number of Observations from a Fit.

Extract the number of ‘observations’ from a model fit. This is principally intended to be used in computing BIC (see AIC).

Keywords
models
Usage
nobs(object, ...)

# S3 method for default nobs(object, use.fallback = FALSE, ...)

Arguments
object

A fitted model object.

use.fallback

logical: should fallback methods be used to try to guess the value?

Further arguments to be passed to methods.

Details

This is a generic function, with an S4 generic in package stats4. There are methods in this package for objects of classes "lm", "glm", "nls" and "logLik", as well as a default method (which throws an error, unless use.fallback = TRUE when it looks for weights and residuals components -- use with care!).

The main usage is in determining the appropriate penalty for BIC, but nobs is also used by the stepwise fitting methods step, add1 and drop1 as a quick check that different fits have been fitted to the same set of data (and not, say, that further rows have been dropped because of NAs in the new predictors).

For lm, glm and nls fits, observations with zero weight are not included.

Value

A single number, normally an integer. Could be NA.

See Also

AIC.

Aliases
  • nobs
  • nobs.default
Documentation reproduced from package stats, version 3.5.0, License: Part of R 3.5.0

Community examples

Looks like there are no examples yet.