R/fit_logit.R

Defines functions summary.fit_logit coef.fit_logit fit_logit

Documented in fit_logit

#' Fit logistic regression
#'
#' This function is a wrapper around `stats::glm` for a piped workflows.
#' @param data `[data.frame]` \cr The data used to fit a model.
#' @param formula `[formula]` \cr The model formula.
#' @param ... Further arguments passed to `stats::glm`.
#' @name fit_logit
#' @returns A list with the model output.
#' @export
fit_logit <- function(data, formula, ...) {
  m <- stats::glm(formula, data = data, family = stats::binomial(link = "logit"), ...)
  m <- list(model = m)
  class(m) <- c("fit_logit", "glm", class(m))
  m
}

#' @export
coef.fit_logit <- function(object, ...) {
  stats::coef(object$model, ...)
}


#' @export
summary.fit_logit <- function(object, ...) {
  base::summary(object$model, ...)
}

#' @rdname fit_logit
#' @export
fit_rsf <- fit_logit

Try the amt package in your browser

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

amt documentation built on March 31, 2023, 5:29 p.m.