Tags:
create new tag
, view all tags, tagging instructions
 Image Click on image to enlarge. Title Time to AE Occurrence Graph_Subgroup Adverse Events AE_Clinical_Question 3. Is there a difference in the time to the first event across treatment groups?, 4. What are the trends of time to the first event among different AEs Description This plot shows the probability of occurrence of adverse events over time by treatment group. Each color indicates a different treatment and each panel a different AE. Contributor/Email Mat Soukup (email: Mat.Soukup@fda.hhs.gov) Max Cherny (Max.2.Cherny@gsk.com) Background Keywords References Datasets Other CDISC_Data Other_Data Time to Event Data CLASSIFICATIONS Graph_Type Survival Plot Variable_Relationship Survival Data_Types Time to Event Special_Considerations Code_Available Yes Software Program R, SAS Software SAS 9.2 R-Code - Attachment R-Code /*-------------------------------------------------------------------*//*--Forest Plot for CTSPedia --*//*--R Code --*//*--Name: Mat Soukup (modified by Max Cherny --*//*--Company: GSK --*//*--Date : 30JUL 2012 --*//*-------------------------------------------------------------------*/rm(list = ls()) # clear objects graphics.off() # close graphics windows ##### Time to Event Graphiclibrary(lattice)library(vcd)library(survival)set.seed(126)times <- abs(c(rnorm(200, 5, 10), rnorm(200, 9, 10), rnorm(200, 13, 10), rnorm(200, 20, 10), rnorm(200, 7, 10), rnorm(200, 11, 10), rnorm(200, 15, 10), rnorm(200, 24, 10), rnorm(200, 13, 10), rnorm(200, 18, 10), rnorm(200, 23, 10), rnorm(200, 28, 10), rnorm(200, 16, 10), rnorm(200, 21, 10), rnorm(200, 26, 10), rnorm(200, 31, 10)))times[times < 0] <- 3treat <- rep(rep(c('High','Mid','Low','Placebo'),each=200),4)term <- rep(c('Headache','Dizziness','Nausea','Abdominal Pain'), each=800)bin1h <- c(rep(0, 40),rep(1,60))bin1m <- c(rep(0, 45),rep(1,55))bin1l <- c(rep(0, 50),rep(1,50))bin1p <- c(rep(0, 65),rep(1,35))bin2h <- c(rep(0, 65),rep(1,35))bin2m <- c(rep(0, 70),rep(1,30))bin2l <- c(rep(0, 80),rep(1,20))bin2p <- c(rep(0, 90),rep(1,10))cens <- c(sample(bin1h, 200, replace=TRUE), sample(bin1m, 200, replace=TRUE), sample(bin1l, 200, replace=TRUE), sample(bin1p, 200, replace=TRUE), sample(bin2h, 200, replace=TRUE), sample(bin2m, 200, replace=TRUE), sample(bin2l, 200, replace=TRUE), sample(bin2p, 200, replace=TRUE), sample(bin1h, 200, replace=TRUE), sample(bin1m, 200, replace=TRUE), sample(bin1l, 200, replace=TRUE), sample(bin1p, 200, replace=TRUE), sample(bin2h, 200, replace=TRUE), sample(bin2m, 200, replace=TRUE), sample(bin2l, 200, replace=TRUE), sample(bin2p, 200, replace=TRUE))dat <- data.frame(times, treat, term, cens)aes <- c('Headache','Dizziness','Nausea','Abdominal Pain')survlist <- NULLtimelist <- NULLtrtlist <- NULLfor(j in 1:4){ aedat <- dat[dat\$term%in%aes,] nd <- length(unique(aedat\$id)) aest <- NULL # Run a Cox model fit <- survfit(Surv(times,cens)~treat, data=aedat) #Store output for plot trtlistj? <- list(rep(names(fit\$strata),fit\$strata)) survlistj? <- list(fit\$surv) timelistj? <- list(fit\$time)}# Create one big data set for plottingnae <- c(800, 800, 800, 800)aelabel <- c('Headache','Dizziness','Nausea','Abdominal Pain')aelist <- NULLfor(k in 1:4){ aelistk? <- rep(aelabel[k],times=nae[k])}panarg <- unlist(aelist)trtarg <- unlist(trtlist)survarg <- unlist(survlist)timearg <- unlist(timelist)library(vcd)hclcolors <- rainbow_hcl(4, l=50, start=50, c=75)[c(3,2,4,1)]colorpalette <- c(hclcolors[1:3], 'grey45')new.back <- trellis.par.get("background")new.back\$col <- "white"newcol <- trellis.par.get("superpose.symbol")newcol\$col <- colorpalette[c(3,1,2,4)]newcol\$pch <- c(16,1,4,8)new.line <- trellis.par.get('superpose.line')new.line\$col <- colorpalette[c(3,1,2,4)]new.pan <- trellis.par.get("strip.background")new.pan\$col <- c('gray90','white')trellis.par.set("background", new.back)trellis.par.set("superpose.symbol", newcol)trellis.par.set("superpose.line", new.line)trellis.par.set("strip.background",new.pan)lines_style=c(1,2,3,6)lines_widths=c(6,4,3,1)xyplot((1-survarg)~timearg|panarg, groups=trtarg, type='s', scales=list( x=list(alternating=c(1, 1)), y=list(alternating=c(1, 1)) ) , lwd=lines_widths, lty = lines_style, xlab='Time (days)', ylab='Proportion of Subjects Reporting Event', col=trellis.par.get("superpose.symbol")\$col[1:4], key=list(lines=list(lty=lines_style, lwd=lines_widths,#the numbers for N are just dummy numbers. In the actual program they would need to be calculated col=trellis.par.get("superpose.symbol")\$col[1:4]), text=list(c('High (N=100)','Mid (N=110)','Low (N=94)','Placebo (N=130)'), col=trellis.par.get("superpose.symbol")\$col[1:4]), columns=4, title='Treatment', between=.6)) SAS-Code - Attachment Cherny - Time to Event - SAS Code SAS-Code Stata-Code - Attachment Stata-Code Other Code - Attachment Other Code Disclaimer The views expressed within CTSpedia are those of the author and must not be taken to represent policy or guidance on the behalf of any organization or institution with which the author is affiliated. Permission Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT OLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Reference Image 