coxSW {Coxmos} | R Documentation |
coxSW
Description
The coxSW
function conducts a stepwise Cox regression analysis on survival data,
leveraging the capabilities of the My.stepwise
R package. The primary objective of this function
is to identify the most significant predictors for survival data by iteratively adding or removing
predictors based on their statistical significance in the model. The resulting model is of class
"Coxmos" with an attribute model labeled as "coxSW".
Usage
coxSW(
X,
Y,
max.variables = 20,
BACKWARDS = TRUE,
alpha_ENT = 0.1,
alpha_OUT = 0.15,
toKeep.sw = NULL,
initialModel = NULL,
x.center = TRUE,
x.scale = FALSE,
remove_near_zero_variance = TRUE,
remove_zero_variance = FALSE,
toKeep.zv = NULL,
remove_non_significant = FALSE,
alpha = 0.05,
MIN_EPV = 5,
returnData = TRUE,
verbose = FALSE
)
Arguments
X |
Numeric matrix or data.frame. Explanatory variables. Qualitative variables must be transform into binary variables. |
Y |
Numeric matrix or data.frame. Response variables. Object must have two columns named as "time" and "event". For event column, accepted values are: 0/1 or FALSE/TRUE for censored and event observations. |
max.variables |
Numeric. Maximum number of variables you want to keep in the cox model. If MIN_EPV is not meet, the value will be change automatically (default: 20). |
BACKWARDS |
Logical. If BACKWARDS = TRUE, backward strategy is performed (default: TRUE). |
alpha_ENT |
Numeric. Maximum P-Value for a variable to enter the model (default: 0.10). |
alpha_OUT |
Numeric. Minimum P-Value for a variable to leave the model (default: 0.15). |
toKeep.sw |
Character vector. Name of variables in X to not be deleted by Step-wise selection (default: NULL). |
initialModel |
Character vector. Name of variables in X to include in the initial model (default: NULL). |
x.center |
Logical. If x.center = TRUE, X matrix is centered to zero means (default: TRUE). |
x.scale |
Logical. If x.scale = TRUE, X matrix is scaled to unit variances (default: FALSE). |
remove_near_zero_variance |
Logical. If remove_near_zero_variance = TRUE, near zero variance variables will be removed (default: TRUE). |
remove_zero_variance |
Logical. If remove_zero_variance = TRUE, zero variance variables will be removed (default: TRUE). |
toKeep.zv |
Character vector. Name of variables in X to not be deleted by (near) zero variance filtering (default: NULL). |
remove_non_significant |
Logical. If remove_non_significant = TRUE, non-significant variables/components in final cox model will be removed until all variables are significant by forward selection (default: FALSE). |
alpha |
Numeric. Numerical values are regarded as significant if they fall below the threshold (default: 0.05). |
MIN_EPV |
Numeric. Minimum number of Events Per Variable (EPV) you want reach for the final cox model. Used to restrict the number of variables/components can be computed in final cox models. If the minimum is not meet, the model cannot be computed (default: 5). |
returnData |
Logical. Return original and normalized X and Y matrices (default: TRUE). |
verbose |
Logical. If verbose = TRUE, extra messages could be displayed (default: FALSE). |
Details
The coxSW
function employs a stepwise regression technique tailored for survival data. This
method is particularly beneficial when dealing with a plethora of predictors, and there's a
necessity to distill the model to its most impactful variables. The stepwise procedure can be
configured to operate in forward, backward, or a hybrid mode, contingent on the parameters
specified by the user.
During the iterative process, variables are evaluated for inclusion or exclusion based on
predefined significance levels (alpha_ENT
for entry and alpha_OUT
for removal). This ensures
that the model retains only those predictors that meet the significance criteria, thereby
enhancing the model's interpretability and predictive power.
Additionally, the function offers several preprocessing options, such as centering and scaling of the predictor matrix, removal of variables with near-zero or zero variance, and the ability to enforce the inclusion of specific variables in the model. These preprocessing steps are crucial for ensuring the robustness and stability of the resulting Cox regression model.
It's worth noting that the function is equipped to handle both numeric and binary categorical predictors. However, it's imperative that categorical variables are appropriately transformed into binary format before analysis. The outcome or response variable should comprise two columns: "time" representing the survival time and "event" indicating the occurrence of the event of interest.
Value
Instance of class "Coxmos" and model "coxSW". The class contains the following elements:
X
: List of normalized X data information.
-
(data)
: normalized X matrix -
(x.mean)
: mean values for X matrix -
(x.sd)
: standard deviation for X matrix
Y
: List of normalized Y data information.
-
(data)
: normalized Y matrix -
(y.mean)
: mean values for Y matrix -
(y.sd)
: standard deviation for Y matrix
survival_model
: List of survival model information
-
fit
: coxph object. -
AIC
: AIC of cox model. -
BIC
: BIC of cox model. -
lp
: linear predictors for train data. -
coef
: Coefficients for cox model. -
YChapeau
: Y Chapeau residuals. -
Yresidus
: Y residuals.
call
: call function
X_input
: X input matrix
Y_input
: Y input matrix
nsv
: Variables removed by remove_non_significant if any.
nzv
: Variables removed by remove_near_zero_variance or remove_zero_variance.
nz_coeffvar
: Variables removed by coefficient variation near zero.
removed_variables_correlation
: Variables removed by being high correlated with other
variables.
class
: Model class.
time
: time consumed for running the cox analysis.
Author(s)
Pedro Salguero Garcia. Maintainer: pedsalga@upv.edu.es
References
Efroymson MA (1960). “Multiple Regression Analysis.” Mathematical Methods for Digital Computers. Company ISC (2017). “My.stepwise: Stepwise Variable Selection Procedures for Regression Analysis.” https://cran.r-project.org/package=My.stepwise.
Examples
data("X_proteomic")
data("Y_proteomic")
X <- X_proteomic[,1:10]
Y <- Y_proteomic
coxSW(X, Y, x.center = TRUE, x.scale = TRUE)