Skip to main content


Showing posts from December, 2012

Update to Graphing Non-Proportional Hazards in R

Update 31 July 2013: I've moved all of the functionality described in this post into an R package called simPH. Have a look. It is much easier to use.This is a quick update for a previous post on Graphing Non-Proportional Hazards in R. In the previous post I showed how to simulate and graph 1,000 non-proportional hazard ratios at roughly every point in time across an observation period. In the previous example I kept in simulation outliers. Some people have suggested dropping the top and bottom 2.5 percent of simulated values (i.e. keeping the middle 95 percent).Luckily this can be accomplished with Hadley Wickham's plyr package and three lines of code. The trick is to use plyr's ddply command to subset the data frame at each point in Time where we simulated values. In the previous example the simulated values were in a variable called HRqmv. In each subset we use the quantile command from base R to create logical variables indicating if a simulation of HRqmv is greater th…