0
$\begingroup$

So I have a data set with several different parameters, age, sex, etc. I also have an indicator of if any given subject has HIV or does not. I want to plot survival curves for these. I also have for each subject the time to death after diagnosis or the last time they were observed, and an indicator that tells us if they were censored or if they did indeed die.

So my question is, how do we account for censoring and how do we make a survival object that allows us to make separate estimates for survival for those who do have HIV and those who do not?

For example, my data is HIV.dataset

and I have some parameters,

HIV.dataset$gender,

HIV.dataset\$hiv,

HIV.dataset\$ind

and

HIV.dataset\$time

Where the gender is a factorized version ie M or F. hiv is an indicator (1= HIV positive)

ind represents the indicator of death , 0 is censored and 1 is death

and time represents the time in days to death after diagnosis or the last time they were observed.

So I am not sure how I account for censoring. Is this something I include or do not include? How can I separate the cases to make separate curves, for example if I wanted a survival curve for those who do have HIV.

I know I should make use of survfit , and I would need a Surv object.

So in summary I am looking to better understand how to plot survival curves (using Kaplan-Meier Estimates) and how to account for censoring.

Thanks all

$\endgroup$

closed as off-topic by whuber Nov 16 '18 at 21:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – whuber
If this question can be reworded to fit the rules in the help center, please edit the question.

1
$\begingroup$

To obtain the Kaplan-Meier estimates of the survival function for malse and females, and plot them in R using the survival package, you will need to use something like this:

sfit <- survfit(Surv(time, ind) ~ gender, data = HIV.dataset)
plot(sfit)

There are many resources available online on how to do survival analysis in R, such as my Survival Analysis in R Companion.

$\endgroup$
  • $\begingroup$ oh so i replace ~1 with the feature,,, thanks $\endgroup$ – Quality Oct 1 '18 at 5:35
0
$\begingroup$

The right-censoring is already coded in the "ind" character - it tells the program whether to count this observation as an event (with a 1) or not (with a 0).

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.