To use this wrapper to calculate the attributable fraction function, type the following command in Stata:
shell "...\Rscript" ...\stata_wrapper.R time='varible' status='variable' cov='covariate1,...' predictors='covariate1+covariate2+...' datafile='stata-data-set' resultfile='stata-data-set'
- "...\Rscript": the executable Rscript file, including its full path. Usually this file is located in the directory of "C:\Program Files\R\R version\bin".
- ...\stata_wrapper.R: the stata_wrapper.R file, including its full path.
- time='varible': specifies the name of variable indicating the time to the occurrence of an event or censoring.
- status='varible': specifies the name of variable indicating whether the time variable corresponds to an event or censoring.
- cov='covariate1,...': specifies the names of a set of covariates whose attributable fraction function is of interest. The covariate names need to be separated by commas. Note that no spaces are allowed between covariate names. For example cov='x1,x2' is allowed but cov='x1, x2' is not.
- predictors='covariate1+covariate2+...': specifies the name(s) of covariate(s) to be included in the Cox model. The covariate names need to be connected by plus signs. Note that no spaces are allowed between covariate names. For example predictors='x1+x2' is allowed but predictors='x1 + x2' is not. The covariates specified in the "cov" statement must be included in the Cox model. The unadjusted attributable fraction function will be calcualted if the Cox model does not include other covariates; the adjusted attributable fraction function adjusting for other covariates in the Cox model will be calculated otherwise.
- datafile='stata-data-set': specifies the name of the input stata dataset, including the full path. The dataset needs to be in Stata 12 format. Note that double slashes are required in the path of the dataset.
- resultfile='stata-data-set': specifies the name, including the full path, of the stata dataset to store the result which includes the following variables. Note that double slashes are required in the path of the dataset.
- time: unique uncensored event times at which the attributable fraction function jumps.
- est: the estimates of unadjusted/adjusted attributable fractions at unique uncensored
event times.
-
se the standard errors of the estimated attributable fractions.
-
low: the lower confidence limits of the atrtributable fractions.
-
upp: the upper confidence limits of the atrtributable fractions.