Major rewrite to properly handle complex formula terms including:
Factor variables with multiple levels
Interaction terms (e.g., x1:x2, x1:factor)
Polynomial terms (e.g., I(x^2))
Complex interactions with polynomials (e.g., I(x^2):factor)
Log transformations with interactions (e.g., log(x):factor)
Three-way and higher-order interactions
Fixed bug where null model returned incorrect log-likelihood. Previously, when the null model was selected, the function returned the log-likelihood of the last non-null model instead of the actual null model log-likelihood (loglik.null).
Eliminated deprecation warning related to formula.character() for formulas with length > 1.
Improved term handling using the assign attribute from model.matrix() to correctly identify which columns belong to which terms.
Added helper functions for safer formula manipulation:
safe_as_formula(): Safely converts various inputs to formula objects
safe_drop_term(): Drops terms by reconstructing formula from term labels
safe_add_term(): Adds terms by reconstructing formula string
Replaced regex-based column matching with proper assign attribute tracking, fixing issues where variable names contained other variable names as substrings.
Added explicit namespace prefixes (stats::, cmprsk::) for CRAN compliance.
Corrected a bug in backward selection procedure in how scope.min was checked to terminate the selection procedure.
Added checks to make sure that scope.min formula input is correct.
Simplified how standard error was computed.
Fixed a bug related to outputting results in forward selection.
Corrected a bug in backward selection procedure when one variable name is contained in another variable name (e.g., "Mitosis" and "AtyMitosis").
Corrected a bug in forward selection procedure when an as.factor() variable is to be added to the model.