| fitLM | R Documentation |
Fit a coxph or CSC model to a LM super dataset
fitLM( formula, LMdata, type = "coxph", method = "breslow", func_covars, func_LMs, LM_col, outcome, w, LMcovars, ... )
formula |
The formula to be used, remember to include "+cluster(ID)" for the column that indicates the ID of the individual for robust error estimates. |
LMdata |
An object of class "LMdataframe", this can be created by running cutLMsuper and addLMtime |
type |
"coxph" or "CSC"/"CauseSpecificCox" |
method |
A character string specifying the method for tie handling. Default is "breslow". More information can be found in coxph. |
func_covars |
A list of functions to use for interactions between LMs and covariates. |
func_LMs |
A list of functions to use for transformations of the landmark times. |
LM_col |
Character string specifying the column name that indicates the landmark time point for a row. |
outcome |
List with items time and status, containing character strings identifying the names of time and status variables, respectively, of the survival outcome |
w |
Scalar, the value of the prediction window (ie predict w-year/other time period risk from the LM points) |
LMcovars |
Vector of strings indicating the columns that are to have a LM interaction |
... |
Arguments given to coxph or CSC. |
An object of class "LMcoxph" or "LMCSC" with components:
model: fitted model
type: as input
w, func_covars, func_LMs, LMcovars, allLMcovars, outcome: as in LMdata
LHS: the LHS of the input formula
linear.predictors: the vector of linear predictors, one per subject. Note that this vector has not been centered.
## Not run:
data(relapse)
outcome = list(time="Time", status="event")
covars = list(fixed=c("ID","age.at.time.0","male","stage","bmi"),
varying=c("treatment"))
w = 60; LMs = c(0,12,24)
# Covariate-landmark time interactions
func.covars <- list( function(t) t, function(t) t^2)
# let hazard depend on landmark time
func.LMs <- list( function(t) t, function(t) t^2)
# Choose covariates that will have time interaction
pred.covars <- c("age","male","stage","bmi","treatment")
# Stack landmark datasets
LMdata <- cutLMsuper(relapse, outcome, LMs, w, covs, format="long", id="ID", rtime="fup_time", right=F)
# Update complex LM-varying covariates
LMdata$LMdata$age <- LMdata$LMdata$age.at.time.0 + LMdata$LMdata$LM/12 # age is in years and LM is in months
# Add LM-time interactions
LMdata <- addLMtime(LMdata, pred.covars, func.covars, func.LMs)
formula <- "Hist(Time, event, LM) ~ age + male + stage + bmi + treatment + age_1 + age_2 + male_1 + male_2 + stage_1 + stage_2 + bmi_1 + bmi_2 + treatment_1 + treatment_2 + LM_1 + LM_2 + cluster(ID)"
supermodel <- fitLM(as.formula(formula), LMdata, "CSC")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.