
Fully runs a poisson regression model with multiple event realizations, returning the model and results
Source:R/basic_run.R
PoisRunMultiOut.RdPoisRunMultiOut uses a formula, data.table, and list of controls to prepare and
run a Colossus poisson 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 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 control options vignette for details
- 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 Poisson Wrapper Functions:
PoisRun(),
PoisRunJoint(),
PoisRunMulti()
Examples
library(data.table)
df <- 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),
lung = c(0, 0, 1, 0, 1, 0, 0),
dose = c(0, 1, 1, 0, 1, 0, 1)
)
set.seed(3742)
df$rand <- c(1, floor(runif(nrow(df) - 1, min = 0, max = 1)))
df$lung0 <- c(1, floor(runif(nrow(df) - 1, min = 0, max = 1)))
df$lung1 <- c(1, floor(runif(nrow(df) - 1, min = 0, max = 1)))
df$lung2 <- c(1, floor(runif(nrow(df) - 1, min = 0, max = 1)))
realization_columns <- c("lung", "lung1", "lung2")
control <- list(
ncores = 1, lr = 0.75, maxiters = c(1, 1),
halfmax = 1
)
formula <- Pois(t1, lung) ~ loglinear(CONST, dose, rand, 0) + multiplicative()
res <- PoisRunMultiOut(formula, df,
control = control,
realization_columns = realization_columns
)