# NOT RUN {
## two dimensional ellipses
e1 <- list("c" = c(1,1), "P" = matrix(c(2,0,0,0.5), ncol = 2))
e2 <- list("c" = c(0,0), "S" = matrix(c(1, 0.2, 0.2, 2), ncol = 2), "r" = 1)
# note: it is not necessary to specify an ellipse radius "r"
feasible_overlap(list(e1, e2))
## regression example
# generate data
n <- 100
E <- rbinom(n, 1, 0.5)
X <- rnorm(n, E * 3, 1)
Y <- rnorm(n, 2 + 1.5 * X, 1)
# create confidence region ellipses
m0 <- lm(Y ~ X, data = data.frame(Y, X), subset = (E == 0))
m1 <- lm(Y ~ X, data = data.frame(Y, X), subset = (E == 1))
ConfRegion0 <- list(c = coefficients(m0), S = vcov(m0))
ConfRegion1 <- list(c = coefficients(m0), S = vcov(m0))
# find smallest radius
res <- feasible_overlap(list(ConfRegion0, ConfRegion1))
# this radius now corresponds to the chisq quantile at which
# the confidence regions intersect non-emptily.
# In other words the (1 - alpha)-confidence intervals intersect for alpha:
alpha <- pchisq(res$radii, 2)
# }
Run the code above in your browser using DataLab