vcov.gam.RdExtracts the Bayesian posterior covariance matrix of the
parameters or frequentist covariance matrix of the parameter estimators
from a fitted gam object.
# S3 method for class 'gam'
vcov(object, sandwich=FALSE, freq = FALSE, dispersion = NULL,unconditional=FALSE, ...)fitted model object of class gam as produced by gam().
compute sandwich estimate of covariance matrix. Currently expensive for discrete bam fits.
TRUE to return the frequentist covariance matrix of the
parameter estimators, FALSE to return the Bayesian posterior covariance
matrix of the parameters. The latter option includes the expected squared bias
according to the Bayesian smoothing prior.
a value for the dispersion parameter: not normally used.
if TRUE (and freq==FALSE) then the Bayesian
smoothing parameter
uncertainty corrected covariance matrix is returned, if available.
other arguments, currently ignored.
Basically, just extracts object$Ve, object$Vp or object$Vc (if available) from a gamObject, unless sandwich==TRUE in which case the sandwich estimate is computed (with or without the squared bias component).
A matrix corresponding to the estimated frequentist covariance matrix
of the model parameter estimators/coefficients, or the estimated posterior
covariance matrix of the parameters, depending on the argument freq.
Wood, S.N. (2017) Generalized Additive Models: An Introductio with R (2nd ed) CRC Press
require(mgcv)
n <- 100
x <- runif(n)
y <- sin(x*2*pi) + rnorm(n)*.2
mod <- gam(y~s(x,bs="cc",k=10),knots=list(x=seq(0,1,length=10)))
diag(vcov(mod))
#> (Intercept) s(x).1 s(x).2 s(x).3 s(x).4 s(x).5
#> 0.000417557 0.003943883 0.004927974 0.003582308 0.004079923 0.003016437
#> s(x).6 s(x).7 s(x).8
#> 0.003758695 0.003595161 0.003113030