Counts the number of previous events of two types for recurrent events processes

count.history(
  data,
  status = "status",
  id = "id",
  types = 1:2,
  names.count = "Count",
  lag = TRUE,
  multitype = FALSE
)

Arguments

data

data-frame

status

name of status

id

id

types

types of the events (code) related to status

names.count

name of Counts, for example Count1 Count2 when types=c(1,2)

lag

if true counts previously observed, and if lag=FALSE counts up to know

multitype

if multitype then count number of types also when types=c(1,2) for example

Author

Thomas Scheike

Examples

########################################
## getting some rates to mimick 
########################################

data(base1cumhaz)
data(base4cumhaz)
data(drcumhaz)
dr <- drcumhaz
base1 <- base1cumhaz
base4 <- base4cumhaz

######################################################################
### simulating simple model that mimicks data 
### now with two event types and second type has same rate as death rate
######################################################################

rr <- simRecurrentII(1000,base1,base4,death.cumhaz=dr)
rr <-  count.history(rr)
dtable(rr,~"Count*"+status,level=1)
#> 
#> Count1
#>    0    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15 
#> 1076  722  515  417  355  292  229  188  136  102   68   51   36   23   16   12 
#>   16   17 
#>    5    3 
#> 
#> Count2
#>    0    1    2    3    4    5    6 
#> 3015  883  244   83   17    2    2 
#> 
#> status
#>    0    1    2 
#> 1000 2844  402 
#>