1

I am using ctree() in package party/partykit to plot a survival tree of a survival model.

Overall survival is good, 95% survival at worst, so I would like to change the yscale to c(0.9, 1) so that the panels are useful on the final plot.

I need to adjust the yscale arguments in the terminal panels of the survival plots but this throws up an error and does not seem to be possible.

Is this possible in ctree() or should I use another method?

I have added arguments for yscale to the terminal_panel function but this thorws up an error

"Error in survfitKM(X, newY, casewt, ...) : 
  unused argument (yscale = c(0.9, 1))"

    plot(taperfit.ct, terminal_panel = node_surv(taperfit.ct, yscale = c(0.9, 1)))

I expected this to change the scale to zoom in on the KM plots with y axis scale form 90% survival to 100% survival, but this did not happen.

Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49
JisL
  • 161
  • 8
  • I have been working on this and I have located the code in the node_surv function which controls the KM plot panel but I cannot seem to alter the code to adjust the output. I have used the following: fixInNamespace("node_surv", "party") to view and edit the code temporarily but this makes no difference. I have also tried using: trace(node_surv, edit=TRUE) but this throws the error:"unable to find an environment containing class “grapcon_generator”" any ideas? – JisL Feb 14 '19 at 14:26
  • I have also tried using: "plot(taperfit.ct, terminal_panel = node_surv, tp_args= list(yscale = c(0.9,1)))" but this throws error: "Error in survfitKM(X, newY, casewt, ...) : unused argument (yscale = c(0.9, 1))" – JisL Feb 14 '19 at 14:52

1 Answers1

3

So far the node_surv() function did not have a yscale argument and hence when you provided it, it got passed on to the wrong function yielding an error. However, I just added it to the partykit repository on R-Forge. Thus, if you check out and build partykit from there your code

plot(taperfit.ct, terminal_panel = node_surv(taperfit.ct, yscale = c(0.9, 1)))

or for short

plot(taperfit.ct, tp_args = list(yscale = c(0.9, 1)))

should work.

You can also manually work around the issue if you're using the old party implementation (or have troubles with building partykit).

taperplot <- node_surv(taperfit.ct, yscale = c(0.9, 1))
fix(taperplot) ## go to line 11 and change the definition of yscale
plot(taperfit.ct, terminal_panel = taperplot)
Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49
  • Thank you so much. I will transfer ot Party kit and give this a go. – JisL Feb 17 '19 at 15:45
  • Thanks for your help so far. I have been very slow, sorry. I have used partykit with the arguments listed above (1- terminal panel, 2- tp_args) and the plot still doesn't change. Are there any other ways to get this to work? – JisL Mar 06 '19 at 00:10
  • Did you use the latest version of `partykit` from R-Forge. Unfortunately, the package currently does not build automatically, so that you have to check it out and build by hand. Or alternatively, you do the manual workaround I mentioned. – Achim Zeileis Mar 06 '19 at 00:15
  • Hi, sorry I had not got the latest version, I will try this and or work around. – JisL Mar 06 '19 at 11:11