R/refit.R

Defines functions refit

Documented in refit

#' Refit a model
#'
#' Refits a model changing the response variable
#'
#' @param model a model object - currently working for lm and glm
#' @param y new response variable
refit <- function(model, y) {
  x <- as.data.frame(stats::model.matrix(model))
  x$`.y` <- y
  stats::update(model, .y ~ ., data = x)
}
curso-r/ggilberto documentation built on May 20, 2019, 2:39 p.m.