| REGModelList {regport} | R Documentation |
R6 class representing a list of regression model
Description
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.
Public fields
dataa
data.tablestoring modeling data.xfocal variables (terms).
ypredicted variables or expression.
covarscovariables.
mlista list of
REGModel.argsother arguments used for building model.
typemodel type (class).
resultmodel result, a object of
parameters_model. Can be converted into data.frame withas.data.frame()ordata.table::as.data.table().forest_datamore detailed data used for plotting forest.
Methods
Public methods
Method new()
Create a REGModelList object.
Usage
REGModelList$new(data, y, x, covars = NULL)
Arguments
dataa
data.tablestoring modeling data.ypredicted variables or expression.
xfocal variables (terms).
covarscovariables.
Returns
a REGModelList R6 object.
Method build()
Build REGModelList object.
Usage
REGModelList$build(
f = c("coxph", "binomial", "gaussian", "Gamma", "inverse.gaussian", "poisson",
"quasi", "quasibinomial", "quasipoisson"),
exp = NULL,
ci = 0.95,
parallel = FALSE,
...
)Arguments
fa length-1 string specifying modeling function or family of
glm(), default is 'coxph'. Other options are members of GLM family, seestats::family(). 'binomial' is logistic, and 'gaussian' is linear.explogical, indicating whether or not to exponentiate the the coefficients.
ciconfidence Interval (CI) level. Default to 0.95 (95%). e.g.
survival::coxph().parallelif
TRUE, use N-1 cores to run the task....other parameters passing to corresponding regression model function.
Returns
a REGModel R6 object.
Method plot_forest()
plot forest.
Usage
REGModelList$plot_forest( ref_line = NULL, xlim = NULL, vars = NULL, p = NULL, ... )
Arguments
ref_linereference line, default is
1for HR.xlimlimits of x axis.
varsselected variables to show.
pselected 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.
Method print()
print the REGModelList object
Usage
REGModelList$print(...)
Arguments
...unused.
Method clone()
The objects of this class are cloneable with this method.
Usage
REGModelList$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
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()