Learn R Programming

pls (version 2.8-5)

vcov.mvr: Calculate Variance-Covariance Matrix for a Fitted Model Object

Description

Returns the variance-covariance matrix of the coefficients of a Principal Component Regression.

Usage

# S3 method for mvr
vcov(object, ncomp, ...)

Value

A matrix of estimated covariances between regression coefficients.

Arguments

object

a fitted PCR object of class mvr.

ncomp

number of principal components to estimate vcov for.

...

additional arguments (not used).

Examples

Run this code
data(yarn)
yarn.pcr <- pcr(density ~ NIR, 6, data = yarn)
vc <- vcov(yarn.pcr, 3)

# Standard error of coefficients
se <- sqrt(diag(vc))
beta <- coef(yarn.pcr, ncomp = 3)

# Plot regression coefficients with two standard errors shading.
plot(beta, type = 'l',
     panel.first = polygon(x = c(1:268, 268:1),
                           y = c(beta+2*se, rev(beta-2*se)),
                           col = 'lightblue',
                           border = NA))

Run the code above in your browser using DataLab