parfm: R/plot.predict.parfm.R

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
################################################################################
#  Plots the prediction of frailties                                           #
################################################################################
#                                                                              #
#  Computes the prediction of the fraities as                                  #
#                                                                              #
#  Its parameters are                                                          #
#   - x    : the prediction, object of class 'predict.parfm'                   #
#   - sort : how the values must be sorted, either                             #
#            'i' for increasing                                                #
#            'd' for decreasing                                                #
#            or any other value for keeping the current order                  #
#                                                                              #
#   Date: February 02, 2012                                                    #
#   Last modification on: February 23, 2012                                    #
################################################################################

plot.predict.parfm <- function(x, sort="i", 
                               main=NULL,
                               sub=NULL,
                               cex.axis=1,
                               hline=1,
                               ylim=NULL,
                               ...){
  # library('graphics')
  xlab = attr(x, "clustname")
  if (is.null(main)) {
    frailty <- attr(x, "frailty")
    dist <- attr(x, "dist")
    main <- paste(toupper(substr(frailty, 1, 1)), substr(frailty, 2, 100), 
                  " frailty model\nwith ", 
                  toupper(substr(dist, 1, 1)), substr(dist, 2, 100),
                  " baseline", sep="", collapse="")
  }
  if (sort == "i")
    x <- sort(x, decreasing=FALSE)
  else if (sort == "d")
    x <- sort(x, decreasing=TRUE)
  
  if (is.null(ylim))
    ylim <- c(0, max(as.numeric(x)))
  
  plot(1, ty="n", 
       ylab="Predicted frailty value", 
       xlab=xlab,
       main=main,
       sub=sub,
       xaxt="n",
       xlim=c(1, length(as.numeric(x))),
       ylim=ylim)
  abline(h=hline, col="gray")
  points(1:length(as.numeric(x)), as.numeric(x))
  axis(side=1, at=1:length(x), labels=names(x), las=3, cex.axis=cex.axis)
}

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.