vcov.cgaim {cgaim} | R Documentation |
Calculate Variance-Covariance Matrix for a Fitted CGAIM Object
Description
Returns the variance covariance matrix of the main parameters of a fitted cgaim
object. These parameters correspond to the index weights alpha
and the scaling coefficients beta
.
Usage
## S3 method for class 'cgaim'
vcov(object, parm = c("alpha", "beta"), type = c("normal",
"bootstrap"), B = 100, complete = TRUE, ...)
## S3 method for class 'boot.cgaim'
vcov(object, parm = c("alpha", "beta"),
complete = TRUE, ...)
Arguments
object |
A |
parm |
The model components for which to get confidence intervals.
Either |
type |
The type of confidence intervals. Either |
B |
The number of samples to be simulated. |
complete |
Indicates whether the full variance-covariance matrix should be returned when some of the parameters could not be estimated. If so, the matrix is padded with |
... |
Additional parameters to be passed to |
Details
Two types of computation are currently implemented in the function.
When type = "normal"
, variance-covariance matrices are computed assuming
components are normally distributed. Beta coefficients are treated as
regular linear regression coefficients and alpha
coefficients are assumed to follow a Truncated Multivariate Normal distribution.
The latter is obtained by simulating from TMVN (see tmvnorm
)
and computing the empirical variance covariance matrix from these simulations. The parameter B
controls the number of simulations from the TMVN (and is not used when parm = "beta"
).
When type = "bootstrap"
, the variance-covariance matrix is computed on Bootstrap replications. In this case boot.cgaim
is called internally and B
corresponds to the number of replications. Alternatively, the user can directly call boot.cgaim
and feed the result into vcov.boot.cgaim
(see examples).
Value
A variance-covariance matrix object.
References
Masselot, P. and others, 2022. Constrained groupwise additive index models. Biostatistics.
Pya, N., Wood, S.N., 2015. Shape constrained additive models. Stat. Comput. 25, 543–559.
Wood, S.N., 2017. Generalized Additive Models: An Introduction with R, 2nd ed, Texts in Statistical Science. Chapman and Hall/CRC.
See Also
boot.cgaim
for bootstrapping and confint.cgaim
for confidence intervals.
Examples
# A simple CGAIM
n <- 200
x1 <- rnorm(n)
x2 <- x1 + rnorm(n)
z <- x1 + x2
y <- z + rnorm(n)
df1 <- data.frame(y, x1, x2)
ans <- cgaim(y ~ g(x1, x2, acons = list(monotone = 1)), data = df1)
# (Truncated) Normal variance-covariance matrix
set.seed(1)
vcov(ans, B = 1000)
set.seed(1)
vcov(ans, parm = "alpha", B = 1000) # Same result
vcov(ans, parm = "beta", B = 1000)
# Confidence intervals by bootstrap (more computationally intensive, B should be increased)
set.seed(2)
vcov(ans, type = "boot", B = 10)
# Alternatively, bootstrap samples can be performed beforehand
set.seed(2)
boot1 <- boot.cgaim(ans, B = 10)
vcov(boot1)