[R] Survival analysis
gor@n@bro@trom @end|ng |rom umu@@e
Tue Apr 21 16:09:52 CEST 2020
Dear dr Medic,
Den 2020-04-17 kl. 23:03, skrev Medic:
> On 2020-04-17 20:06, Medic wrote:
>> I can't understand how to do a survival analysis (?Surv ()) when some
>> event occurred before the start of observation (left censored). If I
>> understand correctly, there are two methods. I chose a method with: 1)
>> time from the start of treatment to the event and 2) the indicator of
>> the event. I did (in my data) the event indicator so:
>> 1 - event, 2 - event before the start of observation, 0 - no event
> I have no experience of left censoring beyond the text book. Is your
> left censored data the SAME event or a different event?
> YES, THE SAME!
>> left_censor_data <- read.table("left.csv", header = TRUE, sep = ";")
>> #sep = ";" it's right!
>> dput(left_censor_data, file="left_censor_data") #file attached
>> 'data.frame': 11 obs. of 2 variables:
>> $ timee : int 5 151 33 37 75 14 7 9 1 45 ...
>> $ eventt: int 2 0 0 0 0 0 0 2 0 1 ...
>> # 1—event, 2 – event before the start of observation , 0 – no event
> So if I read this data correctly the first observation is left censored.
> What does the time "5" refer to? Is that 5 days BEFORE observation the
> event happened?
> YES, EXACTLY!
> My text book understanding of left censored data was that your
> censored points would
> have time 0.
> I TRIED TO SET TIME 0 NOW (for censored points), AND RECEIVED THE SAME
> WARNING (AND THE CURVE TURNED OUT WRONG)
>> sur <- Surv(time = left_censor_data$timee, event =
>> left_censor_data$eventt, type = "left")
>> WARNING message:
>> In Surv(time = left_censor_data$timee, event =
>> left_censor_data$eventt, :
>> Invalid status value, converted to NA
>> #Why such a WARNING message?
Because the choice "type = 'left'" is incompatible with an event
variable taking three values, see the help page for survival::Surv. My
guess from your (vague) description is that you want "type =
'counting'", as indicated below.
>> #Then everything turns out wrong
> Is the censoring type you want LEFT TRUNCATION rather than LEFT.
> If they are also right censored I think R Surv calls these Counting.
> I SAY ABOUT LEFT CENSORING (NOT ABOUT LEFT TRUNCATION)!
> (COUNTING? I DO NOT UNDERSTAND THIS.)
Then you should read an elementary text on survival analysis or consult
a local statistician.
> THANKS! I HOPE SOMEONE EXPLAIN TO ME
> 1) HOW TO COMPILE THE DATA and
> 2) WRITE A CODE
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help