# 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)
# Use function to compute confidence intervals (B should be increased)
set.seed(1989)
boot1 <- boot.cgaim(ans, B = 10)
ci1 <- confint(boot1)
# Produces the same result as
set.seed(1989)
ci2 <- confint(ans, type = "boot", B = 10)
# Create sampling beforehand
bsamp <- matrix(sample(1:n, n * 10, replace = TRUE), n)
boot2 <- boot.cgaim(ans, bsamples = bsamp)
# Parallel computing (two cores)
# \donttest{
boot3 <- boot.cgaim(ans, nc = 2)
# }
Run the code above in your browser using DataLab