R/as.regexport.R

Defines functions as.regexport

Documented in as.regexport

#' Coerce a model to class regexport
#' 
#' @param model A regression model or output from a regression function that
#'        can be coerced to regexport format
#' @param ... Other arguments to be passed to methods
#'
#' @details 
#' The regexport package uses the classes \code{regexcel} and \code{reglist}
#' to store all regression outputs needed to make the standard tables in a
#' convenient format that avoids all of the complexity of the standard 
#' regression output classes (such as \code{lm} or \code{glm}). Coercing a
#' model to this class will eliminate much of the complexity of the original
#' model and simplifies the object down to what is needed to output the table.
#' 
#' The regexport package currently includes methods for models of class 
#' \code{lm}, \code{glm}, \code{coeftest} (for use with the lmtest package).
#' Output from other packages can easily be used with regexport by creating a
#' list with the required elements and using \code{as.regexport} to coerce the
#' list into class \code{regexport}.
#' 
#' The \code{regexcel} class is a named list with at least three elements:
#' \itemize{
#'   \item \code{depvar} A character vector with one element: the name of the
#'   dependent variable
#'   \item \code{coef} A data.frame with four columns:
#'   \itemize{
#'     \item \code{var} A character vector with names of independent variables
#'     \item \code{est} A numeric vector with the mean estimates of the
#'     coefficients
#'     \item \code{se} A numeric vector with the standard error of the 
#'     coefficients
#'     \item \code{p} A numeric vector with the probability that a coefficient
#'     is not equal to zero (the p-value of the t-test)
#'   }
#'   \item \code{sumstats} A named list with summary statistics that can be
#'   displayed when a regression is output
#' }
#' 
#' @examples 
#' reg <- lm(mpg ~ cyl + disp, data = mtcars)
#' regx <- as.regexport(reg)
#' @export 

as.regexport <- function(model, ...) UseMethod("as.regexport")
philbastian/regexport documentation built on Sept. 12, 2023, 3:25 p.m.