Tutorial 5 -- Specifying Events

NOTE: The processing of the raw output has prioritized flexibility over efficiency. Therefore for simple processing, for which efficient R is available, it may be advisable to write you own purpose built processing function.

There are many types of events which can be used to process the output from the simulator. The events of interest are stored in an EventSet object and events are added using the InsertEvent.EventSet function.

library("badminton") 
myEvents <- InitializeEventSet()
#Add an event into myEvents
myEvents <- InsertEvent.EventSet(myEvents,NewEvent(name="column_name",type="startState"))

Events are created with the NewEvent function. The name argument is the column heading in the output data frame. There are many different event types:

NewEvent(name="column_name",type="endState")
NewEvent(name="column_name",type="recruitTime")
#Output first time subject transitions into state N1 or N2. If no transition occurs then Inf is output
NewEvent(name="column_name",type="timeToHit",nodeNames=c("N1","N2"))
#By default patient time is output, however, setting calendarTime=TRUE will output the calender time the event occurs
NewEvent(name="column_name",type="timeToHit",nodeNames=c("N1","N2"),calendarTime=TRUE)
#Output if the subject transitions into state N1 or N2 before time 10
NewEvent(name="column_name",type="hitsBefore",nodeNames=c("N1","N2"),time=10)
#By default patient time is used, however, setting calendarTime=TRUE will use calender time 
NewEvent(name="column_name",type="hitsBefore",nodeNames=c("N1","N2"),time=10,calendarTime=TRUE)
#Output first time subject transitions over either edge N1 -> N2 or A1 -> A2. If neither transition occurs then Inf is output
NewEvent(name="column_name",type="timeToHit_Edge",edges=c("N1","N2","A1","A2"))
#By default patient time is output, however, setting calendarTime=TRUE will output the calender time the event occurs
NewEvent(name="column_name",type="timeToHit_Edge",edges=c("N1","N2","A1","A2"),calendarTime=TRUE)
#Output whether subject transitions over either edge N1 -> N2 or A1 -> A2.before time 15.5
NewEvent(name="column_name",type="hitsBefore_Edge",edges=c("N1","N2","A1","A2"),time=15.5)
#By default patient time is output, however, setting calendarTime=TRUE will output the calender time the event occurs
NewEvent(name="column_name",type="hitsBefore_Edge",edges=c("N1","N2","A1","A2"),time=15.5,calendarTime=TRUE)

Given a Progression Graph and EventSet it is possible to check whether the nodes and edges described in the EventSet exist in the progression graph:

g <- SimpleStudyProgressionGraph(arms=c("p","a"),armProgression=c("1","2","3"))
ValidateAgainstProgressionGraph.EventSet(myEvents,progressionGraph=g)


scientific-computing-solutions/badminton documentation built on May 29, 2019, 3:43 p.m.