1
#' Cox proprotional hazards multivariable models: \code{finalfit} model wrapper
2
#'
3
#' Using \code{finalfit} conventions, produces multivariable Cox
4
#' Proportional Hazard regression models for a set of explanatory variables
5
#' against a survival object.
6
#'
7
#' Uses \code{\link[survival]{coxph}} with \code{finalfit} modelling
8
#' conventions. Output can be passed to \code{\link{fit2df}}.
9
#'
10
#' @param .data Data frame.
11
#' @param dependent Character vector of length 1:  name of survival object in
12
#'   form \code{Surv(time, status)}.
13
#' @param explanatory Character vector of any length: name(s) of explanatory
14
#'   variables.
15
#' @return A multivariable \code{\link[survival]{coxph}} fitted model
16
#'   output. Output is of class \code{coxph}.
17
#'
18
#' @seealso \code{\link{fit2df}, \link{finalfit_merge}}
19
#' @family finalfit model wrappers
20
#' @export
21
#'
22
#' @examples
23
#' # Cox Proportional Hazards multivariable analysis.
24
#' library(finalfit)
25
#' library(dplyr)
26
#'
27
#' explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor")
28
#' dependent = "Surv(time, status)"
29
#' colon_s %>%
30
#' 	coxphmulti(dependent, explanatory) %>%
31
#' 	fit2df()
32

33
coxphmulti <- function(.data, dependent, explanatory){
34 1
  requireNamespace("survival")
35 1
  coxph(as.formula(paste0(dependent, "~",
36 1
                          paste(explanatory, collapse="+"))), data=.data)
37
}

Read our documentation on viewing source code .

Loading