R/methods_gee.R

Defines functions p_value.geeglm ci.geeglm p_value.gee standard_error.gee

#' @export
standard_error.geeglm <- standard_error.default


#' @export
standard_error.gee <- function(model, method = NULL, ...) {
  cs <- stats::coef(summary(model))
  dots <- list(...)

  if (isTRUE(dots$robust) || !is.null(dots$vcov)) {
    se <- as.vector(cs[, "Robust S.E."])
  } else {
    se <- as.vector(cs[, "Naive S.E."])
  }

  .data_frame(Parameter = .remove_backticks_from_string(rownames(cs)), SE = se)
}


#' @export
p_value.gee <- function(model, method = NULL, ...) {
  cs <- stats::coef(summary(model))
  if (is.null(method)) {
    method <- "any"
  }
  dots <- list(...)

  if (isTRUE(dots$robust) || !is.null(dots$vcov)) {
    p <- 2 *
      stats::pt(
        abs(cs[, "Estimate"] / cs[, "Robust S.E."]),
        df = insight::get_df(x = model, type = method),
        lower.tail = FALSE
      )
  } else {
    p <- 2 *
      stats::pt(
        abs(cs[, "Estimate"] / cs[, "Naive S.E."]),
        df = insight::get_df(x = model, type = method),
        lower.tail = FALSE
      )
  }

  .data_frame(Parameter = .remove_backticks_from_string(rownames(cs)), p = as.vector(p))
}


#' @export
ci.geeglm <- function(x, ci = 0.95, method = "wald", ...) {
  .ci_generic(x, ci = ci, method = method, ...)
}


#' @export
p_value.geeglm <- function(model, method = "wald", ...) {
  stat <- insight::get_statistic(model)

  if (!is.null(stat)) {
    if (identical(method, "residual")) {
      dof <- insight::get_df(model, type = "residual")
      p <- as.vector(
        2 * stats::pt(sqrt(abs(stat$Statistic)), df = dof, lower.tail = FALSE)
      )
    } else {
      p <- as.vector(1 - stats::pchisq(stat$Statistic, df = 1))
    }
    .data_frame(Parameter = stat$Parameter, p = p)
  }
}

Try the parameters package in your browser

Any scripts or data that you put into this service are public.

parameters documentation built on Oct. 16, 2026, 1:07 a.m.