mclements / rstpm2

An R package for generalised survival models
28 stars 11 forks source link

Weird stripes when plotting stpm2 object with more than one curve #4

Closed alexploner closed 5 years ago

alexploner commented 8 years ago

E.g. using the example from ?stpm2; one curve as in the example works fine:

library(rstpm2)
data(brcancer)
fit <- stpm2(Surv(rectime,censrec==1)~hormon,data=brcancer,df=3)
plot(fit,newdata=data.frame(hormon=0))

However, having two curves shows (at least on my machine, Windows 7 + R 3.2.3 + rstpm2 dated 2016-02-24) a striped or comb-like pattern for the confidence regions:

plot(fit,newdata=data.frame(hormon=0:1))

Looks like the two regions might be drawn point-by-point in parallel instead of one after the other?

mclements commented 8 years ago

Alex,

This is good idea: one could stratify by number of rows in newdata.

A working solution is:

plot(fit,newdata=data.frame(hormon=1))

plot(fit,newdata=data.frame(hormon=0), add=TRUE, lty=2)

Mark Clements Associate Professor in Biostatistics Department of Medical Epidemiology and Biostatistics Karolinska Institutet Tel: +46-709-951781 Email: mark.clements@ki.se

----- Reply message ----- From: "Alexander Ploner" notifications@github.com To: "mclements/rstpm2" rstpm2@noreply.github.com Subject: [rstpm2] Weird stripes when plotting stpm2 object with more than one curve (#4) Date: Sun, Mar 13, 2016 13:59

E.g. using the example from ?stpm2; one curve as in the example works fine:

library(rstpm2) data(brcancer) fit <- stpm2(Surv(rectime,censrec==1)~hormon,data=brcancer,df=3) plot(fit,newdata=data.frame(hormon=0))

However, having two curves shows (at least on my machine, Windows 7 + R 3.2.3 + rstpm2 dated 2016-02-24) a striped or comb-like pattern for the confidence regions:

plot(fit,newdata=data.frame(hormon=0:1))

Looks like the two regions might be drawn point-by-point in parallel instead of one after the other?

— Reply to this email directly or view it on GitHubhttps://github.com/mclements/rstpm2/issues/4.