Fully runs a logistic regression model with multiple event realizations, returning the model and results
Source:R/BasicRun.R
LogisticRunMulti.RdLogisticRunMulti uses a formula, data.table, and list of controls to prepare and
run a Colossus logistic regression function
Arguments
- model
either a formula written for the get_form function, or the model result from the get_form function.
- df
a data.table containing the columns of interest
- a_n
list of initial parameter values, used to determine the number of parameters. May be either a list of vectors or a single vector.
- keep_constant
binary values to denote which parameters to change
- realization_columns
used for multi-realization regressions. Matrix of column names with rows for each column with realizations, columns for each realization
- control
list of parameters controlling the convergence, see the
vignette("Control_Options")vignette for details- gradient_control
a list of control options for the gradient descent algorithm. If any value is given, a gradient descent algorithm is used instead of Newton-Raphson. See the
vignette("Control_Options")vignette for details- link
Used in logistic regression, the linking function relating the input model and event probability. Current options are "odds", "ident", and "loglink" for the odds ratio, identity, and complimentary loglink options.
- single
a boolean to denote that only the log-likelihood should be calculated and returned, no derivatives or iterations
- observed_info
a boolean to denote that the observed information matrix should be used to calculate the standard error for parameters, not the expected information matrix
- cons_mat
Matrix containing coefficients for a system of linear constraints, formatted as matrix
- cons_vec
Vector containing constants for a system of linear constraints, formatted as vector
- ...
can include the named entries for the control list parameter
See also
Other Logistic Wrapper Functions:
LikelihoodBound.logitres(),
LogisticRun()
Examples
library(data.table)
df <- data.table::data.table(
UserID = c(112, 114, 213, 214, 115, 116, 117),
t0 = c(18, 20, 18, 19, 21, 20, 18),
t1 = c(30, 45, 57, 47, 36, 60, 55),
event = c(0, 0, 1, 0, 1, 0, 0),
dose = c(0, 1, 1, 0, 1, 0, 1)
)
set.seed(3742)
df$event0 <- rbinom(nrow(df), size = 1, prob = 0.3)
df$event1 <- rbinom(nrow(df), size = 1, prob = 0.3)
df$event2 <- rbinom(nrow(df), size = 1, prob = 0.3)
realization_columns <- c("event0", "event1", "event2")
control <- list(
ncores = 1, lr = 0.75, maxiter = 1,
halfmax = 2, epsilon = 1e-6,
deriv_epsilon = 1e-6, step_max = 1.0,
thres_step_max = 100.0,
verbose = 0, ties = "breslow", double_step = 1
)
formula <- logit(event) ~ loglinear(dose, 0) + multiplicative()
res <- LogisticRunMulti(formula, df, realization_columns = realization_columns, control = control)