1
#' Linear regression multivariable models: \code{finalfit} model wrapper
2
#'
3
#' Using \code{finalfit} conventions, produces a multivariable linear regression
4
#' model for a set of explanatory variables against a continuous dependent.
5
#'
6
#' Uses \code{\link[stats]{lm}} with \code{finalfit} modelling conventions.
7
#' Output can be passed to \code{\link{fit2df}}.
8
#'
9
#' @param .data Dataframe.
10
#' @param dependent Character vector of length 1: name of depdendent variable
11
#'   (must a continuous vector).
12
#' @param explanatory Character vector of any length: name(s) of explanatory
13
#'   variables.
14
#' @param ... Other arguments to pass to \code{\link[stats]{lm}}.
15
#' @return A multivariable \code{\link[stats]{lm}} fitted model.
16
#'
17
#' @seealso \code{\link{fit2df}}
18
#' @family finalfit model wrappers
19
#' @export
20
#'
21
#' @examples
22
#' library(finalfit)
23
#' library(dplyr)
24
#'
25
#' explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor")
26
#' dependent = "nodes"
27
#'
28
#' colon_s %>%
29
#'   lmmulti(dependent, explanatory) %>%
30
#'   fit2df()
31
#' 
32
lmmulti <- function(.data, dependent, explanatory, ...){
33 1
  ff_eval(
34 1
    lm(ff_formula(dependent, explanatory), data = .data, ...)
35
  )
36
}

Read our documentation on viewing source code .

Loading