nobs.lmvar_no_fit: Number of observations for an object of class 'lmvar'

Description Usage Arguments Value Examples

Description

The number of observations in an object of class 'lmvar'.

Usage

1
2
## S3 method for class 'lmvar_no_fit'
nobs(object, ...)

Arguments

object

Object of class 'lmvar_no_fit' (hence it can also be of class 'lmvar')

...

For compatibility with nobs generic

Value

Integer containing the number of observations in the model in object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# As example we use the dataset 'attenu' from the library 'datasets'. The dataset contains
# the response variable 'accel' and two explanatory variables 'mag'  and 'dist'.
library(datasets)

# Create the model matrix for the expected values
X = cbind(attenu$mag, attenu$dist)
colnames(X) = c("mag", "dist")

# Create the model matrix for the standard deviations.
X_s = cbind(attenu$mag, 1 / attenu$dist)
colnames(X_s) = c("mag", "dist_inv")

# Carry out the fit
fit = lmvar(attenu$accel, X, X_s)

# Return the number of observations in the fit
nobs(fit)

# Check that this is equal to the number of observations in the dataset
nobs(fit) == nrow(attenu)

# Function also works on object of class 'lmvar_no_fit'
no_fit = lmvar_no_fit(attenu$accel, X, X_s)
nobs(no_fit)

lmvar documentation built on May 16, 2019, 5:06 p.m.