2024-11-08 15:13:33 +01:00
|
|
|
% Generated by roxygen2: do not edit by hand
|
|
|
|
% Please edit documentation in R/regression_model.R
|
|
|
|
\name{regression_model}
|
|
|
|
\alias{regression_model}
|
2024-11-28 21:02:23 +01:00
|
|
|
\title{Create a regression model programatically}
|
2024-11-08 15:13:33 +01:00
|
|
|
\usage{
|
|
|
|
regression_model(
|
|
|
|
data,
|
2024-11-08 16:31:33 +01:00
|
|
|
outcome.str,
|
|
|
|
auto.mode = TRUE,
|
2024-11-08 15:13:33 +01:00
|
|
|
formula.str = NULL,
|
2024-11-08 16:31:33 +01:00
|
|
|
args.list = NULL,
|
|
|
|
fun = NULL,
|
2024-11-28 21:02:23 +01:00
|
|
|
vars = NULL,
|
|
|
|
...
|
2024-11-08 15:13:33 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
\arguments{
|
|
|
|
\item{data}{data set}
|
|
|
|
|
|
|
|
\item{outcome.str}{Name of outcome variable. Character vector.}
|
|
|
|
|
2024-11-21 12:34:27 +01:00
|
|
|
\item{auto.mode}{Make assumptions on function dependent on outcome data format. Overwrites other arguments.}
|
2024-11-08 15:13:33 +01:00
|
|
|
|
|
|
|
\item{formula.str}{Formula as string. Passed through 'glue::glue'. If given, 'outcome.str' and 'vars' are ignored. Optional.}
|
|
|
|
|
|
|
|
\item{args.list}{List of arguments passed to 'fun' with 'do.call'.}
|
|
|
|
|
|
|
|
\item{fun}{Name of function as character vector or function to use for model creation.}
|
|
|
|
|
|
|
|
\item{vars}{character vector of variables to include}
|
2024-11-28 21:02:23 +01:00
|
|
|
|
|
|
|
\item{...}{ignored for now}
|
2024-11-08 15:13:33 +01:00
|
|
|
}
|
|
|
|
\value{
|
|
|
|
object of standard class for fun
|
|
|
|
}
|
|
|
|
\description{
|
2024-11-28 21:02:23 +01:00
|
|
|
Create a regression model programatically
|
2024-11-08 15:13:33 +01:00
|
|
|
}
|
|
|
|
\examples{
|
|
|
|
gtsummary::trial |>
|
2024-11-08 16:31:33 +01:00
|
|
|
regression_model(outcome.str = "age")
|
2024-11-08 15:13:33 +01:00
|
|
|
gtsummary::trial |>
|
|
|
|
regression_model(
|
|
|
|
outcome.str = "age",
|
2024-11-21 12:34:27 +01:00
|
|
|
auto.mode = FALSE,
|
2024-11-08 15:13:33 +01:00
|
|
|
fun = "stats::lm",
|
|
|
|
formula.str = "{outcome.str}~.",
|
|
|
|
args.list = NULL
|
|
|
|
)
|
2024-11-29 14:30:02 +01:00
|
|
|
ls <- gtsummary::trial |> regression_model(
|
2024-11-08 15:13:33 +01:00
|
|
|
outcome.str = "trt",
|
2024-11-21 12:34:27 +01:00
|
|
|
auto.mode = FALSE,
|
2024-11-08 15:13:33 +01:00
|
|
|
fun = "stats::glm",
|
|
|
|
args.list = list(family = binomial(link = "logit"))
|
|
|
|
)
|
|
|
|
}
|