diff --git a/main/coverage-report/index.html b/main/coverage-report/index.html index d2aaeec137..0d44a03ee3 100644 --- a/main/coverage-report/index.html +++ b/main/coverage-report/index.html @@ -94,7 +94,7 @@ font-size: 11px; }
arm <- variables$arm
covariates <- variables$covariates
offset <- .df_row[[variables$offset]]
formula <- stats::as.formula(paste0(
.var, " ~ ",
paste(covariates, collapse = " + "),
arm
glm_fit <- stats::glm(
formula = formula,
offset = offset,
data = .df_row,
family = stats::poisson(link = "log")
emmeans_fit <- emmeans::emmeans(
glm_fit,
specs = arm,
data = .df_row,
type = "response",
offset = 0,
weights = weights
list(
glm_fit = glm_fit,
emmeans_fit = emmeans_fit
arm <- variables$arm
covariates <- variables$covariates
offset <- .df_row[[variables$offset]]
formula <- stats::as.formula(paste0(
.var, " ~ ",
paste(covariates, collapse = " + "),
arm
glm_fit <- stats::glm(
formula = formula,
offset = offset,
data = .df_row,
family = stats::quasipoisson(link = "log")
emmeans_fit <- emmeans::emmeans(
glm_fit,
specs = arm,
data = .df_row,
type = "response",
offset = 0,
weights = weights
list(
glm_fit = glm_fit,
emmeans_fit = emmeans_fit
poisson = h_glm_poisson(.var, .df_row, variables, weights),
quasipoisson = h_glm_quasipoisson(.var, .df_row, variables, weights),
alpha <- 1 - conf_level
p <- 1 - alpha / 2
arm_levels <- levels(.df_row[[arm]])
out <- lapply(arm_levels, function(lev) {
temp <- .df_row
temp[[arm]] <- factor(lev, levels = arm_levels)
mf <- stats::model.frame(obj$formula, data = temp)
X <- stats::model.matrix(obj$formula, data = mf) # nolint
rate <- stats::predict(obj, newdata = mf, type = "response")
rate_hat <- mean(rate)
zz <- colMeans(rate * X)
se <- sqrt(as.numeric(t(zz) %*% stats::vcov(obj) %*% zz))
rate_lwr <- rate_hat * exp(-stats::qnorm(p) * se / rate_hat)
rate_upr <- rate_hat * exp(stats::qnorm(p) * se / rate_hat)
c(rate_hat, rate_lwr, rate_upr)
names(out) <- arm_levels
out <- do.call(rbind, out)
if ("negbin" %in% class(obj)) {
colnames(out) <- c("rate", "asymp.LCL", "asymp.UCL")
out <- as.data.frame(out)
out[[arm]] <- rownames(out)
out