nObs: Return number of observations for statistical models

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/nObs.R

Description

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

Usage

1
2
3
4
5
nObs(x, ...)
## Default S3 method:
nObs(x, ...)
## S3 method for class 'lm'
nObs(x, ...)

Arguments

x

a statistical model, such as created by lm

...

further arguments for methods

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.

Value

numeric, number of observations

Author(s)

Ott Toomet, otoomet@econ.au.dk

See Also

nParam

Examples

1
2
3
4
5
6
# 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)

miscTools documentation built on Dec. 9, 2019, 3 a.m.

Related to nObs in miscTools...