R draw survival curve and calculate P-value with end time specified









up vote
0
down vote

favorite












I am trying to figure out how to generate a survival curve and P-value of a specific time window and not of the entire dataframe.



i can't simply cut-off all records which have survival times longer than x days, as below. Then all survival probability drops to 0% since there simply isnt anybody alive beyond x days anymore.



#dat <- dat[dat$diff_in_days <= 730, ]


In the survfit function I can specify start.time and it only plots the records that have a greater time than specified.



dat_survfit <- survfit(dat_surv ~ Schedule, data = dat, start.time = 100)


All i would like is to be able to specify an end.time. It would stop plotting from there on and generate the P-value from start.time till end.time. (I checked documentation, survfit doesnt have such parameter)



I don't mind how elegant it is anymore, i'm now bound by a deadline and can't figure it out.



How can I specify an end.time for survfit or split my dataframe so, that it only draws a survival curve starting from x days and ending at x days and calculates the p-value between these number of days.










share|improve this question



















  • 1




    Could you please provide a minimal reproducible example?
    – Mr_Z
    18 hours ago














up vote
0
down vote

favorite












I am trying to figure out how to generate a survival curve and P-value of a specific time window and not of the entire dataframe.



i can't simply cut-off all records which have survival times longer than x days, as below. Then all survival probability drops to 0% since there simply isnt anybody alive beyond x days anymore.



#dat <- dat[dat$diff_in_days <= 730, ]


In the survfit function I can specify start.time and it only plots the records that have a greater time than specified.



dat_survfit <- survfit(dat_surv ~ Schedule, data = dat, start.time = 100)


All i would like is to be able to specify an end.time. It would stop plotting from there on and generate the P-value from start.time till end.time. (I checked documentation, survfit doesnt have such parameter)



I don't mind how elegant it is anymore, i'm now bound by a deadline and can't figure it out.



How can I specify an end.time for survfit or split my dataframe so, that it only draws a survival curve starting from x days and ending at x days and calculates the p-value between these number of days.










share|improve this question



















  • 1




    Could you please provide a minimal reproducible example?
    – Mr_Z
    18 hours ago












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am trying to figure out how to generate a survival curve and P-value of a specific time window and not of the entire dataframe.



i can't simply cut-off all records which have survival times longer than x days, as below. Then all survival probability drops to 0% since there simply isnt anybody alive beyond x days anymore.



#dat <- dat[dat$diff_in_days <= 730, ]


In the survfit function I can specify start.time and it only plots the records that have a greater time than specified.



dat_survfit <- survfit(dat_surv ~ Schedule, data = dat, start.time = 100)


All i would like is to be able to specify an end.time. It would stop plotting from there on and generate the P-value from start.time till end.time. (I checked documentation, survfit doesnt have such parameter)



I don't mind how elegant it is anymore, i'm now bound by a deadline and can't figure it out.



How can I specify an end.time for survfit or split my dataframe so, that it only draws a survival curve starting from x days and ending at x days and calculates the p-value between these number of days.










share|improve this question















I am trying to figure out how to generate a survival curve and P-value of a specific time window and not of the entire dataframe.



i can't simply cut-off all records which have survival times longer than x days, as below. Then all survival probability drops to 0% since there simply isnt anybody alive beyond x days anymore.



#dat <- dat[dat$diff_in_days <= 730, ]


In the survfit function I can specify start.time and it only plots the records that have a greater time than specified.



dat_survfit <- survfit(dat_surv ~ Schedule, data = dat, start.time = 100)


All i would like is to be able to specify an end.time. It would stop plotting from there on and generate the P-value from start.time till end.time. (I checked documentation, survfit doesnt have such parameter)



I don't mind how elegant it is anymore, i'm now bound by a deadline and can't figure it out.



How can I specify an end.time for survfit or split my dataframe so, that it only draws a survival curve starting from x days and ending at x days and calculates the p-value between these number of days.







r dataframe survival-analysis






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 19 hours ago

























asked 19 hours ago









Krijn van der Burg

1831222




1831222







  • 1




    Could you please provide a minimal reproducible example?
    – Mr_Z
    18 hours ago












  • 1




    Could you please provide a minimal reproducible example?
    – Mr_Z
    18 hours ago







1




1




Could you please provide a minimal reproducible example?
– Mr_Z
18 hours ago




Could you please provide a minimal reproducible example?
– Mr_Z
18 hours ago

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222122%2fr-draw-survival-curve-and-calculate-p-value-with-end-time-specified%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222122%2fr-draw-survival-curve-and-calculate-p-value-with-end-time-specified%23new-answer', 'question_page');

);

Post as a guest














































































這個網誌中的熱門文章

How to combine Bézier curves to a surface?

Mutual Information Always Non-negative

Why am i infinitely getting the same tweet with the Twitter Search API?