[WIP] topmodels - #1159
Conversation
|
@zeileis I have not tried too many things yet, but at first glance what we discussed seems to work well. See above for installation and examples. |
|
Vincent, really cool, thanks! I did not try many things, yet, but noticed the following. While Also, the Thus, instead of More tomorrow! |
|
TODO:
|
In general, I like verbosity, but in this particular case I feel that it might be best to be consistent with A lot of users are asking me to implement prediction intervals in Is this something that library("topmodels")
library("marginaleffects")
sim <- function(...) {
N <- 500
dat <- data.frame(x = rnorm(N))
dat$y <- dat$x + rnorm(N)
idx <- sample(1:N, N / 2)
train <- dat[idx, ]
test <- dat[-idx, ]
m <- glm(y ~ x, data = train)
p <- do.call(cbind, list(
procast(m, newdata = test, type = "mean"),
procast(m, newdata = test, type = "quantile", at = .05),
procast(m, newdata = test, type = "quantile", at = .95)
))
p <- setNames(p, c("estimate", "conf.low", "conf.high"))
p$truth <- test$y
coverage <- mean(p$truth < p$conf.high & p$truth > p$conf.low)
return(coverage)
}
mean(sapply(seq_len(100), sim))
> [1] 0.89572 |
Install:
Examples seem to work: