confint.cgaim {cgaim} | R Documentation |
Confidence intervals
Description
Computes confidence intervals for the CGAIM components.
Usage
## S3 method for class 'cgaim'
confint(object, parm, level = 0.95, type = c("normal",
"bootstrap"), B = 100, ...)
## S3 method for class 'boot.cgaim'
confint(object, parm, level = 0.95, ...)
Arguments
object |
A |
parm |
The model components for which to get confidence intervals.
One or several of: |
level |
The level of confidence intervals. Default to 0.95. |
type |
The type of confidence intervals. Either |
B |
The number of samples to be simulated. |
... |
Additional parameters to be passed to |
Details
Two types of confidence intervals are currently implemented in the function.
When type = "normal"
, confidence intervals are computed assuming
components are normally distributed. Beta coefficients are treated as
regular linear regression coefficients and g as regular smooth functions
estimated by (shape-constrained) generalized additive models. For alpha
coefficients, we consider a linear transformation mapping them to a
Truncated Multivariate Normal distribution (i.e. with only bound constraints).
Simulation from the TMVN are performed (see tmvnorm
)
and transformed
back into the original coefficient space (i.e. with linear constraints). The parameter B
controls the number of simulations from the TMVN.
Confidence intervals are computed as the percentiles of these simulated
coefficients, ensuring the confidence region is entirely within the feasible
region defined by the constraints.
When type = "bootstrap"
, confidence intervals are estimated by
percentile bootstrap. boot.cgaim
is called internally
to create B
samples of model components, and confidence intervals are then computed
as the percentiles of bootstrap samples. Alternatively, the user can directly
call boot.cgaim
and feed the result into
confint.boot.cgaim
.
Value
A list of confidence intervals. Contains one element per model
component in the parm
argument.
Note
Confidence intervals for the g functions are evaluated on the
same n
index values as the functions in 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.
DiCiccio, T.J., Efron, B., 1996. Bootstrap Confidence Intervals. Statistical Science 11, 189–212.
Carpenter, J., Bithell, J., 2000. Bootstrap confidence intervals: when, which, what? A practical guide for medical statisticians. Statistics in Medicine 19, 1141–1164.
See Also
boot.cgaim
for bootstrapping.
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)
# Normal confidence intervals
set.seed(1)
ci1 <- confint(ans, B = 1000)
ci1$alpha
ci1$beta
# Select only alphas: identical to above result
set.seed(1)
confint(ans, B = 1000, parm = "alpha")
# Select only betas: identical to above result
set.seed(1)
confint(ans, B = 1000, parm = "beta")
# Confidence intervals by bootstrap (more computationally intensive, B should be increased)
set.seed(2)
ci2 <- confint(ans, type = "boot", B = 10)
# Alternatively, bootstrap samples can be performed beforehand
set.seed(2)
boot1 <- boot.cgaim(ans, B = 10)
ci3 <- confint(boot1)