1
|
|
#' Binomial logistic regression multivariable models: \code{finalfit} model
|
2
|
|
#' wrapper
|
3
|
|
#'
|
4
|
|
#' Using \code{finalfit} conventions, produces a multivariable binomial
|
5
|
|
#' logistic regression model for a set of explanatory variables against a
|
6
|
|
#' binary dependent.
|
7
|
|
#'
|
8
|
|
#' Uses \code{\link[stats]{glm}} with \code{finalfit} modelling conventions.
|
9
|
|
#' Output can be passed to \code{\link{fit2df}}.
|
10
|
|
#'
|
11
|
|
#' @param .data Data frame.
|
12
|
|
#' @param dependent Character vector of length 1: name of depdendent variable
|
13
|
|
#' (must have 2 levels).
|
14
|
|
#' @param explanatory Character vector of any length: name(s) of explanatory
|
15
|
|
#' variables.
|
16
|
|
#' @param family Character vector quoted or unquoted of the error distribution
|
17
|
|
#' and link function to be used in the model, see \code{\link[stats]{glm}}.
|
18
|
|
#' @param ... Other arguments to pass to \code{\link[stats]{glm}}.
|
19
|
|
#' @return A multivariable \code{\link[stats]{glm}} fitted model.
|
20
|
|
#'
|
21
|
|
#' @seealso \code{\link{fit2df}, \link{finalfit_merge}}
|
22
|
|
#' @family finalfit model wrappers
|
23
|
|
#' @export
|
24
|
|
#'
|
25
|
|
#' @examples
|
26
|
|
#' library(finalfit)
|
27
|
|
#' library(dplyr)
|
28
|
|
#' explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor")
|
29
|
|
#' dependent = "mort_5yr"
|
30
|
|
#'
|
31
|
|
#' colon_s %>%
|
32
|
|
#' glmmulti(dependent, explanatory) %>%
|
33
|
|
#' fit2df(estimate_suffix=" (univariable)")
|
34
|
|
#'
|
35
|
|
glmmulti <- function(.data, dependent, explanatory, family = "binomial", ...){
|
36
|
1
|
ff_eval(
|
37
|
1
|
glm(ff_formula(dependent, explanatory),
|
38
|
1
|
data = .data, family = family, ...)
|
39
|
|
)
|
40
|
|
}
|