Learn R Programming

maxLik (version 0.7-2)

nObs: Return number of observations for statistical models

Description

Returns number of observations for statistical models. The default method assumes presence of a component param$nObs in x.

Usage

nObs(x, ...)
## S3 method for class 'default':
nObs(x, \dots)
## S3 method for class 'lm':
nObs(x, \dots)

Arguments

x
a statistical model, such as created by lm
...
further arguments for methods

Value

  • numeric, number of observations

Details

This is a generic function. The default method returns the component x$param$nObs. The lm-method is based on qr-decomposition, in the same way as the does summary.lm.

See Also

nParam

Examples

Run this code
# Construct a simple OLS regression:
x1 <- runif(100)
x2 <- runif(100)
y <- 3 + 4*x1 + 5*x2 + rnorm(100)
m <- lm(y~x1+x2)  # estimate it
nObs(m)

Run the code above in your browser using DataLab