REGModelList {regport} | R Documentation |
Contains fields storing data and methods to build, process and visualize a list of regression model. Currently, this class is designed for CoxPH and GLM regression models.
data
a data.table
storing modeling data.
x
focal variables (terms).
y
predicted variables or expression.
covars
covariables.
mlist
a list of REGModel
.
args
other arguments used for building model.
type
model type (class).
result
model result, a object of parameters_model
. Can be converted into
data.frame with as.data.frame()
or data.table::as.data.table()
.
forest_data
more detailed data used for plotting forest.
new()
Create a REGModelList
object.
REGModelList$new(data, y, x, covars = NULL)
data
a data.table
storing modeling data.
y
predicted variables or expression.
x
focal variables (terms).
covars
covariables.
a REGModelList
R6 object.
build()
Build REGModelList
object.
REGModelList$build( f = c("coxph", "binomial", "gaussian", "Gamma", "inverse.gaussian", "poisson", "quasi", "quasibinomial", "quasipoisson"), exp = NULL, ci = 0.95, parallel = FALSE, ... )
f
a length-1 string specifying modeling function or family of glm()
, default is 'coxph'.
Other options are members of GLM family, see stats::family()
.
'binomial' is logistic, and 'gaussian' is linear.
exp
logical, indicating whether or not to exponentiate the the coefficients.
ci
confidence Interval (CI) level. Default to 0.95 (95%).
e.g. survival::coxph()
.
parallel
if TRUE
, use N-1 cores to run the task.
...
other parameters passing to corresponding regression model function.
a REGModel
R6 object.
plot_forest()
plot forest.
REGModelList$plot_forest( ref_line = NULL, xlim = NULL, vars = NULL, p = NULL, ... )
ref_line
reference line, default is 1
for HR.
xlim
limits of x axis.
vars
selected variables to show.
p
selected variables with level' pvalue lower than p.
...
other plot options passing to forestploter::forest()
.
Also check https://github.com/adayim/forestploter to see more complex adjustment of the result plot.
print()
print the REGModelList
object
REGModelList$print(...)
...
unused.
clone()
The objects of this class are cloneable with this method.
REGModelList$clone(deep = FALSE)
deep
Whether to make a deep clone.
ml <- REGModelList$new(
data = mtcars,
y = "mpg",
x = c("factor(cyl)", colnames(mtcars)[3:5]),
covars = c(colnames(mtcars)[8:9], "factor(gear)")
)
ml
ml$print()
ml$plot_forest()
ml$build(f = "gaussian")
## Not run:
ml$build(f = "gaussian", parallel = TRUE)
## End(Not run)
ml$print()
ml$result
ml$forest_data
ml$plot_forest()