Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/stratified_cox.R
The stratified_cox() function runs multiple referent group interaction cox models. The results will show the effect of our main exposure variable within each level of our stratification variable.
1 | stratified_cox(dat,start,stop,outcome,expoVar,strataVar,age,covariates=NULL)
|
dat |
data frame used in the analysis |
start |
Character vector naming your start of followup time, can be numeric or date format. Typically this is one of our DTINT variables. For time dependent or late-entry models, this will be the name of your start time variable. |
stop |
Character vector naming your end of followup time, can be numeric or date format. Typically this is one of our DATEFT or DATEDD variables. For time dependent or late-entry models, this will be the name of your stop time variable. |
outcome |
Character vector for the outcome variable used in the analysis, must be coded as 0=control, 1=case |
expoVar |
Character vector for our main exposure variable, may be categorical or numeric |
strataVar |
Character vector for our stratification variable, must be categorical |
age |
Character vector for our age variable used for stratifying on single year of age |
covariates |
Character vector of covariates. Default is NULL (age-adjusted analysis only) |
The stratified_cox() function will run your stratified interaction models, format the results into a table, and return all model output in a list format that is suitable for program review. Function will work for standard, time-dependent, or late-entry models, depending on how the data are formatted prior to running the function.
Interaction models are coded using the following formula:
y <- formula(Surv(start,stop,outcome)~ strataVar + strataVar:expoVar + covariates + strata(age))
To calculate a p-interaction, a reduced model is also calculated:
y <- formula(Surv(start,stop,outcome) strataVar + expoVar + covariates + strata(age))
The p-interaction is then calculated:
anova(interaction.model, reduced.model)
The function outputs a 3-level list including all the output from the analysis.
final |
A data frame containing the organized output of the function. Includes exposure name, categories, case numbers, stratified estimates and p-values, and a p-value for interaction. |
int.model |
All model output for the interaction model |
base.model |
All model output from the base model |
Brian Carter
G:/Intramural Research/Epidemiology Research/Analysts EPI/Memos, presentations, resources and code/Interaction/Memo, Interaction Methods.doc
coxph
, cox_models, interaction_cox
1 2 3 4 5 6 7 8 9 10 | df <- example_data
foo <- stratified_cox(dat=df,
start="dtint92",
stop="dateft",
outcome="dead",
expoVar="smoke92",
strataVar="bmicat92",
age="age92m",
covariates=NULL)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.