pSERG: Comparison of time to treatment before and after publication of awareness of delays in the pSERG consortium

Install needed packages

# install.packages("gdata")
library(gdata)
## gdata: Unable to locate valid perl interpreter
## gdata: 
## gdata: read.xls() will be unable to read Excel XLS and XLSX files
## gdata: unless the 'perl=' argument is used to specify the location
## gdata: of a valid perl intrpreter.
## gdata: 
## gdata: (To avoid display of this message in the future, please
## gdata: ensure perl is installed and available on the executable
## gdata: search path.)
## gdata: Unable to load perl libaries needed by read.xls()
## gdata: to support 'XLX' (Excel 97-2004) files.
## 
## gdata: Unable to load perl libaries needed by read.xls()
## gdata: to support 'XLSX' (Excel 2007+) files.
## 
## gdata: Run the function 'installXLSXsupport()'
## gdata: to automatically download and install the perl
## gdata: libaries needed to support Excel XLS and XLSX formats.
## 
## Attaching package: 'gdata'
## The following object is masked from 'package:stats':
## 
##     nobs
## The following object is masked from 'package:utils':
## 
##     object.size
## The following object is masked from 'package:base':
## 
##     startsWith
# install.packages("car")
library(car)
## Warning: package 'car' was built under R version 3.5.3
## Loading required package: carData
## Warning: package 'carData' was built under R version 3.5.2
# install.packages("lubridate")
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
## 
##     date
# install.packages("gmodels")
library(gmodels)

# install.packages("survival")
library(survival)

# install.packages("survRM2")
library(survRM2)
## Warning: package 'survRM2' was built under R version 3.5.3

Load database

# Load database
pSERG <- read.csv("G:\\PROJECTS\\pSERGbeforeafter\\Data\\pSERG.csv")

Data cleaning and data transformation

# Keep only the cases of refractory status epilepticus
pSERG <- pSERG[pSERG$SE_GROUP=="refractory_case", ]

# Transform date of status epilepticus into date format
pSERG$DATESEIZURE <- as.Date(pSERG$DATESEIZURE, format = "%m/%d/%Y")

# Order by date of status epilepticus
pSERG <- pSERG[order(pSERG$PATIENT_LABEL, pSERG$DATESEIZURE), ]

# Delete duplicate episodes from the same patient
pSERG <- pSERG[!duplicated(pSERG$PATIENT_LABEL), ]

# Delete patients with unknown age
pSERG$G_T_STTS_PLPTCS_EPISODE_MONTHS <- as.numeric(as.character(pSERG$G_T_STTS_PLPTCS_EPISODE_MONTHS))
## Warning: NAs introduced by coercion
pSERG$G_T_STTS_PLPTCUS_EPISODE_YEARS <- as.numeric(as.character(pSERG$G_T_STTS_PLPTCUS_EPISODE_YEARS))
## Warning: NAs introduced by coercion
pSERG$ageyears <- pSERG$G_T_STTS_PLPTCUS_EPISODE_YEARS + (pSERG$G_T_STTS_PLPTCS_EPISODE_MONTHS/12)
pSERG <- pSERG[complete.cases(pSERG[ ,"ageyears"]), ]

# Delete patients with unknown sex
pSERG <- pSERG[which(pSERG$SEX == "male" | pSERG$SEX == "female"), ]
pSERG$SEX <- droplevels(pSERG$SEX)

# Delete patients with unknown hospital onset
pSERG <- pSERG[which(pSERG$HOSPITALONSET == "yes" | pSERG$HOSPITALONSET == "no"), ]
pSERG$HOSPITALONSET <- droplevels(pSERG$HOSPITALONSET)

# Transform BZDTIME.0 to numeric
pSERG$BZDTIME.0 <- as.numeric(as.character(pSERG$BZDTIME.0))
## Warning: NAs introduced by coercion
# Delete patients with unknown time to first BZD
pSERG <- pSERG[complete.cases(pSERG[ , "BZDTIME.0"]), ]

# Transform AEDTIME.0 to numeric
pSERG$AEDTIME.0 <- as.numeric(as.character(pSERG$AEDTIME.0))
## Warning: NAs introduced by coercion
# Delete patients with unknown time to first non-BZD-AED
pSERG <- pSERG[complete.cases(pSERG[ , "AEDTIME.0"]), ]

# Delete patients with unknown type of SE (continuous vs intermittent)
pSERG <- pSERG[which(pSERG$TYPESTATUS == "continuous" | pSERG$TYPESTATUS == "intermittent"), ]
pSERG$TYPESTATUS <- droplevels(pSERG$TYPESTATUS)

# Create convulsive duration in minutes and eliminate patients with unknown convulsive duration
pSERG$CONVULSIVEDURATION <- as.numeric(as.character(pSERG$CONVULSIVEDURATION))
## Warning: NAs introduced by coercion
pSERG$CONVULSIVEmin <- pSERG$CONVULSIVEDURATION
pSERG$CONVULSIVEhr <- pSERG$CONVULSIVEDURATION * 60
pSERG$convulsivedurationmin <- ifelse(pSERG$CONVULSIVEDURATIONUNITS=="min", pSERG$CONVULSIVEmin, pSERG$CONVULSIVEhr)
pSERG <- pSERG[complete.cases(pSERG[ , "convulsivedurationmin"]), ]

# Delete patients with unknown race
pSERG <- pSERG[complete.cases(pSERG[ , "RACE"]), ]
pSERG$RACE <- droplevels(pSERG$RACE)

# Delete patients with unknown or nonsensical time of SE
pSERG$TIMESEIZURE_HOURS <- as.numeric(as.character(pSERG$TIMESEIZURE_HOURS))
## Warning: NAs introduced by coercion
pSERG <- pSERG[complete.cases(pSERG[ ,"TIMESEIZURE_HOURS"]), ]
pSERG$TIMESEIZURE_HOURS <- ifelse(pSERG$TIMESEIZURE_HOURS >= 100, pSERG$TIMESEIZURE_HOURS/100, pSERG$TIMESEIZURE_HOURS)
# Create variable day/night
pSERG$day <- ifelse(pSERG$TIMESEIZURE_HOURS >= 8 & pSERG$TIMESEIZURE_HOURS < 20, 1, 0)
# Delete patients with unknown time of SE onset (day or night)
pSERG <- pSERG[complete.cases(pSERG[ , "day"]), ]


###############VARIABLE CREATION#########################
# Divide race into White and non-white
pSERG$white <- ifelse(pSERG$RACE == 'white', 1, 0)

# Create variable delay
pSERG$delay[grepl("delay", pSERG$PAST)] <- 1
pSERG$delay[!grepl("delay", pSERG$PAST)] <- 0

# Create variable cerebral palsy
pSERG$palsy[grepl("palsy", pSERG$PAST)] <- 1
pSERG$palsy[!grepl("palsy", pSERG$PAST)] <- 0

# Create variable febrile
pSERG$febrile[grepl("febrile", pSERG$PAST)] <- 1
pSERG$febrile[!grepl("febrile", pSERG$PAST)] <- 0

# Create variable none (no neurological comorbidities)
pSERG$none[grepl("none", pSERG$PAST)] <- 1
pSERG$none[!grepl("none", pSERG$PAST)] <- 0

# Create variable prior epilepsy
pSERG$priorepilepsy[grepl("epi",pSERG$PAST)] <- 1
pSERG$priorepilepsy[!grepl("epi",pSERG$PAST)] <- 0

# Create variable prior status
pSERG$status[grepl("status",pSERG$PAST)] <- 1
pSERG$status[!grepl("status",pSERG$PAST)] <- 0

# Create variable of at least one continuous infusion
pSERG$CI <- ifelse(!(pSERG$CONTMED.0==""), 1, 0)

# Transform CI time into numeric
pSERG$CONTTIME.0 <- as.numeric(as.character(pSERG$CONTTIME.0))
## Warning: NAs introduced by coercion
# Create ICU stay in days
pSERG$ICU_DURATION <- as.numeric(as.character(pSERG$ICU_DURATION))
## Warning: NAs introduced by coercion
pSERG$ICUhours <- pSERG$ICU_DURATION/24
pSERG$ICUdays <- pSERG$ICU_DURATION
pSERG$ICUdurationdays <- ifelse(pSERG$ICU_UNITS=="days", pSERG$ICUdays, pSERG$ICUhours)

# Transform EMS arrival to numeric
pSERG$EMSARRIVAL <- as.numeric(as.character(pSERG$EMSARRIVAL))
## Warning: NAs introduced by coercion
# Transform time to hospital arrival to numeric
pSERG$HOSPITALARRIVAL <- as.numeric(as.character(pSERG$HOSPITALARRIVAL))
## Warning: NAs introduced by coercion
# Create variable BZD before hospital arrival
pSERG$AEDbeforehospital <- ifelse(pSERG$BZDTIME.0 < pSERG$HOSPITALARRIVAL, 1, 0)

# Reclasify etiology
pSERG$etiology2 <- recode(pSERG$ETIOLOGY, 
                          "'genetic' = 'genetic'; 
                          'metabolic'= 'metabolic'; 
                          'other' = 'other'; 
                          'structural' = 'structural'; 
                          'unknown' = 'unknown'; 
                          '' = 'unknown'")

# Structural etiology
pSERG$structuraletiology <- ifelse(pSERG$etiology2 == "structural", 1, 0)

# Create variable early academic year
pSERG$dateSE <- as.POSIXct(pSERG$DATESEIZURE, format = "%m/%d/%Y")
pSERG$monthSE <- month(pSERG$dateSE, label = FALSE)
pSERG$earlyacademicyear <- ifelse(pSERG$monthSE >= 7 & pSERG$monthSE <= 12, 1, 0)

# Create variable awareness of delays in time to treatment
pSERG$yearSE <- year(pSERG$dateSE)
pSERG$awareness <- ifelse(pSERG$yearSE >= 2015, 1, 0)

# Create variable event to use functions related to censoring
pSERG$event <- 1


# Create variable firstBZDmore20min
pSERG$firstBZDmore20min <- as.factor(ifelse(pSERG$BZDTIME.0 > 20, 1, 0))

# Create variable firstBZDmore40min
pSERG$firstBZDmore40min <- as.factor(ifelse(pSERG$BZDTIME.0 > 40, 1, 0))

# Create variable firstBZDmore60min
pSERG$firstBZDmore60min <- as.factor(ifelse(pSERG$BZDTIME.0 > 60, 1, 0))


# Create variable firstASMmore40min
pSERG$firstASMmore40min <- as.factor(ifelse(pSERG$AEDTIME.0 > 40, 1, 0))

# Create variable firstASMmore60min
pSERG$firstASMmore60min <- as.factor(ifelse(pSERG$AEDTIME.0 > 60, 1, 0))

# Create variable firstASMmore120min
pSERG$firstASMmore120min <- as.factor(ifelse(pSERG$AEDTIME.0 > 120, 1, 0))


# Create variable firstCImore60min
pSERG$firstCImore60min <- as.factor(ifelse(pSERG$CONTTIME.0 > 60, 1, 0))

# Create variable firstCImore120min
pSERG$firstCImore120min <- as.factor(ifelse(pSERG$CONTTIME.0 > 120, 1, 0))

# Create variable firstCImore240min
pSERG$firstCImore240min <- as.factor(ifelse(pSERG$CONTTIME.0 > 240, 1, 0))

# Transform variables to numeric for the rmst2 function
pSERG$TYPESTATUSnumeric <- ifelse(pSERG$TYPESTATUS=="continuous", 1, 0)
pSERG$HOSPITALONSETnumeric <- ifelse(pSERG$HOSPITALONSET=="yes", 1, 0)
pSERG$SEXnumeric <- ifelse(pSERG$SEX=="male", 1, 0)

Demographics

# Proportion of patients with rSE during the period of increased awareness of delays in time to treatment 
CrossTable(pSERG$awareness)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       151 |       177 | 
##           |     0.460 |     0.540 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Age
nobs(pSERG$ageyears)
## [1] 328
summary(pSERG$ageyears)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.08333  1.25419  3.83333  5.75898  9.35417 20.74167
sd(pSERG$ageyears)
## [1] 5.207827
# Age in patients <2015
nobs(pSERG[pSERG$awareness==0, ]$ageyears)
## [1] 151
summary(pSERG[pSERG$awareness==0, ]$ageyears)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.125   1.167   3.750   5.616   8.863  20.742
sd(pSERG[pSERG$awareness==0, ]$ageyears)
## [1] 5.290925
# Age in patients >=2015
nobs(pSERG[pSERG$awareness==1, ]$ageyears)
## [1] 177
summary(pSERG[pSERG$awareness==1, ]$ageyears)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  0.08333  1.28583  4.08333  5.88063  9.63608 19.30583
sd(pSERG[pSERG$awareness==1, ]$ageyears)
## [1] 5.147784
# Sex
CrossTable(pSERG$SEX)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |    female |      male | 
##           |-----------|-----------|
##           |       145 |       183 | 
##           |     0.442 |     0.558 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Sex in patients <2015
CrossTable(pSERG[pSERG$awareness==0, ]$SEX)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##           |    female |      male | 
##           |-----------|-----------|
##           |        71 |        80 | 
##           |     0.470 |     0.530 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Sex in patients >=2015
CrossTable(pSERG[pSERG$awareness==1, ]$SEX)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##           |    female |      male | 
##           |-----------|-----------|
##           |        74 |       103 | 
##           |     0.418 |     0.582 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Race
CrossTable(pSERG$RACE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##                                     |       american_indian_alaska_native |                              arabic |                               asian |           black_or_african_american | native_hawaiian_or_pacific_islander | 
##                                     |-------------------------------------|-------------------------------------|-------------------------------------|-------------------------------------|-------------------------------------|
##                                     |                                   1 |                                  10 |                                  11 |                                  65 |                                   2 | 
##                                     |                               0.003 |                               0.030 |                               0.034 |                               0.198 |                               0.006 | 
##                                     |-------------------------------------|-------------------------------------|-------------------------------------|-------------------------------------|-------------------------------------|
## 
## 
##                                     |                        not_reported |                             unknown |                               white | 
##                                     |-------------------------------------|-------------------------------------|-------------------------------------|
##                                     |                                   8 |                                  22 |                                 209 | 
##                                     |                               0.024 |                               0.067 |                               0.637 | 
##                                     |-------------------------------------|-------------------------------------|-------------------------------------|
## 
## 
## 
## 
# Race in patients <2015
CrossTable(pSERG[pSERG$awareness==0, ]$RACE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##                                     |                              arabic |                               asian |           black_or_african_american | native_hawaiian_or_pacific_islander |                        not_reported | 
##                                     |-------------------------------------|-------------------------------------|-------------------------------------|-------------------------------------|-------------------------------------|
##                                     |                                   7 |                                   6 |                                  38 |                                   1 |                                   5 | 
##                                     |                               0.046 |                               0.040 |                               0.252 |                               0.007 |                               0.033 | 
##                                     |-------------------------------------|-------------------------------------|-------------------------------------|-------------------------------------|-------------------------------------|
## 
## 
##                                     |                             unknown |                               white | 
##                                     |-------------------------------------|-------------------------------------|
##                                     |                                  13 |                                  81 | 
##                                     |                               0.086 |                               0.536 | 
##                                     |-------------------------------------|-------------------------------------|
## 
## 
## 
## 
# Race in patients >=2015
CrossTable(pSERG[pSERG$awareness==1, ]$RACE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##                                     |       american_indian_alaska_native |                              arabic |                               asian |           black_or_african_american | native_hawaiian_or_pacific_islander | 
##                                     |-------------------------------------|-------------------------------------|-------------------------------------|-------------------------------------|-------------------------------------|
##                                     |                                   1 |                                   3 |                                   5 |                                  27 |                                   1 | 
##                                     |                               0.006 |                               0.017 |                               0.028 |                               0.153 |                               0.006 | 
##                                     |-------------------------------------|-------------------------------------|-------------------------------------|-------------------------------------|-------------------------------------|
## 
## 
##                                     |                        not_reported |                             unknown |                               white | 
##                                     |-------------------------------------|-------------------------------------|-------------------------------------|
##                                     |                                   3 |                                   9 |                                 128 | 
##                                     |                               0.017 |                               0.051 |                               0.723 | 
##                                     |-------------------------------------|-------------------------------------|-------------------------------------|
## 
## 
## 
## 
# Ethnicity
CrossTable(pSERG$ETHNICITY)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##                        |     hispanic_or_latino | not_hispanic_or_latino |           not_reported |                unknown | 
##                        |------------------------|------------------------|------------------------|------------------------|
##                        |                     51 |                    247 |                     18 |                     12 | 
##                        |                  0.155 |                  0.753 |                  0.055 |                  0.037 | 
##                        |------------------------|------------------------|------------------------|------------------------|
## 
## 
## 
## 
# Ethnicity in patients <2015
CrossTable(pSERG[pSERG$awareness==0, ]$ETHNICITY)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##                        |     hispanic_or_latino | not_hispanic_or_latino |           not_reported |                unknown | 
##                        |------------------------|------------------------|------------------------|------------------------|
##                        |                     26 |                    111 |                      8 |                      6 | 
##                        |                  0.172 |                  0.735 |                  0.053 |                  0.040 | 
##                        |------------------------|------------------------|------------------------|------------------------|
## 
## 
## 
## 
# Ethnicity in patients >=2015
CrossTable(pSERG[pSERG$awareness==1, ]$ETHNICITY)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##                        |     hispanic_or_latino | not_hispanic_or_latino |           not_reported |                unknown | 
##                        |------------------------|------------------------|------------------------|------------------------|
##                        |                     25 |                    136 |                     10 |                      6 | 
##                        |                  0.141 |                  0.768 |                  0.056 |                  0.034 | 
##                        |------------------------|------------------------|------------------------|------------------------|
## 
## 
## 
## 
# Delay
CrossTable(pSERG$delay)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       161 |       167 | 
##           |     0.491 |     0.509 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Delay in patients <2015
CrossTable(pSERG[pSERG$awareness==0, ]$delay)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        75 |        76 | 
##           |     0.497 |     0.503 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Delay in patients >=2015
CrossTable(pSERG[pSERG$awareness==1, ]$delay)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        86 |        91 | 
##           |     0.486 |     0.514 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Prior epilepsy
CrossTable(pSERG$priorepilepsy)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       167 |       161 | 
##           |     0.509 |     0.491 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Prior epilepsy in patients <2015
CrossTable(pSERG[pSERG$awareness==0, ]$priorepilepsy)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        80 |        71 | 
##           |     0.530 |     0.470 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Prior epilepsy in patients >=2015
CrossTable(pSERG[pSERG$awareness==1, ]$priorepilepsy)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        87 |        90 | 
##           |     0.492 |     0.508 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Status
CrossTable(pSERG$status)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       266 |        62 | 
##           |     0.811 |     0.189 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Status in patients <2015
CrossTable(pSERG[pSERG$awareness==0, ]$status)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       125 |        26 | 
##           |     0.828 |     0.172 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Status in patients >=2015
CrossTable(pSERG[pSERG$awareness==1, ]$status)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       141 |        36 | 
##           |     0.797 |     0.203 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Palsy
CrossTable(pSERG$palsy)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       297 |        31 | 
##           |     0.905 |     0.095 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Palsy in patients <2015
CrossTable(pSERG[pSERG$awareness==0, ]$palsy)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       138 |        13 | 
##           |     0.914 |     0.086 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Palsy in patients >=2015
CrossTable(pSERG[pSERG$awareness==1, ]$palsy)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       159 |        18 | 
##           |     0.898 |     0.102 | 
##           |-----------|-----------|
## 
## 
## 
## 
# None
CrossTable(pSERG$none)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       218 |       110 | 
##           |     0.665 |     0.335 | 
##           |-----------|-----------|
## 
## 
## 
## 
# None in patients <2015
CrossTable(pSERG[pSERG$awareness==0, ]$none)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        95 |        56 | 
##           |     0.629 |     0.371 | 
##           |-----------|-----------|
## 
## 
## 
## 
# None in patients >=2015
CrossTable(pSERG[pSERG$awareness==1, ]$none)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       123 |        54 | 
##           |     0.695 |     0.305 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Etiology
CrossTable(pSERG$etiology2)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##            |    genetic |  metabolic |      other | structural |    unknown | 
##            |------------|------------|------------|------------|------------|
##            |         62 |         15 |         56 |         83 |        112 | 
##            |      0.189 |      0.046 |      0.171 |      0.253 |      0.341 | 
##            |------------|------------|------------|------------|------------|
## 
## 
## 
## 
# Etiology in patients <2015
CrossTable(pSERG[pSERG$awareness==0, ]$etiology2)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##            |    genetic |  metabolic |      other | structural |    unknown | 
##            |------------|------------|------------|------------|------------|
##            |         24 |         11 |         25 |         44 |         47 | 
##            |      0.159 |      0.073 |      0.166 |      0.291 |      0.311 | 
##            |------------|------------|------------|------------|------------|
## 
## 
## 
## 
# Etiology in patients >=2015
CrossTable(pSERG[pSERG$awareness==1, ]$etiology2)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##            |    genetic |  metabolic |      other | structural |    unknown | 
##            |------------|------------|------------|------------|------------|
##            |         38 |          4 |         31 |         39 |         65 | 
##            |      0.215 |      0.023 |      0.175 |      0.220 |      0.367 | 
##            |------------|------------|------------|------------|------------|
## 
## 
## 
## 
# Hospital onset
CrossTable(pSERG$HOSPITALONSET)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |        no |       yes | 
##           |-----------|-----------|
##           |       222 |       106 | 
##           |     0.677 |     0.323 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Hospital onset in patients <2015
CrossTable(pSERG[pSERG$awareness==0, ]$HOSPITALONSET)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##           |        no |       yes | 
##           |-----------|-----------|
##           |       105 |        46 | 
##           |     0.695 |     0.305 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Hospital onset in patients >=2015
CrossTable(pSERG[pSERG$awareness==1, ]$HOSPITALONSET)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##           |        no |       yes | 
##           |-----------|-----------|
##           |       117 |        60 | 
##           |     0.661 |     0.339 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Convulsive duration
nobs(pSERG$convulsivedurationmin)
## [1] 328
summary(pSERG$convulsivedurationmin)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##      0.0     60.0    124.5   2159.7    281.5 172800.0
# Convulsive duration in patients <2015
summary(pSERG[pSERG$awareness==0, ]$convulsivedurationmin)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       0      60     135    2582     275  172800
# Convulsive duration in patients >=2015
summary(pSERG[pSERG$awareness==1, ]$convulsivedurationmin)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       0      60     120    1800     286   90720
# Time to first BZD
nobs(pSERG$BZDTIME.0)
## [1] 328
summary(pSERG$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   17.00   63.74   45.00 1440.00
# Time to first BZD in patients <2015
summary(pSERG[pSERG$awareness==0, ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   20.00   55.26   52.50  720.00
# Time to first BZD in patients >=2015
summary(pSERG[pSERG$awareness==1, ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   15.00   70.98   38.00 1440.00
# Time to first non-BZD-AED
nobs(pSERG$AEDTIME.0)
## [1] 328
summary(pSERG$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   33.75   65.50  162.60  150.00 4320.00
# Time to first non-BZD-AED in patients <2015
summary(pSERG[pSERG$awareness==0, ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     5.0    34.5    68.0   155.9   163.5  1800.0
# Time to first non-BZD-AED in patients >=2015
summary(pSERG[pSERG$awareness==1, ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    33.0    65.0   168.3   142.0  4320.0
# Time to first CI
nobs(pSERG$CONTTIME.0)
## [1] 152
summary(pSERG$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   113.5   173.5   523.7   543.2  7200.0     176
# Time to first CI in patients <2015
summary(pSERG[pSERG$awareness==0, ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   124.2   186.0   511.8   571.0  4320.0      83
# Time to first CI in patients >=2015
summary(pSERG[pSERG$awareness==1, ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0    89.5   160.0   533.4   495.0  7200.0      93
# Length of stay
nobs(pSERG$ICUdurationdays)
## [1] 311
summary(pSERG$ICUdurationdays)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    0.00    2.00    4.00   12.15   11.00  180.00      17
# Length of stay in patients <2015
summary(pSERG[pSERG$awareness==0, ]$ICUdurationdays)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##   0.000   2.000   4.278  11.912  11.932 154.000       2
# Length of stay in patients >=2015
summary(pSERG[pSERG$awareness==1, ]$ICUdurationdays)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##   0.000   1.691   4.000  12.368  11.000 180.000      15
# Mortality
CrossTable(pSERG$ALIVE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |           |        no |       yes | 
##           |-----------|-----------|-----------|
##           |         3 |        11 |       314 | 
##           |     0.009 |     0.034 |     0.957 | 
##           |-----------|-----------|-----------|
## 
## 
## 
## 
# Mortality in patients <2015
CrossTable(pSERG[pSERG$awareness==0, ]$ALIVE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##           |        no |       yes | 
##           |-----------|-----------|
##           |         5 |       146 | 
##           |     0.033 |     0.967 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Mortality in patients >=2015
CrossTable(pSERG[pSERG$awareness==1, ]$ALIVE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##           |           |        no |       yes | 
##           |-----------|-----------|-----------|
##           |         3 |         6 |       168 | 
##           |     0.017 |     0.034 |     0.949 | 
##           |-----------|-----------|-----------|
## 
## 
## 
## 
# Time to first BZD by year
tapply(pSERG$BZDTIME.0, as.factor(pSERG$yearSE), length)
## 2011 2012 2013 2014 2015 2016 2017 2018 2019 
##    2   59   44   46   36   50   42   34   15
tapply(pSERG$BZDTIME.0, as.factor(pSERG$yearSE), summary)
## $`2011`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       5       5       5       5       5       5 
## 
## $`2012`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    2.00    5.00   17.00   43.71   60.00  360.00 
## 
## $`2013`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   20.00   67.07   49.25  538.00 
## 
## $`2014`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   18.50   60.96   53.75  720.00 
## 
## $`2015`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   14.00   71.42   29.25 1264.00 
## 
## $`2016`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.00    8.25   20.00   63.88   49.50 1132.00 
## 
## $`2017`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.00    5.00   16.50   89.29   41.00 1440.00 
## 
## $`2018`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    6.00   15.00   66.12   32.25  625.00 
## 
## $`2019`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.00    5.00   22.00   53.33   32.50  517.00
# Figure time to first BZD by year
plot(survfit(Surv(pSERG$BZDTIME.0) ~ as.factor(pSERG$yearSE)), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), 
     col = c("aquamarine2", "chartreuse", "darkorchid1", "darkorange", "brown3", "cyan2", "deeppink1", "coral2", "darkturquoise"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")
legend("bottomright", legend=c("2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019"),
  col=c("aquamarine2", "chartreuse", "darkorchid1", "darkorange", "brown3", "cyan2", "deeppink1", "coral2", "darkturquoise"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1)

# Time to first ASM by year
tapply(pSERG$AEDTIME.0, as.factor(pSERG$yearSE), length)
## 2011 2012 2013 2014 2015 2016 2017 2018 2019 
##    2   59   44   46   36   50   42   34   15
tapply(pSERG$AEDTIME.0, as.factor(pSERG$yearSE), summary)
## $`2011`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   30.00   45.75   61.50   61.50   77.25   93.00 
## 
## $`2012`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    10.0    28.0    61.0   105.0   112.5   780.0 
## 
## $`2013`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     5.0    39.0    65.0   174.5   184.0  1800.0 
## 
## $`2014`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    20.0    48.5    83.0   207.5   207.5  1440.0 
## 
## $`2015`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    31.5    62.5   253.1   150.0  4320.0 
## 
## $`2016`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    5.00   42.75   78.00  129.76  129.75 1276.00 
## 
## $`2017`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    10.0    30.5    63.0   151.5   118.8  1419.0 
## 
## $`2018`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   16.00   34.25   63.00  108.97  119.50  385.00 
## 
## $`2019`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    10.0    40.5    77.0   274.7   378.0  1488.0
# Figure time to first non-BZD AED by year
plot(survfit(Surv(pSERG$AEDTIME.0) ~ as.factor(pSERG$yearSE)), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("aquamarine2", "chartreuse", "darkorchid1", "darkorange", "brown3", "cyan2", "deeppink1", "coral2", "darkturquoise"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")
legend("bottomright", legend=c("2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019"),
  col=c("aquamarine2", "chartreuse", "darkorchid1", "darkorange", "brown3", "cyan2", "deeppink1", "coral2", "darkturquoise"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1)

# Time to first CI by year
tapply(pSERG$CONTTIME.0, as.factor(pSERG$yearSE), length)
## 2011 2012 2013 2014 2015 2016 2017 2018 2019 
##    2   59   44   46   36   50   42   34   15
tapply(pSERG$CONTTIME.0, as.factor(pSERG$yearSE), summary)
## $`2011`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     360     360     360     360     360     360       1 
## 
## $`2012`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    30.0   125.0   180.0   588.2   520.0  4320.0      38 
## 
## $`2013`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   148.0   230.0   411.7   525.0  2880.0      19 
## 
## $`2014`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##      20     102     165     562     992    2520      25 
## 
## $`2015`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    45.0   118.0   166.0   756.5   367.5  7200.0      20 
## 
## $`2016`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    53.0   103.5   160.0   338.2   440.5  1470.0      19 
## 
## $`2017`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    5.00   71.75  157.50  446.95  505.00 2370.00      22 
## 
## $`2018`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##   49.00   85.75  108.00  382.71  219.50 3008.00      20 
## 
## $`2019`
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##   480.0   957.5  1435.0  2639.3  3719.0  6003.0      12
# Figure time to first CI by awareness
plot(survfit(Surv(pSERG$CONTTIME.0) ~ as.factor(pSERG$yearSE)), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("aquamarine2", "chartreuse", "darkorchid1", "darkorange", "brown3", "cyan2", "deeppink1", "coral2", "darkturquoise"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")
legend("bottomright", legend=c("2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019"),
  col=c("aquamarine2", "chartreuse", "darkorchid1", "darkorange", "brown3", "cyan2", "deeppink1", "coral2", "darkturquoise"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

Time to treatment

# Time to first BZD
summary(pSERG$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   17.00   63.74   45.00 1440.00
sd(pSERG$BZDTIME.0)
## [1] 157.5196
survfit(Surv(pSERG$BZDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG$BZDTIME.0) ~ 1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##     328     328      17      14      20
# Figure time to first BZD
plot(survfit(Surv(pSERG$BZDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")

# Time to first BZD depending on awareness
summary(pSERG[which(pSERG$awareness == 0), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   20.00   55.26   52.50  720.00
summary(pSERG[which(pSERG$awareness == 1), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   15.00   70.98   38.00 1440.00
survdiff(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho = 1)
## 
##                     N Observed Expected (O-E)^2/E (O-E)^2/V
## pSERG$awareness=0 151     76.8     81.3     0.245     0.733
## pSERG$awareness=1 177     94.1     89.6     0.223     0.733
## 
##  Chisq= 0.7  on 1 degrees of freedom, p= 0.4
pchisq(survdiff(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.3918653
# Figure time to first BZD by awareness
plot(survfit(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first BZD
summary(coxph(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + pSERG$HOSPITALONSET + 
                pSERG$day + pSERG$earlyacademicyear + pSERG$white +
                pSERG$structuraletiology + pSERG$priorepilepsy +
                pSERG$status + pSERG$ageyears + pSERG$SEX))
## Call:
## coxph(formula = Surv(pSERG$BZDTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + 
##     pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + 
##     pSERG$white + pSERG$structuraletiology + pSERG$priorepilepsy + 
##     pSERG$status + pSERG$ageyears + pSERG$SEX)
## 
##   n= 328, number of events= 328 
## 
##                                   coef exp(coef)  se(coef)      z Pr(>|z|)
## pSERG$awareness               0.012427  1.012505  0.113800  0.109  0.91304
## pSERG$TYPESTATUSintermittent -0.400432  0.670031  0.128309 -3.121  0.00180
## pSERG$HOSPITALONSETyes        0.362862  1.437438  0.124163  2.922  0.00347
## pSERG$day                     0.094270  1.098856  0.114743  0.822  0.41132
## pSERG$earlyacademicyear       0.191032  1.210498  0.112253  1.702  0.08879
## pSERG$white                   0.001637  1.001639  0.122804  0.013  0.98936
## pSERG$structuraletiology      0.059220  1.061008  0.135405  0.437  0.66186
## pSERG$priorepilepsy           0.021959  1.022202  0.124602  0.176  0.86011
## pSERG$status                  0.496292  1.642619  0.158110  3.139  0.00170
## pSERG$ageyears               -0.002526  0.997477  0.011114 -0.227  0.82019
## pSERG$SEXmale                 0.062825  1.064840  0.115626  0.543  0.58690
##                                
## pSERG$awareness                
## pSERG$TYPESTATUSintermittent **
## pSERG$HOSPITALONSETyes       **
## pSERG$day                      
## pSERG$earlyacademicyear      . 
## pSERG$white                    
## pSERG$structuraletiology       
## pSERG$priorepilepsy            
## pSERG$status                 **
## pSERG$ageyears                 
## pSERG$SEXmale                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                              exp(coef) exp(-coef) lower .95 upper .95
## pSERG$awareness                 1.0125     0.9876    0.8101    1.2655
## pSERG$TYPESTATUSintermittent    0.6700     1.4925    0.5210    0.8616
## pSERG$HOSPITALONSETyes          1.4374     0.6957    1.1269    1.8335
## pSERG$day                       1.0989     0.9100    0.8775    1.3760
## pSERG$earlyacademicyear         1.2105     0.8261    0.9714    1.5084
## pSERG$white                     1.0016     0.9984    0.7874    1.2742
## pSERG$structuraletiology        1.0610     0.9425    0.8137    1.3835
## pSERG$priorepilepsy             1.0222     0.9783    0.8007    1.3050
## pSERG$status                    1.6426     0.6088    1.2049    2.2393
## pSERG$ageyears                  0.9975     1.0025    0.9760    1.0194
## pSERG$SEXmale                   1.0648     0.9391    0.8489    1.3357
## 
## Concordance= 0.615  (se = 0.02 )
## Rsquare= 0.106   (max possible= 1 )
## Likelihood ratio test= 36.63  on 11 df,   p=1e-04
## Wald test            = 38.54  on 11 df,   p=6e-05
## Score (logrank) test = 39.46  on 11 df,   p=4e-05
# Time to first non-BZD AED
summary(pSERG$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   33.75   65.50  162.60  150.00 4320.00
sd(pSERG$AEDTIME.0)
## [1] 333.9342
survfit(Surv(pSERG$AEDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG$AEDTIME.0) ~ 1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##   328.0   328.0    65.5    60.0    77.0
# Figure time to first non-BZD AED
plot(survfit(Surv(pSERG$AEDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")

# Time to first non-BZD AED depending on awareness
summary(pSERG[which(pSERG$awareness == 0), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     5.0    34.5    68.0   155.9   163.5  1800.0
summary(pSERG[which(pSERG$awareness == 1), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    33.0    65.0   168.3   142.0  4320.0
survdiff(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho = 1)
## 
##                     N Observed Expected (O-E)^2/E (O-E)^2/V
## pSERG$awareness=0 151     75.4     77.2    0.0412     0.117
## pSERG$awareness=1 177     90.4     88.6    0.0359     0.117
## 
##  Chisq= 0.1  on 1 degrees of freedom, p= 0.7
pchisq(survdiff(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.7328349
# Figure time to first non-BZD AED by awareness
plot(survfit(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first non-BZD AED
summary(coxph(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + pSERG$HOSPITALONSET + 
                pSERG$day + pSERG$earlyacademicyear + pSERG$white +
                pSERG$structuraletiology + pSERG$priorepilepsy +
                pSERG$status + pSERG$ageyears + pSERG$SEX))
## Call:
## coxph(formula = Surv(pSERG$AEDTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + 
##     pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + 
##     pSERG$white + pSERG$structuraletiology + pSERG$priorepilepsy + 
##     pSERG$status + pSERG$ageyears + pSERG$SEX)
## 
##   n= 328, number of events= 328 
## 
##                                  coef exp(coef) se(coef)      z Pr(>|z|)
## pSERG$awareness               0.01269   1.01277  0.11358  0.112   0.9111
## pSERG$TYPESTATUSintermittent -0.56309   0.56945  0.12731 -4.423 9.73e-06
## pSERG$HOSPITALONSETyes        0.67761   1.96916  0.12243  5.535 3.12e-08
## pSERG$day                     0.23887   1.26981  0.11599  2.059   0.0395
## pSERG$earlyacademicyear       0.15103   1.16303  0.11373  1.328   0.1842
## pSERG$white                  -0.03675   0.96392  0.11990 -0.306   0.7593
## pSERG$structuraletiology      0.27808   1.32060  0.13247  2.099   0.0358
## pSERG$priorepilepsy          -0.06798   0.93428  0.12420 -0.547   0.5841
## pSERG$status                  0.28074   1.32411  0.15700  1.788   0.0737
## pSERG$ageyears               -0.02287   0.97739  0.01107 -2.066   0.0388
## pSERG$SEXmale                 0.07086   1.07343  0.11609  0.610   0.5416
##                                 
## pSERG$awareness                 
## pSERG$TYPESTATUSintermittent ***
## pSERG$HOSPITALONSETyes       ***
## pSERG$day                    *  
## pSERG$earlyacademicyear         
## pSERG$white                     
## pSERG$structuraletiology     *  
## pSERG$priorepilepsy             
## pSERG$status                 .  
## pSERG$ageyears               *  
## pSERG$SEXmale                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                              exp(coef) exp(-coef) lower .95 upper .95
## pSERG$awareness                 1.0128     0.9874    0.8106    1.2653
## pSERG$TYPESTATUSintermittent    0.5694     1.7561    0.4437    0.7308
## pSERG$HOSPITALONSETyes          1.9692     0.5078    1.5491    2.5032
## pSERG$day                       1.2698     0.7875    1.0116    1.5939
## pSERG$earlyacademicyear         1.1630     0.8598    0.9306    1.4535
## pSERG$white                     0.9639     1.0374    0.7620    1.2193
## pSERG$structuraletiology        1.3206     0.7572    1.0186    1.7121
## pSERG$priorepilepsy             0.9343     1.0703    0.7324    1.1918
## pSERG$status                    1.3241     0.7552    0.9734    1.8012
## pSERG$ageyears                  0.9774     1.0231    0.9564    0.9988
## pSERG$SEXmale                   1.0734     0.9316    0.8550    1.3477
## 
## Concordance= 0.653  (se = 0.019 )
## Rsquare= 0.183   (max possible= 1 )
## Likelihood ratio test= 66.44  on 11 df,   p=6e-10
## Wald test            = 68.08  on 11 df,   p=3e-10
## Score (logrank) test = 69.55  on 11 df,   p=1e-10
# Time to first CI
summary(pSERG$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   113.5   173.5   523.7   543.2  7200.0     176
sd(pSERG$CONTTIME.0)
## [1] NA
survfit(Surv(pSERG$CONTTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG$CONTTIME.0) ~ 1)
## 
##    176 observations deleted due to missingness 
##       n  events  median 0.95LCL 0.95UCL 
##     152     152     174     154     230
# Figure time to first CI
plot(survfit(Surv(pSERG$CONTTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")

# Time to first CI depending on awareness
summary(pSERG[which(pSERG$awareness == 0), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   124.2   186.0   511.8   571.0  4320.0      83
summary(pSERG[which(pSERG$awareness == 1), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0    89.5   160.0   533.4   495.0  7200.0      93
survdiff(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, 
##     rho = 1)
## 
## n=152, 176 observations deleted due to missingness.
## 
##                    N Observed Expected (O-E)^2/E (O-E)^2/V
## pSERG$awareness=0 68     32.2     36.5     0.516      1.48
## pSERG$awareness=1 84     44.6     40.3     0.468      1.48
## 
##  Chisq= 1.5  on 1 degrees of freedom, p= 0.2
pchisq(survdiff(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.2236165
# Figure time to first CI by awareness
plot(survfit(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first CI
summary(coxph(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + pSERG$HOSPITALONSET + 
                pSERG$day + pSERG$earlyacademicyear + pSERG$white +
                pSERG$structuraletiology + pSERG$priorepilepsy +
                pSERG$status + pSERG$ageyears + pSERG$SEX))
## Call:
## coxph(formula = Surv(pSERG$CONTTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + 
##     pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + 
##     pSERG$white + pSERG$structuraletiology + pSERG$priorepilepsy + 
##     pSERG$status + pSERG$ageyears + pSERG$SEX)
## 
##   n= 152, number of events= 152 
##    (176 observations deleted due to missingness)
## 
##                                   coef exp(coef)  se(coef)      z Pr(>|z|)
## pSERG$awareness               0.079430  1.082670  0.171255  0.464   0.6428
## pSERG$TYPESTATUSintermittent -0.296428  0.743469  0.195778 -1.514   0.1300
## pSERG$HOSPITALONSETyes        0.103818  1.109398  0.183383  0.566   0.5713
## pSERG$day                    -0.022113  0.978130  0.175102 -0.126   0.8995
## pSERG$earlyacademicyear       0.250987  1.285293  0.178375  1.407   0.1594
## pSERG$white                  -0.352717  0.702776  0.193912 -1.819   0.0689
## pSERG$structuraletiology      0.212484  1.236746  0.206259  1.030   0.3029
## pSERG$priorepilepsy           0.211229  1.235195  0.199131  1.061   0.2888
## pSERG$status                  0.117848  1.125073  0.231835  0.508   0.6112
## pSERG$ageyears               -0.001698  0.998303  0.016895 -0.101   0.9199
## pSERG$SEXmale                 0.178052  1.194888  0.173236  1.028   0.3040
##                               
## pSERG$awareness               
## pSERG$TYPESTATUSintermittent  
## pSERG$HOSPITALONSETyes        
## pSERG$day                     
## pSERG$earlyacademicyear       
## pSERG$white                  .
## pSERG$structuraletiology      
## pSERG$priorepilepsy           
## pSERG$status                  
## pSERG$ageyears                
## pSERG$SEXmale                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                              exp(coef) exp(-coef) lower .95 upper .95
## pSERG$awareness                 1.0827     0.9236    0.7740     1.514
## pSERG$TYPESTATUSintermittent    0.7435     1.3450    0.5065     1.091
## pSERG$HOSPITALONSETyes          1.1094     0.9014    0.7744     1.589
## pSERG$day                       0.9781     1.0224    0.6940     1.379
## pSERG$earlyacademicyear         1.2853     0.7780    0.9061     1.823
## pSERG$white                     0.7028     1.4229    0.4806     1.028
## pSERG$structuraletiology        1.2367     0.8086    0.8255     1.853
## pSERG$priorepilepsy             1.2352     0.8096    0.8361     1.825
## pSERG$status                    1.1251     0.8888    0.7142     1.772
## pSERG$ageyears                  0.9983     1.0017    0.9658     1.032
## pSERG$SEXmale                   1.1949     0.8369    0.8509     1.678
## 
## Concordance= 0.569  (se = 0.028 )
## Rsquare= 0.071   (max possible= 1 )
## Likelihood ratio test= 11.21  on 11 df,   p=0.4
## Wald test            = 11.41  on 11 df,   p=0.4
## Score (logrank) test = 11.48  on 11 df,   p=0.4
## Correction for multiple comparisons
timetotreatment <- c(pchisq(survdiff(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE),
                     
                     summary(coxph(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + 
                                     pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + 
                                     pSERG$white + pSERG$structuraletiology + pSERG$priorepilepsy +
                                     pSERG$status + pSERG$ageyears + pSERG$SEX))$coefficients[1, 5],
                     
                     pchisq(survdiff(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE),
                     
                     summary(coxph(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + 
                     pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + pSERG$white +
                     pSERG$structuraletiology + pSERG$priorepilepsy + pSERG$status + 
                     pSERG$ageyears + pSERG$SEX))$coefficients[1, 5],
                     
                     pchisq(survdiff(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE),
                     
                     summary(coxph(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + 
                     pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + pSERG$white +
                     pSERG$structuraletiology + pSERG$priorepilepsy + pSERG$status + 
                     pSERG$ageyears + pSERG$SEX))$coefficients[1, 5]
                     )

p.adjust(timetotreatment, "BH") 
## [1] 0.9130407 0.9130407 0.9130407 0.9130407 0.9130407 0.9130407

Treatment within recommendations and outliers

# First BZD later than 20 minutes
CrossTable(pSERG$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       187 |       141 | 
##           |     0.570 |     0.430 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        82 |        69 | 
##           |     0.543 |     0.457 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       105 |        72 | 
##           |     0.593 |     0.407 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstBZDmore20min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstBZDmore20min and pSERG$awareness
## p-value = 0.3728
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.5132229 1.2943583
## sample estimates:
## odds ratio 
##  0.8154231
# Difference adjusting for covariates within the first 20 minutes
rmst2(time=pSERG$BZDTIME.0, status=pSERG$event, arm=pSERG$awareness, tau=20,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 20  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.341    -1.889     1.206 0.665
## RMST (arm=1)/(arm=0)  0.976     0.869     1.095 0.676
## RMTL (arm=1)/(arm=0)  1.058     0.834     1.341 0.643
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            16.359    1.238 13.218 0.000    13.933    18.784
## arm                  -0.341    0.789 -0.432 0.665    -1.889     1.206
## TYPESTATUSnumeric    -0.471    0.806 -0.585 0.559    -2.051     1.108
## HOSPITALONSETnumeric -3.339    0.862 -3.873 0.000    -5.029    -1.649
## day                  -0.738    0.777 -0.950 0.342    -2.261     0.784
## earlyacademicyear    -1.189    0.777 -1.531 0.126    -2.711     0.333
## white                -0.007    0.804 -0.009 0.993    -1.584     1.569
## structuraletiology   -0.689    0.927 -0.744 0.457    -2.506     1.127
## priorepilepsy        -0.664    0.837 -0.794 0.427    -2.304     0.976
## status               -3.154    1.139 -2.770 0.006    -5.385    -0.922
## ageyears              0.045    0.078  0.572 0.567    -0.109     0.199
## SEXnumeric            0.434    0.791  0.549 0.583    -1.115     1.984
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             2.812    0.092 30.609 0.000    16.639    13.897
## arm                  -0.025    0.059 -0.418 0.676     0.976     0.869
## TYPESTATUSnumeric    -0.033    0.061 -0.539 0.590     0.968     0.859
## HOSPITALONSETnumeric -0.266    0.073 -3.647 0.000     0.767     0.665
## day                  -0.057    0.058 -0.993 0.321     0.944     0.843
## earlyacademicyear    -0.087    0.059 -1.490 0.136     0.916     0.817
## white                -0.002    0.060 -0.033 0.974     0.998     0.887
## structuraletiology   -0.052    0.071 -0.731 0.465     0.949     0.825
## priorepilepsy        -0.053    0.061 -0.869 0.385     0.949     0.842
## status               -0.264    0.101 -2.613 0.009     0.768     0.630
## ageyears              0.003    0.006  0.582 0.561     1.003     0.992
## SEXnumeric            0.033    0.059  0.563 0.574     1.034     0.920
##                      upper .95
## intercept               19.921
## arm                      1.095
## TYPESTATUSnumeric        1.091
## HOSPITALONSETnumeric     0.884
## day                      1.057
## earlyacademicyear        1.028
## white                    1.123
## structuraletiology       1.092
## priorepilepsy            1.069
## status                   0.936
## ageyears                 1.015
## SEXnumeric               1.161
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             1.415    0.197  7.178 0.000     4.116     2.797
## arm                   0.056    0.121  0.463 0.643     1.058     0.834
## TYPESTATUSnumeric     0.084    0.120  0.697 0.486     1.087     0.859
## HOSPITALONSETnumeric  0.465    0.119  3.913 0.000     1.592     1.261
## day                   0.104    0.121  0.862 0.389     1.110     0.876
## earlyacademicyear     0.186    0.118  1.577 0.115     1.205     0.956
## white                -0.006    0.122 -0.049 0.961     0.994     0.782
## structuraletiology    0.101    0.134  0.757 0.449     1.107     0.851
## priorepilepsy         0.089    0.138  0.642 0.521     1.093     0.833
## status                0.404    0.146  2.761 0.006     1.499     1.125
## ageyears             -0.007    0.012 -0.545 0.586     0.993     0.969
## SEXnumeric           -0.062    0.121 -0.513 0.608     0.940     0.742
##                      upper .95
## intercept                6.057
## arm                      1.341
## TYPESTATUSnumeric        1.376
## HOSPITALONSETnumeric     2.010
## day                      1.407
## earlyacademicyear        1.519
## white                    1.264
## structuraletiology       1.438
## priorepilepsy            1.433
## status                   1.997
## ageyears                 1.018
## SEXnumeric               1.191
# First BZD later than 40 minutes
CrossTable(pSERG$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       238 |        90 | 
##           |     0.726 |     0.274 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       104 |        47 | 
##           |     0.689 |     0.311 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       134 |        43 | 
##           |     0.757 |     0.243 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstBZDmore40min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstBZDmore40min and pSERG$awareness
## p-value = 0.1743
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4237375 1.1895374
## sample estimates:
## odds ratio 
##  0.7108269
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG$BZDTIME.0, status=pSERG$event, arm=pSERG$awareness, tau=40,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -1.733    -4.913     1.447 0.286
## RMST (arm=1)/(arm=0)  0.922     0.789     1.079 0.313
## RMTL (arm=1)/(arm=0)  1.098     0.932     1.292 0.263
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            26.130    2.500 10.451 0.000    21.230    31.030
## arm                  -1.733    1.623 -1.068 0.286    -4.913     1.447
## TYPESTATUSnumeric    -3.819    1.558 -2.451 0.014    -6.874    -0.765
## HOSPITALONSETnumeric -7.114    1.651 -4.309 0.000   -10.350    -3.878
## day                  -0.914    1.612 -0.567 0.571    -4.073     2.245
## earlyacademicyear    -2.245    1.575 -1.425 0.154    -5.332     0.842
## white                 1.020    1.659  0.615 0.539    -2.231     4.271
## structuraletiology    0.326    1.919  0.170 0.865    -3.434     4.087
## priorepilepsy         0.207    1.738  0.119 0.905    -3.199     3.614
## status               -6.799    2.173 -3.128 0.002   -11.059    -2.540
## ageyears              0.100    0.157  0.638 0.524    -0.208     0.409
## SEXnumeric            0.107    1.614  0.066 0.947    -3.056     3.270
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.283    0.122 26.983 0.000    26.652    20.998
## arm                  -0.081    0.080 -1.010 0.313     0.922     0.789
## TYPESTATUSnumeric    -0.189    0.082 -2.306 0.021     0.828     0.706
## HOSPITALONSETnumeric -0.377    0.096 -3.934 0.000     0.686     0.569
## day                  -0.047    0.078 -0.597 0.550     0.954     0.818
## earlyacademicyear    -0.108    0.079 -1.366 0.172     0.898     0.770
## white                 0.048    0.083  0.583 0.560     1.049     0.892
## structuraletiology    0.019    0.094  0.201 0.840     1.019     0.847
## priorepilepsy         0.001    0.081  0.017 0.987     1.001     0.854
## status               -0.381    0.136 -2.809 0.005     0.683     0.524
## ageyears              0.005    0.007  0.634 0.526     1.005     0.990
## SEXnumeric            0.009    0.079  0.111 0.911     1.009     0.864
##                      upper .95
## intercept               33.830
## arm                      1.079
## TYPESTATUSnumeric        0.972
## HOSPITALONSETnumeric     0.828
## day                      1.113
## earlyacademicyear        1.048
## white                    1.235
## structuraletiology       1.226
## priorepilepsy            1.174
## status                   0.891
## ageyears                 1.020
## SEXnumeric               1.178
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             2.666    0.133 20.059 0.000    14.378    11.081
## arm                   0.093    0.083  1.120 0.263     1.098     0.932
## TYPESTATUSnumeric     0.196    0.077  2.550 0.011     1.217     1.046
## HOSPITALONSETnumeric  0.345    0.079  4.368 0.000     1.412     1.210
## day                   0.046    0.084  0.543 0.587     1.047     0.887
## earlyacademicyear     0.118    0.080  1.468 0.142     1.125     0.961
## white                -0.055    0.084 -0.658 0.510     0.946     0.803
## structuraletiology   -0.014    0.098 -0.146 0.884     0.986     0.813
## priorepilepsy        -0.020    0.095 -0.212 0.832     0.980     0.813
## status                0.320    0.100  3.193 0.001     1.376     1.131
## ageyears             -0.005    0.008 -0.640 0.522     0.995     0.978
## SEXnumeric           -0.003    0.083 -0.038 0.970     0.997     0.847
##                      upper .95
## intercept               18.655
## arm                      1.292
## TYPESTATUSnumeric        1.415
## HOSPITALONSETnumeric     1.649
## day                      1.235
## earlyacademicyear        1.317
## white                    1.116
## structuraletiology       1.195
## priorepilepsy            1.181
## status                   1.675
## ageyears                 1.011
## SEXnumeric               1.173
# First BZD later than 60 minutes
CrossTable(pSERG$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       266 |        62 | 
##           |     0.811 |     0.189 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       117 |        34 | 
##           |     0.775 |     0.225 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       149 |        28 | 
##           |     0.842 |     0.158 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstBZDmore60min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstBZDmore60min and pSERG$awareness
## p-value = 0.1568
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3559881 1.1699788
## sample estimates:
## odds ratio 
##  0.6475457
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG$BZDTIME.0, status=pSERG$event, arm=pSERG$awareness, tau=60,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -2.926    -7.539     1.687 0.214
## RMST (arm=1)/(arm=0)  0.897     0.745     1.079 0.249
## RMTL (arm=1)/(arm=0)  1.092     0.956     1.247 0.196
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept             34.449    3.699  9.314 0.000    27.199    41.698
## arm                   -2.926    2.354 -1.243 0.214    -7.539     1.687
## TYPESTATUSnumeric     -6.759    2.222 -3.042 0.002   -11.114    -2.405
## HOSPITALONSETnumeric  -9.712    2.351 -4.132 0.000   -14.319    -5.105
## day                   -1.580    2.373 -0.666 0.506    -6.231     3.071
## earlyacademicyear     -3.481    2.289 -1.520 0.128    -7.968     1.006
## white                  0.871    2.452  0.355 0.723    -3.936     5.677
## structuraletiology     0.748    2.769  0.270 0.787    -4.680     6.176
## priorepilepsy          1.558    2.542  0.613 0.540    -3.425     6.540
## status               -10.876    2.899 -3.752 0.000   -16.558    -5.194
## ageyears               0.145    0.227  0.636 0.525    -0.301     0.590
## SEXnumeric            -0.642    2.347 -0.274 0.784    -5.243     3.959
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.575    0.144 24.869 0.000    35.681    26.921
## arm                  -0.109    0.094 -1.153 0.249     0.897     0.745
## TYPESTATUSnumeric    -0.277    0.098 -2.835 0.005     0.758     0.625
## HOSPITALONSETnumeric -0.420    0.113 -3.734 0.000     0.657     0.527
## day                  -0.065    0.093 -0.695 0.487     0.937     0.781
## earlyacademicyear    -0.134    0.093 -1.442 0.149     0.874     0.728
## white                 0.031    0.099  0.317 0.751     1.032     0.850
## structuraletiology    0.033    0.109  0.302 0.762     1.034     0.834
## priorepilepsy         0.048    0.095  0.501 0.616     1.049     0.870
## status               -0.506    0.154 -3.280 0.001     0.603     0.446
## ageyears              0.005    0.009  0.603 0.547     1.005     0.988
## SEXnumeric           -0.020    0.093 -0.212 0.832     0.980     0.817
##                      upper .95
## intercept               47.292
## arm                      1.079
## TYPESTATUSnumeric        0.918
## HOSPITALONSETnumeric     0.819
## day                      1.125
## earlyacademicyear        1.049
## white                    1.253
## structuraletiology       1.281
## priorepilepsy            1.264
## status                   0.816
## ageyears                 1.022
## SEXnumeric               1.177
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.272    0.111 29.446 0.000    26.356    21.198
## arm                   0.088    0.068  1.294 0.196     1.092     0.956
## TYPESTATUSnumeric     0.192    0.062  3.104 0.002     1.212     1.073
## HOSPITALONSETnumeric  0.268    0.064  4.178 0.000     1.308     1.153
## day                   0.045    0.070  0.650 0.516     1.047     0.912
## earlyacademicyear     0.103    0.066  1.560 0.119     1.108     0.974
## white                -0.028    0.070 -0.394 0.694     0.973     0.847
## structuraletiology   -0.020    0.081 -0.253 0.800     0.980     0.837
## priorepilepsy        -0.053    0.078 -0.676 0.499     0.949     0.815
## status                0.294    0.078  3.763 0.000     1.342     1.151
## ageyears             -0.004    0.007 -0.655 0.512     0.996     0.982
## SEXnumeric            0.020    0.068  0.298 0.766     1.020     0.893
##                      upper .95
## intercept               32.768
## arm                      1.247
## TYPESTATUSnumeric        1.368
## HOSPITALONSETnumeric     1.483
## day                      1.200
## earlyacademicyear        1.261
## white                    1.116
## structuraletiology       1.147
## priorepilepsy            1.105
## status                   1.564
## ageyears                 1.009
## SEXnumeric               1.166
# First non-BZD ASM later than 40 minutes
CrossTable(pSERG$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        97 |       231 | 
##           |     0.296 |     0.704 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        45 |       106 | 
##           |     0.298 |     0.702 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        52 |       125 | 
##           |     0.294 |     0.706 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstASMmore40min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstASMmore40min and pSERG$awareness
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.6159083 1.6873059
## sample estimates:
## odds ratio 
##   1.020443
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG$AEDTIME.0, status=pSERG$event, arm=pSERG$awareness, tau=40,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.765    -2.625     1.096 0.421
## RMST (arm=1)/(arm=0)  0.979     0.928     1.033 0.436
## RMTL (arm=1)/(arm=0)  1.199     0.824     1.745 0.343
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            34.887    1.702 20.503 0.000    31.552    38.222
## arm                  -0.765    0.949 -0.806 0.421    -2.625     1.096
## TYPESTATUSnumeric     0.059    0.995  0.059 0.953    -1.891     2.009
## HOSPITALONSETnumeric -6.520    1.200 -5.431 0.000    -8.872    -4.167
## day                  -1.409    0.983 -1.433 0.152    -3.336     0.518
## earlyacademicyear     0.928    0.936  0.992 0.321    -0.906     2.763
## white                 1.989    1.031  1.929 0.054    -0.032     4.010
## structuraletiology   -1.491    1.165 -1.280 0.201    -3.775     0.793
## priorepilepsy         1.739    0.994  1.750 0.080    -0.209     3.687
## status               -0.730    1.188 -0.614 0.539    -3.059     1.600
## ageyears              0.161    0.099  1.630 0.103    -0.033     0.354
## SEXnumeric            1.019    1.022  0.997 0.319    -0.984     3.021
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.549    0.049 71.697 0.000    34.763    31.549
## arm                  -0.021    0.027 -0.780 0.436     0.979     0.928
## TYPESTATUSnumeric     0.003    0.028  0.102 0.919     1.003     0.949
## HOSPITALONSETnumeric -0.193    0.038 -5.057 0.000     0.825     0.765
## day                  -0.039    0.028 -1.401 0.161     0.961     0.910
## earlyacademicyear     0.026    0.027  0.972 0.331     1.026     0.974
## white                 0.057    0.030  1.885 0.059     1.058     0.998
## structuraletiology   -0.043    0.035 -1.238 0.216     0.958     0.895
## priorepilepsy         0.049    0.028  1.721 0.085     1.050     0.993
## status               -0.020    0.034 -0.587 0.557     0.980     0.918
## ageyears              0.005    0.003  1.632 0.103     1.005     0.999
## SEXnumeric            0.028    0.029  0.965 0.335     1.029     0.971
##                      upper .95
## intercept               38.304
## arm                      1.033
## TYPESTATUSnumeric        1.060
## HOSPITALONSETnumeric     0.889
## day                      1.016
## earlyacademicyear        1.082
## white                    1.123
## structuraletiology       1.025
## priorepilepsy            1.109
## status                   1.047
## ageyears                 1.010
## SEXnumeric               1.089
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             1.404    0.343  4.094 0.000     4.072     2.079
## arm                   0.181    0.192  0.947 0.343     1.199     0.824
## TYPESTATUSnumeric     0.068    0.224  0.304 0.761     1.070     0.690
## HOSPITALONSETnumeric  1.230    0.213  5.760 0.000     3.420     2.251
## day                   0.330    0.215  1.533 0.125     1.391     0.912
## earlyacademicyear    -0.202    0.194 -1.044 0.296     0.817     0.559
## white                -0.405    0.195 -2.075 0.038     0.667     0.455
## structuraletiology    0.286    0.199  1.438 0.150     1.331     0.901
## priorepilepsy        -0.444    0.249 -1.786 0.074     0.641     0.394
## status                0.225    0.278  0.809 0.418     1.252     0.727
## ageyears             -0.036    0.024 -1.515 0.130     0.964     0.920
## SEXnumeric           -0.269    0.211 -1.277 0.202     0.764     0.506
##                      upper .95
## intercept                7.976
## arm                      1.745
## TYPESTATUSnumeric        1.661
## HOSPITALONSETnumeric     5.197
## day                      2.121
## earlyacademicyear        1.194
## white                    0.978
## structuraletiology       1.965
## priorepilepsy            1.044
## status                   2.157
## ageyears                 1.011
## SEXnumeric               1.155
# First non-BZD ASM later than 60 minutes
CrossTable(pSERG$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       150 |       178 | 
##           |     0.457 |     0.543 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        70 |        81 | 
##           |     0.464 |     0.536 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        80 |        97 | 
##           |     0.452 |     0.548 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstASMmore60min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstASMmore60min and pSERG$awareness
## p-value = 0.9115
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.6618423 1.6584742
## sample estimates:
## odds ratio 
##   1.047657
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG$AEDTIME.0, status=pSERG$event, arm=pSERG$awareness, tau=60,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.616    -4.006     2.773 0.722
## RMST (arm=1)/(arm=0)  0.989     0.921     1.062 0.755
## RMTL (arm=1)/(arm=0)  1.076     0.815     1.419 0.605
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept             48.523    3.037 15.975 0.000    42.570    54.477
## arm                   -0.616    1.729 -0.356 0.722    -4.006     2.773
## TYPESTATUSnumeric     -2.347    1.831 -1.282 0.200    -5.936     1.241
## HOSPITALONSETnumeric -12.771    2.098 -6.088 0.000   -16.882    -8.659
## day                   -3.214    1.779 -1.807 0.071    -6.701     0.273
## earlyacademicyear      1.966    1.717  1.145 0.252    -1.399     5.331
## white                  2.985    1.872  1.594 0.111    -0.685     6.656
## structuraletiology    -3.222    2.079 -1.550 0.121    -7.297     0.853
## priorepilepsy          3.459    1.809  1.912 0.056    -0.087     7.006
## status                -1.559    2.119 -0.736 0.462    -5.711     2.594
## ageyears               0.308    0.174  1.771 0.077    -0.033     0.649
## SEXnumeric             2.068    1.806  1.145 0.252    -1.472     5.608
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.876    0.065 59.317 0.000    48.242    42.443
## arm                  -0.011    0.036 -0.312 0.755     0.989     0.921
## TYPESTATUSnumeric    -0.047    0.039 -1.219 0.223     0.954     0.884
## HOSPITALONSETnumeric -0.282    0.051 -5.514 0.000     0.754     0.683
## day                  -0.066    0.037 -1.781 0.075     0.936     0.870
## earlyacademicyear     0.040    0.036  1.107 0.268     1.041     0.970
## white                 0.062    0.040  1.526 0.127     1.064     0.983
## structuraletiology   -0.069    0.047 -1.473 0.141     0.934     0.852
## priorepilepsy         0.070    0.038  1.868 0.062     1.073     0.997
## status               -0.030    0.044 -0.685 0.493     0.970     0.890
## ageyears              0.006    0.004  1.770 0.077     1.006     0.999
## SEXnumeric            0.042    0.038  1.089 0.276     1.042     0.967
##                      upper .95
## intercept               54.834
## arm                      1.062
## TYPESTATUSnumeric        1.029
## HOSPITALONSETnumeric     0.834
## day                      1.007
## earlyacademicyear        1.117
## white                    1.152
## structuraletiology       1.023
## priorepilepsy            1.155
## status                   1.058
## ageyears                 1.013
## SEXnumeric               1.123
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             2.328    0.242  9.610 0.000    10.259     6.381
## arm                   0.073    0.141  0.517 0.605     1.076     0.815
## TYPESTATUSnumeric     0.230    0.151  1.524 0.127     1.259     0.936
## HOSPITALONSETnumeric  0.968    0.150  6.468 0.000     2.632     1.963
## day                   0.281    0.157  1.796 0.073     1.325     0.975
## earlyacademicyear    -0.179    0.145 -1.234 0.217     0.837     0.630
## white                -0.261    0.144 -1.822 0.068     0.770     0.581
## structuraletiology    0.255    0.146  1.741 0.082     1.290     0.968
## priorepilepsy        -0.338    0.172 -1.963 0.050     0.713     0.509
## status                0.178    0.192  0.929 0.353     1.195     0.821
## ageyears             -0.028    0.017 -1.684 0.092     0.972     0.941
## SEXnumeric           -0.209    0.150 -1.401 0.161     0.811     0.605
##                      upper .95
## intercept               16.494
## arm                      1.419
## TYPESTATUSnumeric        1.692
## HOSPITALONSETnumeric     3.529
## day                      1.801
## earlyacademicyear        1.111
## white                    1.020
## structuraletiology       1.718
## priorepilepsy            1.000
## status                   1.741
## ageyears                 1.005
## SEXnumeric               1.087
# First non-BZD ASM later than 120 minutes
CrossTable(pSERG$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       233 |        95 | 
##           |     0.710 |     0.290 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  151 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       105 |        46 | 
##           |     0.695 |     0.305 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  177 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       128 |        49 | 
##           |     0.723 |     0.277 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstASMmore120min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstASMmore120min and pSERG$awareness
## p-value = 0.6258
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.5268943 1.4511690
## sample estimates:
## odds ratio 
##  0.8741735
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG$AEDTIME.0, status=pSERG$event, arm=pSERG$awareness, tau=120,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -2.095   -10.081     5.891 0.607
## RMST (arm=1)/(arm=0)  0.977     0.875     1.091 0.681
## RMTL (arm=1)/(arm=0)  1.060     0.894     1.258 0.502
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept             83.165    6.819 12.197 0.000    69.801    96.529
## arm                   -2.095    4.074 -0.514 0.607   -10.081     5.891
## TYPESTATUSnumeric    -19.028    4.071 -4.674 0.000   -27.007   -11.049
## HOSPITALONSETnumeric -28.314    4.517 -6.269 0.000   -37.167   -19.462
## day                   -7.717    4.120 -1.873 0.061   -15.793     0.359
## earlyacademicyear      0.699    4.044  0.173 0.863    -7.227     8.625
## white                  4.828    4.281  1.128 0.259    -3.563    13.218
## structuraletiology    -8.691    4.813 -1.806 0.071   -18.124     0.742
## priorepilepsy          6.993    4.336  1.613 0.107    -1.505    15.492
## status                -6.463    5.067 -1.275 0.202   -16.394     3.469
## ageyears               0.799    0.387  2.066 0.039     0.041     1.557
## SEXnumeric             3.560    4.178  0.852 0.394    -4.628    11.748
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             4.421    0.096 46.043 0.000    83.185    68.915
## arm                  -0.023    0.056 -0.411 0.681     0.977     0.875
## TYPESTATUSnumeric    -0.273    0.062 -4.432 0.000     0.761     0.674
## HOSPITALONSETnumeric -0.423    0.076 -5.589 0.000     0.655     0.565
## day                  -0.106    0.057 -1.882 0.060     0.899     0.805
## earlyacademicyear     0.007    0.056  0.133 0.894     1.008     0.902
## white                 0.060    0.061  0.977 0.329     1.062     0.941
## structuraletiology   -0.122    0.074 -1.665 0.096     0.885     0.766
## priorepilepsy         0.090    0.058  1.549 0.121     1.095     0.976
## status               -0.080    0.072 -1.123 0.262     0.923     0.802
## ageyears              0.010    0.005  2.021 0.043     1.010     1.000
## SEXnumeric            0.046    0.058  0.801 0.423     1.048     0.935
##                      upper .95
## intercept              100.411
## arm                      1.091
## TYPESTATUSnumeric        0.859
## HOSPITALONSETnumeric     0.760
## day                      1.004
## earlyacademicyear        1.125
## white                    1.198
## structuraletiology       1.022
## priorepilepsy            1.227
## status                   1.062
## ageyears                 1.020
## SEXnumeric               1.174
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.607    0.145 24.800 0.000    36.848    27.709
## arm                   0.059    0.087  0.672 0.502     1.060     0.894
## TYPESTATUSnumeric     0.390    0.083  4.672 0.000     1.476     1.254
## HOSPITALONSETnumeric  0.561    0.089  6.313 0.000     1.753     1.472
## day                   0.164    0.092  1.787 0.074     1.178     0.984
## earlyacademicyear    -0.019    0.087 -0.217 0.829     0.981     0.827
## white                -0.119    0.087 -1.360 0.174     0.888     0.748
## structuraletiology    0.181    0.092  1.957 0.050     1.198     1.000
## priorepilepsy        -0.168    0.101 -1.664 0.096     0.846     0.694
## status                0.161    0.110  1.462 0.144     1.174     0.947
## ageyears             -0.019    0.009 -2.034 0.042     0.981     0.963
## SEXnumeric           -0.086    0.090 -0.963 0.336     0.917     0.770
##                      upper .95
## intercept               49.001
## arm                      1.258
## TYPESTATUSnumeric        1.739
## HOSPITALONSETnumeric     2.086
## day                      1.410
## earlyacademicyear        1.164
## white                    1.054
## structuraletiology       1.436
## priorepilepsy            1.030
## status                   1.457
## ageyears                 0.999
## SEXnumeric               1.094
# First CI later than 60 minutes
CrossTable(pSERG$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  152 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        17 |       135 | 
##           |     0.112 |     0.888 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  68 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         6 |        62 | 
##           |     0.088 |     0.912 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        11 |        73 | 
##           |     0.131 |     0.869 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstCImore60min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstCImore60min and pSERG$awareness
## p-value = 0.4493
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1844316 2.0313749
## sample estimates:
## odds ratio 
##  0.6440591
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0), ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0), ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0), ]$awareness, tau=60,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.595    -2.407     3.596 0.698
## RMST (arm=1)/(arm=0) 1.010     0.959     1.065 0.695
## RMTL (arm=1)/(arm=0) 0.826     0.196     3.475 0.794
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            59.007    1.973 29.900 0.000    55.139    62.874
## arm                   0.595    1.531  0.388 0.698    -2.407     3.596
## TYPESTATUSnumeric     0.056    1.614  0.034 0.972    -3.108     3.220
## HOSPITALONSETnumeric -1.228    1.737 -0.707 0.479    -4.632     2.175
## day                  -2.874    1.255 -2.290 0.022    -5.333    -0.414
## earlyacademicyear    -0.573    1.449 -0.396 0.692    -3.413     2.266
## white                 1.122    1.560  0.720 0.472    -1.935     4.180
## structuraletiology   -0.846    1.868 -0.453 0.650    -4.508     2.815
## priorepilepsy        -0.402    1.279 -0.314 0.753    -2.908     2.105
## status                2.962    1.121  2.643 0.008     0.766     5.159
## ageyears             -0.009    0.147 -0.062 0.950    -0.297     0.279
## SEXnumeric           -0.537    1.569 -0.343 0.732    -3.612     2.538
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)       z     p exp(coef) lower .95
## intercept             4.077    0.034 118.592 0.000    58.979    55.135
## arm                   0.010    0.027   0.392 0.695     1.010     0.959
## TYPESTATUSnumeric     0.001    0.028   0.027 0.978     1.001     0.947
## HOSPITALONSETnumeric -0.021    0.031  -0.701 0.483     0.979     0.922
## day                  -0.050    0.022  -2.249 0.024     0.951     0.911
## earlyacademicyear    -0.010    0.025  -0.399 0.690     0.990     0.942
## white                 0.020    0.027   0.723 0.470     1.020     0.967
## structuraletiology   -0.015    0.033  -0.444 0.657     0.985     0.923
## priorepilepsy        -0.007    0.022  -0.311 0.756     0.993     0.951
## status                0.051    0.020   2.596 0.009     1.052     1.013
## ageyears              0.000    0.003  -0.057 0.954     1.000     0.995
## SEXnumeric           -0.009    0.027  -0.345 0.730     0.991     0.939
##                      upper .95
## intercept               63.090
## arm                      1.065
## TYPESTATUSnumeric        1.057
## HOSPITALONSETnumeric     1.039
## day                      0.994
## earlyacademicyear        1.040
## white                    1.077
## structuraletiology       1.052
## priorepilepsy            1.037
## status                   1.093
## ageyears                 1.005
## SEXnumeric               1.045
## 
## 
## Model summary (ratio of time-lost) 
##                         coef se(coef)       z     p exp(coef) lower .95
## intercept             -0.444    1.087  -0.408 0.683     0.642     0.076
## arm                   -0.191    0.733  -0.261 0.794     0.826     0.196
## TYPESTATUSnumeric     -0.190    0.780  -0.244 0.807     0.827     0.179
## HOSPITALONSETnumeric   0.517    0.632   0.818 0.414     1.676     0.486
## day                    1.574    0.843   1.867 0.062     4.826     0.925
## earlyacademicyear      0.180    0.627   0.287 0.774     1.197     0.351
## white                 -0.190    0.611  -0.312 0.755     0.827     0.250
## structuraletiology     0.408    0.500   0.814 0.416     1.503     0.564
## priorepilepsy          0.197    0.563   0.349 0.727     1.217     0.403
## status               -17.676    0.504 -35.052 0.000     0.000     0.000
## ageyears               0.013    0.054   0.239 0.811     1.013     0.911
## SEXnumeric             0.135    0.668   0.202 0.840     1.145     0.309
##                      upper .95
## intercept                5.398
## arm                      3.475
## TYPESTATUSnumeric        3.816
## HOSPITALONSETnumeric     5.783
## day                     25.179
## earlyacademicyear        4.086
## white                    2.737
## structuraletiology       4.009
## priorepilepsy            3.673
## status                   0.000
## ageyears                 1.126
## SEXnumeric               4.241
# First CI later than 120 minutes
CrossTable(pSERG$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  152 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        45 |       107 | 
##           |     0.296 |     0.704 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  68 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        16 |        52 | 
##           |     0.235 |     0.765 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        29 |        55 | 
##           |     0.345 |     0.655 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstCImore120min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstCImore120min and pSERG$awareness
## p-value = 0.1562
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.2642823 1.2638205
## sample estimates:
## odds ratio 
##  0.5856217
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0), ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0), ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0), ]$awareness, tau=120,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -5.444   -14.181     3.293 0.222
## RMST (arm=1)/(arm=0)  0.950     0.874     1.032 0.221
## RMTL (arm=1)/(arm=0)  1.487     0.753     2.934 0.253
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept            113.407    6.884 16.475 0.000    99.915   126.899
## arm                   -5.444    4.458 -1.221 0.222   -14.181     3.293
## TYPESTATUSnumeric     -1.290    5.082 -0.254 0.800   -11.251     8.670
## HOSPITALONSETnumeric  -0.920    4.877 -0.189 0.850   -10.478     8.638
## day                   -7.022    4.319 -1.626 0.104   -15.486     1.442
## earlyacademicyear     -3.668    4.654 -0.788 0.431   -12.789     5.453
## white                  3.105    4.830  0.643 0.520    -6.361    12.572
## structuraletiology    -3.877    5.799 -0.669 0.504   -15.243     7.489
## priorepilepsy         -4.649    4.734 -0.982 0.326   -13.928     4.630
## status                 9.072    4.614  1.966 0.049     0.028    18.115
## ageyears               0.318    0.409  0.778 0.437    -0.484     1.121
## SEXnumeric            -1.571    4.635 -0.339 0.735   -10.656     7.513
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             4.733    0.064 73.450 0.000   113.581   100.106
## arm                  -0.052    0.042 -1.224 0.221     0.950     0.874
## TYPESTATUSnumeric    -0.012    0.049 -0.240 0.811     0.988     0.898
## HOSPITALONSETnumeric -0.009    0.046 -0.185 0.853     0.991     0.906
## day                  -0.066    0.041 -1.615 0.106     0.936     0.863
## earlyacademicyear    -0.035    0.044 -0.803 0.422     0.965     0.886
## white                 0.030    0.046  0.643 0.521     1.030     0.941
## structuraletiology   -0.037    0.056 -0.665 0.506     0.963     0.863
## priorepilepsy        -0.045    0.045 -0.984 0.325     0.956     0.875
## status                0.085    0.043  1.969 0.049     1.089     1.000
## ageyears              0.003    0.004  0.778 0.436     1.003     0.995
## SEXnumeric           -0.015    0.044 -0.343 0.732     0.985     0.905
##                      upper .95
## intercept              128.869
## arm                      1.032
## TYPESTATUSnumeric        1.087
## HOSPITALONSETnumeric     1.085
## day                      1.014
## earlyacademicyear        1.052
## white                    1.127
## structuraletiology       1.076
## priorepilepsy            1.045
## status                   1.186
## ageyears                 1.011
## SEXnumeric               1.073
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             2.050    0.541  3.790 0.000     7.767     2.691
## arm                   0.397    0.347  1.144 0.253     1.487     0.753
## TYPESTATUSnumeric     0.119    0.333  0.358 0.720     1.127     0.587
## HOSPITALONSETnumeric  0.069    0.340  0.203 0.839     1.071     0.551
## day                   0.508    0.323  1.571 0.116     1.662     0.882
## earlyacademicyear     0.228    0.336  0.680 0.496     1.257     0.651
## white                -0.214    0.338 -0.634 0.526     0.807     0.416
## structuraletiology    0.240    0.358  0.671 0.502     1.271     0.631
## priorepilepsy         0.298    0.320  0.930 0.352     1.347     0.719
## status               -0.704    0.420 -1.678 0.093     0.494     0.217
## ageyears             -0.024    0.031 -0.763 0.445     0.977     0.919
## SEXnumeric            0.106    0.345  0.306 0.759     1.111     0.565
##                      upper .95
## intercept               22.419
## arm                      2.934
## TYPESTATUSnumeric        2.164
## HOSPITALONSETnumeric     2.085
## day                      3.130
## earlyacademicyear        2.427
## white                    1.566
## structuraletiology       2.563
## priorepilepsy            2.525
## status                   1.126
## ageyears                 1.038
## SEXnumeric               2.184
# First CI later than 240 minutes
CrossTable(pSERG$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  152 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        93 |        59 | 
##           |     0.612 |     0.388 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  68 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        39 |        29 | 
##           |     0.574 |     0.426 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        54 |        30 | 
##           |     0.643 |     0.357 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstCImore240min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstCImore240min and pSERG$awareness
## p-value = 0.4067
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3683156 1.5175244
## sample estimates:
## odds ratio 
##  0.7485821
# Difference adjusting for covariates within the first 240 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0), ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0), ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0), ]$awareness, tau=240,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 240  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                         Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -12.694   -35.823    10.436 0.282
## RMST (arm=1)/(arm=0)   0.928     0.809     1.065 0.288
## RMTL (arm=1)/(arm=0)   1.202     0.864     1.671 0.275
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept            196.605   20.167  9.749 0.000   157.078   236.131
## arm                  -12.694   11.801 -1.076 0.282   -35.823    10.436
## TYPESTATUSnumeric    -22.437   13.057 -1.718 0.086   -48.028     3.154
## HOSPITALONSETnumeric  -5.896   12.593 -0.468 0.640   -30.577    18.786
## day                  -14.568   12.233 -1.191 0.234   -38.544     9.409
## earlyacademicyear     -9.542   12.416 -0.769 0.442   -33.877    14.792
## white                  5.947   13.065  0.455 0.649   -19.660    31.555
## structuraletiology    -4.624   15.201 -0.304 0.761   -34.417    25.168
## priorepilepsy         -5.716   13.797 -0.414 0.679   -32.758    21.325
## status                 4.460   14.272  0.313 0.755   -23.512    32.432
## ageyears               0.348    1.099  0.317 0.751    -1.806     2.502
## SEXnumeric            -7.172   12.097 -0.593 0.553   -30.881    16.537
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             5.291    0.118 45.000 0.000   198.538   157.674
## arm                  -0.075    0.070 -1.063 0.288     0.928     0.809
## TYPESTATUSnumeric    -0.139    0.084 -1.660 0.097     0.870     0.738
## HOSPITALONSETnumeric -0.035    0.076 -0.459 0.646     0.966     0.832
## day                  -0.085    0.072 -1.177 0.239     0.918     0.797
## earlyacademicyear    -0.056    0.074 -0.759 0.448     0.945     0.818
## white                 0.035    0.078  0.442 0.659     1.035     0.888
## structuraletiology   -0.030    0.092 -0.322 0.748     0.971     0.811
## priorepilepsy        -0.034    0.082 -0.418 0.676     0.966     0.824
## status                0.029    0.085  0.343 0.732     1.030     0.872
## ageyears              0.002    0.006  0.296 0.767     1.002     0.989
## SEXnumeric           -0.043    0.072 -0.598 0.550     0.958     0.833
##                      upper .95
## intercept              249.991
## arm                      1.065
## TYPESTATUSnumeric        1.025
## HOSPITALONSETnumeric     1.121
## day                      1.058
## earlyacademicyear        1.093
## white                    1.207
## structuraletiology       1.163
## priorepilepsy            1.134
## status                   1.216
## ageyears                 1.015
## SEXnumeric               1.103
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.857    0.299 12.920 0.000    47.315    26.357
## arm                   0.184    0.168  1.092 0.275     1.202     0.864
## TYPESTATUSnumeric     0.291    0.162  1.798 0.072     1.338     0.974
## HOSPITALONSETnumeric  0.084    0.171  0.490 0.624     1.088     0.777
## day                   0.215    0.179  1.201 0.230     1.239     0.873
## earlyacademicyear     0.137    0.174  0.789 0.430     1.147     0.816
## white                -0.088    0.181 -0.488 0.626     0.915     0.642
## structuraletiology    0.053    0.205  0.258 0.797     1.054     0.705
## priorepilepsy         0.078    0.195  0.402 0.687     1.082     0.738
## status               -0.047    0.201 -0.235 0.814     0.954     0.643
## ageyears             -0.006    0.016 -0.365 0.715     0.994     0.963
## SEXnumeric            0.099    0.172  0.579 0.563     1.105     0.789
##                      upper .95
## intercept               84.936
## arm                      1.671
## TYPESTATUSnumeric        1.837
## HOSPITALONSETnumeric     1.522
## day                      1.759
## earlyacademicyear        1.614
## white                    1.306
## structuraletiology       1.576
## priorepilepsy            1.585
## status                   1.414
## ageyears                 1.026
## SEXnumeric               1.547

Time to treatment out of the hospital

# At least one benzodiazepine before hospital arrival
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  157 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        59 |        98 | 
##           |     0.376 |     0.624 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Proportion of patients with at least one benzodiazepine before hospital arrival depending on awareness
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  81 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        40 |        41 | 
##           |     0.494 |     0.506 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  76 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        19 |        57 | 
##           |     0.250 |     0.750 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDbeforehospital, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness)
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$AEDbeforehospital and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.001809
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  1.413809 6.132627
## sample estimates:
## odds ratio 
##   2.906258
# Absolute risk reduction
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0), ]$AEDbeforehospital)$prop.row[2] - CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1), ]$AEDbeforehospital)$prop.row[2]
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  81 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        40 |        41 | 
##           |     0.494 |     0.506 | 
##           |-----------|-----------|
## 
## 
## 
##  
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  76 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        19 |        57 | 
##           |     0.250 |     0.750 | 
##           |-----------|-----------|
## 
## 
## 
## 
## [1] -0.2438272
# Number needed to treat
1 / (CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0), ]$AEDbeforehospital)$prop.row[2] - CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1), ]$AEDbeforehospital)$prop.row[2])
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  81 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        40 |        41 | 
##           |     0.494 |     0.506 | 
##           |-----------|-----------|
## 
## 
## 
##  
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  76 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        19 |        57 | 
##           |     0.250 |     0.750 | 
##           |-----------|-----------|
## 
## 
## 
## 
## [1] -4.101266
# By year
table(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$yearSE=="2011", ]$AEDbeforehospital)
## < table of extent 0 >
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$yearSE=="2012", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  33 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        18 |        15 | 
##           |     0.545 |     0.455 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$yearSE=="2013", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  23 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        12 |        11 | 
##           |     0.522 |     0.478 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$yearSE=="2014", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        10 |        15 | 
##           |     0.400 |     0.600 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$yearSE=="2015", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  11 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         2 |         9 | 
##           |     0.182 |     0.818 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$yearSE=="2016", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  34 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         9 |        25 | 
##           |     0.265 |     0.735 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$yearSE=="2017", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  13 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         2 |        11 | 
##           |     0.154 |     0.846 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$yearSE=="2018", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  10 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         5 |         5 | 
##           |     0.500 |     0.500 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$yearSE=="2019", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  8 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         1 |         7 | 
##           |     0.125 |     0.875 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Logistic regression adjusting for potential confounders
logistic_out_of_hospital_BZD <- glm(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDbeforehospital ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX, family="binomial")

cbind(exp(cbind("Odds ratio" = coef(logistic_out_of_hospital_BZD), confint(logistic_out_of_hospital_BZD, level = 0.95))), "p-value" = coef(summary(logistic_out_of_hospital_BZD))[ , 4])
## Waiting for profiling to be done...
##                                                             Odds ratio
## (Intercept)                                                  2.7185651
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               4.3452719
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.2857623
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     1.1601618
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.1101262
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.5400745
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.7278006
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           1.1424542
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  9.0351191
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                1.0292742
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.5171305
##                                                                 2.5 %
## (Intercept)                                                 0.7359824
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness              1.9590088
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent 0.1099761
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    0.5293899
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear      0.5185347
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  0.2249018
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     0.2946216
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          0.5322064
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 2.5239374
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               0.9585850
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                0.2315641
##                                                                 97.5 %
## (Intercept)                                                 10.8009006
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness              10.3000467
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.6892508
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     2.5594053
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       2.3789177
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   1.2438644
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      1.7903300
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           2.4626295
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 45.3025920
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                1.1084247
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.1148369
##                                                                 p-value
## (Intercept)                                                 0.141589849
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness              0.000482221
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent 0.007050196
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    0.710347135
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear      0.787108224
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  0.155615525
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     0.487176056
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          0.732117993
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 0.002226171
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               0.432496538
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                0.098247513
# At least one benzodiazepine before hospital arrival among those with prior epilepsy
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  85 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        29 |        56 | 
##           |     0.341 |     0.659 | 
##           |-----------|-----------|
## 
## 
## 
## 
# At least one benzodiazepine before hospital arrival among those with prior epilepsy depending on awareness
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$awareness == 0), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  43 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        20 |        23 | 
##           |     0.465 |     0.535 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$awareness == 1), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  42 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         9 |        33 | 
##           |     0.214 |     0.786 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$AEDbeforehospital, pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$awareness)
## 
##  Fisher's Exact Test for Count Data
## 
## data:  
## p-value = 0.02174
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  1.127161 9.360579
## sample estimates:
## odds ratio 
##   3.143665
# Absolute risk reduction
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$awareness == 0), ]$AEDbeforehospital)$prop.row[2] - CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$awareness == 1), ]$AEDbeforehospital)$prop.row[2]
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  43 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        20 |        23 | 
##           |     0.465 |     0.535 | 
##           |-----------|-----------|
## 
## 
## 
##  
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  42 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         9 |        33 | 
##           |     0.214 |     0.786 | 
##           |-----------|-----------|
## 
## 
## 
## 
## [1] -0.2508306
# Number needed to treat
1 / (CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$awareness == 0), ]$AEDbeforehospital)$prop.row[2] - CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$awareness == 1), ]$AEDbeforehospital)$prop.row[2])
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  43 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        20 |        23 | 
##           |     0.465 |     0.535 | 
##           |-----------|-----------|
## 
## 
## 
##  
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  42 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         9 |        33 | 
##           |     0.214 |     0.786 | 
##           |-----------|-----------|
## 
## 
## 
## 
## [1] -3.986755
# By year
table(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$yearSE=="2011", ]$AEDbeforehospital)
## < table of extent 0 >
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$yearSE=="2012", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  19 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        12 |         7 | 
##           |     0.632 |     0.368 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$yearSE=="2013", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  10 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         3 |         7 | 
##           |     0.300 |     0.700 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$yearSE=="2014", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  14 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         5 |         9 | 
##           |     0.357 |     0.643 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$yearSE=="2015", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  7 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         1 |         6 | 
##           |     0.143 |     0.857 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$yearSE=="2016", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  17 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         7 |        10 | 
##           |     0.412 |     0.588 | 
##           |-----------|-----------|
## 
## 
## 
## 
table(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$yearSE=="2017", ]$AEDbeforehospital)
## 
## 1 
## 9
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$yearSE=="2018", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  4 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         1 |         3 | 
##           |     0.250 |     0.750 | 
##           |-----------|-----------|
## 
## 
## 
## 
table(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$yearSE=="2019", ]$AEDbeforehospital)
## 
## 1 
## 5
# Logistic regression adjusting for potential confounders among those with prior epilepsy
logistic_out_of_hospital_BZD_prior_epilepsy <- glm(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$AEDbeforehospital ~ pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$awareness + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$day + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$white +
                pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$structuraletiology + 
                pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$status + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$SEX, family="binomial")

cbind(exp(cbind("Odds ratio" = coef(logistic_out_of_hospital_BZD_prior_epilepsy), confint(logistic_out_of_hospital_BZD_prior_epilepsy, level = 0.95))), "p-value" = coef(summary(logistic_out_of_hospital_BZD_prior_epilepsy))[ , 4])
## Waiting for profiling to be done...
##                                                                                        Odds ratio
## (Intercept)                                                                             1.3359758
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness               3.9696983
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent  0.4414770
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                     1.7217193
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear       0.7114983
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                   0.5448214
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology      1.1357661
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                 10.1632513
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears                1.0726123
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                 0.6937318
##                                                                                            2.5 %
## (Intercept)                                                                            0.1835707
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness              1.2819824
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent 0.1110689
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                    0.5777862
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear      0.2243768
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                  0.1545398
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology     0.3176501
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                 2.1435310
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears               0.9580311
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                0.2223616
##                                                                                           97.5 %
## (Intercept)                                                                            10.695066
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness              13.986966
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent  1.554206
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                     5.297892
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear       2.210763
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                   1.763946
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology      4.245993
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                 79.492673
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears                1.213215
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                 2.072260
##                                                                                            p-value
## (Intercept)                                                                            0.777123655
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness              0.022041943
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent 0.217326455
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                    0.331929707
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear      0.555858376
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                  0.321953266
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology     0.845473896
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                 0.009179252
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears               0.238047384
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                0.516393858
## Correction for multiple comparisons
atleastoneBZD <- c(fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDbeforehospital, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness)$p.value,
                   
cbind(exp(cbind("Odds ratio" = coef(logistic_out_of_hospital_BZD), confint(logistic_out_of_hospital_BZD, level = 0.95))), "p-value" = coef(summary(logistic_out_of_hospital_BZD))[ , 4])[2,4],

fisher.test(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$AEDbeforehospital, pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$awareness)$p.value,

cbind(exp(cbind("Odds ratio" = coef(logistic_out_of_hospital_BZD_prior_epilepsy), confint(logistic_out_of_hospital_BZD_prior_epilepsy, level = 0.95))), "p-value" = coef(summary(logistic_out_of_hospital_BZD_prior_epilepsy))[ , 4])[2,4]
                     )
## Waiting for profiling to be done...
## Waiting for profiling to be done...
p.adjust(atleastoneBZD, "BH") 
## [1] 0.003617363 0.001928884 0.022041943 0.022041943
# Patients in each category
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$awareness)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  222 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       105 |       117 | 
##           |     0.473 |     0.527 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Time to first BZD
summary(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    7.00   20.00   68.93   55.00 1264.00
sd(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0)
## [1] 153.5504
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$BZDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##     222     222      20      20      30
# Figure time to first BZD
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")

# Time to first BZD depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0     7.0    25.0    63.1    60.0   720.0
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    7.00   20.00   74.15   50.00 1264.00
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness, rho = 1)
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0 105     52.8     57.6
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1 117     63.5     58.7
##                                                  (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0     0.406      1.27
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1     0.399      1.27
## 
##  Chisq= 1.3  on 1 degrees of freedom, p= 0.3
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.2606017
# Figure time to first BZD by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first BZD
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "no", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$status + pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$SEX)
## 
##   n= 222, number of events= 222 
## 
##                                                                   coef
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.0572927
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -0.4315180
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.0620423
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.1334490
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.1075034
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.1740010
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.0577160
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.6101583
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               -0.0008181
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.1517755
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               1.0589657
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.6495224
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     1.0640073
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.1427630
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   1.1134946
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      1.1900568
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           1.0594141
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  1.8407228
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.9991823
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.1638990
##                                                               se(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.1402286
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.1567867
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.1416562
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.1384930
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.1510865
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.1743550
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.1489168
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.1940220
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.0143055
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.1423701
##                                                                  z
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.409
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -2.752
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.438
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.964
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.712
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.998
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.388
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  3.145
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               -0.057
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.066
##                                                             Pr(>|z|)   
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.68286   
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.00592 **
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.66140   
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.33526   
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.47675   
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.31829   
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.69833   
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.00166 **
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.95440   
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.28639   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 1.0590
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.6495
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.0640
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.1428
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     1.1135
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.1901
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.0594
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.8407
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9992
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.1639
##                                                             exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                  0.9443
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     1.5396
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        0.9398
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          0.8751
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      0.8981
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         0.8403
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              0.9439
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     0.5433
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   1.0008
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    0.8592
##                                                             lower .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 0.8045
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.4777
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.8061
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.8711
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.8281
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.8456
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.7912
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.2585
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9716
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.8805
##                                                             upper .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 1.3939
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.8832
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.4045
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.4991
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     1.4972
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.6749
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.4185
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    2.6924
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  1.0276
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.5385
## 
## Concordance= 0.6  (se = 0.025 )
## Rsquare= 0.102   (max possible= 1 )
## Likelihood ratio test= 23.94  on 10 df,   p=0.008
## Wald test            = 25.59  on 10 df,   p=0.004
## Score (logrank) test = 26.56  on 10 df,   p=0.003
# Time to first non-BZD AED
summary(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    45.5    81.0   192.7   170.0  4320.0
sd(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0)
## [1] 375.2449
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$AEDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##     222     222      81      70     103
# Figure time to first non-BZD AED
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")

# Time to first non-BZD AED depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    10.0    45.0    82.0   189.3   190.0  1800.0
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    55.0    80.0   195.8   153.0  4320.0
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness, rho = 1)
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0 105     53.0     53.3
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1 117     59.4     59.1
##                                                  (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0   0.00171   0.00492
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1   0.00154   0.00492
## 
##  Chisq= 0  on 1 degrees of freedom, p= 0.9
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.9441036
# Figure time to first non-BZD AED by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first non-BZD AED
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "no", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$status + pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$SEX)
## 
##   n= 222, number of events= 222 
## 
##                                                                  coef
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.021747
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -0.760795
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.149188
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.055396
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -0.090119
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     -0.003863
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          -0.130302
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.111409
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               -0.021653
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.240906
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               1.021985
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.467295
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     1.160891
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.056959
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.913822
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.996144
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.877830
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  1.117852
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.978580
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.272401
##                                                              se(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.140321
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.154158
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.145294
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.139822
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.146181
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.171752
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.152081
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.194062
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.013936
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.148227
##                                                                  z
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.155
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -4.935
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     1.027
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.396
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -0.616
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     -0.022
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          -0.857
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.574
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               -1.554
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.625
##                                                             Pr(>|z|)    
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 0.877    
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent 8.01e-07 ***
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.305    
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.692    
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.538    
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.982    
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.392    
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.566    
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.120    
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.104    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 1.0220
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.4673
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.1609
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.0570
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.9138
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.9961
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.8778
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.1179
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9786
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.2724
##                                                             exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                  0.9785
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     2.1400
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        0.8614
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          0.9461
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      1.0943
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         1.0039
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              1.1392
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     0.8946
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   1.0219
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    0.7859
##                                                             lower .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 0.7763
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.3454
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.8732
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.8036
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.6862
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.7114
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.6516
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.7642
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9522
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.9516
##                                                             upper .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 1.3455
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.6321
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.5434
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.3902
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     1.2170
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.3948
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.1827
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.6352
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  1.0057
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.7014
## 
## Concordance= 0.621  (se = 0.023 )
## Rsquare= 0.153   (max possible= 1 )
## Likelihood ratio test= 36.81  on 10 df,   p=6e-05
## Wald test            = 37.37  on 10 df,   p=5e-05
## Score (logrank) test = 39.04  on 10 df,   p=3e-05
# Time to first CI
summary(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    15.0   118.0   172.0   506.4   626.0  4320.0     121
sd(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0)
## [1] NA
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$CONTTIME.0) ~ 
##     1)
## 
##    121 observations deleted due to missingness 
##       n  events  median 0.95LCL 0.95UCL 
##     101     101     172     150     295
# Figure time to first CI
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")

# Time to first CI depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    20.0   137.0   180.0   575.8   660.0  4320.0      60
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    15.0    86.5   166.0   450.6   586.5  3008.0      61
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness, rho = 1)
## 
## n=101, 121 observations deleted due to missingness.
## 
##                                                   N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0 45     21.3     24.2
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1 56     29.8     26.9
##                                                  (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0     0.352         1
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1     0.317         1
## 
##  Chisq= 1  on 1 degrees of freedom, p= 0.3
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.3164683
# Figure time to first CI by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first CI
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS + 
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "no", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$status + pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$SEX)
## 
##   n= 101, number of events= 101 
##    (121 observations deleted due to missingness)
## 
##                                                                  coef
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.242082
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -0.158051
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    -0.155402
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.355585
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -0.401119
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.429897
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.220390
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 -0.024234
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.002679
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.182839
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               1.273899
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.853806
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.856071
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.427015
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.669570
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      1.537099
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           1.246563
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.976057
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                1.002682
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.200621
##                                                              se(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.223437
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.243565
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.220719
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.232539
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.263308
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.283451
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.252103
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.278004
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.021505
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.238978
##                                                                  z
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               1.083
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -0.649
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    -0.704
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.529
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -1.523
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      1.517
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.874
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 -0.087
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.125
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.765
##                                                             Pr(>|z|)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 0.279
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.516
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.481
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.126
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.128
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.129
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.382
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.931
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.901
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.444
## 
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 1.2739
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.8538
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.8561
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.4270
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.6696
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.5371
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.2466
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.9761
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  1.0027
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.2006
##                                                             exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                  0.7850
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     1.1712
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        1.1681
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          0.7008
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      1.4935
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         0.6506
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              0.8022
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     1.0245
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   0.9973
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    0.8329
##                                                             lower .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 0.8221
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.5297
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.5554
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.9047
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.3996
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.8819
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.7605
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.5660
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9613
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.7516
##                                                             upper .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                  1.974
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     1.376
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        1.319
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          2.251
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      1.122
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         2.679
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              2.043
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     1.683
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   1.046
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    1.918
## 
## Concordance= 0.574  (se = 0.034 )
## Rsquare= 0.083   (max possible= 0.999 )
## Likelihood ratio test= 8.8  on 10 df,   p=0.6
## Wald test            = 8.99  on 10 df,   p=0.5
## Score (logrank) test = 8.97  on 10 df,   p=0.5
#### Recommendations and outliers out of the hospital

# First BZD later than 20 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  222 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       115 |       107 | 
##           |     0.518 |     0.482 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  105 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        50 |        55 | 
##           |     0.476 |     0.524 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  117 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        65 |        52 | 
##           |     0.556 |     0.444 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore20min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstBZDmore20min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.2821
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4140914 1.2767604
## sample estimates:
## odds ratio 
##  0.7283348
# Difference adjusting for covariates within the first 20 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, tau=20,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 20  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.558    -2.333     1.216 0.537
## RMST (arm=1)/(arm=0)  0.961     0.849     1.087 0.528
## RMTL (arm=1)/(arm=0)  1.102     0.791     1.536 0.566
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          18.160    1.554 11.683 0.000    15.114    21.207
## arm                -0.558    0.905 -0.617 0.537    -2.333     1.216
## TYPESTATUSnumeric  -0.069    0.924 -0.074 0.941    -1.879     1.742
## day                -0.777    0.899 -0.864 0.388    -2.540     0.986
## earlyacademicyear  -0.443    0.891 -0.497 0.619    -2.189     1.303
## white              -0.585    0.935 -0.626 0.531    -2.418     1.248
## structuraletiology -0.996    1.091 -0.913 0.361    -3.134     1.142
## priorepilepsy      -2.230    0.936 -2.384 0.017    -4.064    -0.396
## status             -4.772    1.380 -3.459 0.001    -7.475    -2.068
## ageyears           -0.034    0.093 -0.364 0.716    -0.216     0.149
## SEXnumeric          0.098    0.922  0.106 0.915    -1.709     1.905
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.920    0.104 28.127 0.000    18.546    15.132
## arm                -0.040    0.063 -0.631 0.528     0.961     0.849
## TYPESTATUSnumeric  -0.006    0.064 -0.092 0.927     0.994     0.878
## day                -0.056    0.062 -0.894 0.371     0.946     0.837
## earlyacademicyear  -0.030    0.061 -0.482 0.630     0.971     0.861
## white              -0.039    0.064 -0.601 0.548     0.962     0.849
## structuraletiology -0.068    0.077 -0.887 0.375     0.934     0.804
## priorepilepsy      -0.152    0.066 -2.319 0.020     0.859     0.755
## status             -0.387    0.128 -3.012 0.003     0.679     0.528
## ageyears           -0.003    0.006 -0.397 0.691     0.997     0.985
## SEXnumeric          0.009    0.064  0.133 0.894     1.009     0.889
##                    upper .95
## intercept             22.732
## arm                    1.087
## TYPESTATUSnumeric      1.126
## day                    1.069
## earlyacademicyear      1.095
## white                  1.091
## structuraletiology     1.086
## priorepilepsy          0.977
## status                 0.874
## ageyears               1.010
## SEXnumeric             1.144
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           0.974    0.328  2.967 0.003     2.649     1.392
## arm                 0.097    0.169  0.575 0.566     1.102     0.791
## TYPESTATUSnumeric   0.007    0.171  0.038 0.969     1.007     0.720
## day                 0.132    0.167  0.791 0.429     1.141     0.823
## earlyacademicyear   0.088    0.167  0.529 0.597     1.092     0.788
## white               0.117    0.176  0.664 0.507     1.124     0.796
## structuraletiology  0.186    0.192  0.970 0.332     1.204     0.827
## priorepilepsy       0.437    0.184  2.377 0.017     1.549     1.080
## status              0.666    0.178  3.737 0.000     1.947     1.373
## ageyears            0.005    0.017  0.272 0.785     1.005     0.972
## SEXnumeric         -0.006    0.170 -0.033 0.973     0.994     0.712
##                    upper .95
## intercept              5.041
## arm                    1.536
## TYPESTATUSnumeric      1.408
## day                    1.581
## earlyacademicyear      1.514
## white                  1.589
## structuraletiology     1.753
## priorepilepsy          2.222
## status                 2.762
## ageyears               1.039
## SEXnumeric             1.388
# First BZD later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  222 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       151 |        71 | 
##           |     0.680 |     0.320 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  105 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        68 |        37 | 
##           |     0.648 |     0.352 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  117 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        83 |        34 | 
##           |     0.709 |     0.291 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore40min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstBZDmore40min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.3874
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4111257 1.3780614
## sample estimates:
## odds ratio 
##  0.7538266
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -1.931    -5.837     1.974 0.332
## RMST (arm=1)/(arm=0)  0.917     0.770     1.092 0.332
## RMTL (arm=1)/(arm=0)  1.118     0.891     1.402 0.335
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          28.476    3.150  9.040 0.000    22.302    34.649
## arm                -1.931    1.993 -0.969 0.332    -5.837     1.974
## TYPESTATUSnumeric  -3.187    1.951 -1.634 0.102    -7.011     0.636
## day                -1.070    1.970 -0.543 0.587    -4.932     2.791
## earlyacademicyear  -1.331    1.926 -0.691 0.489    -5.106     2.444
## white               0.317    2.040  0.156 0.876    -3.680     4.315
## structuraletiology  0.203    2.394  0.085 0.933    -4.490     4.895
## priorepilepsy      -1.480    2.021 -0.732 0.464    -5.442     2.481
## status             -8.965    2.745 -3.266 0.001   -14.344    -3.586
## ageyears           -0.070    0.192 -0.365 0.715    -0.447     0.307
## SEXnumeric         -0.144    2.007 -0.072 0.943    -4.078     3.789
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.367    0.135 24.983 0.000    29.004    22.270
## arm                -0.086    0.089 -0.970 0.332     0.917     0.770
## TYPESTATUSnumeric  -0.145    0.090 -1.614 0.107     0.865     0.726
## day                -0.050    0.087 -0.579 0.562     0.951     0.802
## earlyacademicyear  -0.055    0.085 -0.641 0.521     0.947     0.801
## white               0.018    0.091  0.200 0.841     1.018     0.852
## structuraletiology  0.012    0.104  0.120 0.905     1.012     0.826
## priorepilepsy      -0.069    0.088 -0.778 0.437     0.934     0.785
## status             -0.485    0.173 -2.798 0.005     0.616     0.438
## ageyears           -0.003    0.008 -0.377 0.706     0.997     0.980
## SEXnumeric          0.000    0.089 -0.002 0.998     1.000     0.840
##                    upper .95
## intercept             37.774
## arm                    1.092
## TYPESTATUSnumeric      1.032
## day                    1.127
## earlyacademicyear      1.119
## white                  1.218
## structuraletiology     1.240
## priorepilepsy          1.110
## status                 0.865
## ageyears               1.014
## SEXnumeric             1.191
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.499    0.195 12.813 0.000    12.167     8.302
## arm                 0.111    0.116  0.965 0.335     1.118     0.891
## TYPESTATUSnumeric   0.180    0.110  1.630 0.103     1.197     0.964
## day                 0.058    0.116  0.502 0.616     1.060     0.845
## earlyacademicyear   0.083    0.112  0.743 0.457     1.087     0.873
## white              -0.012    0.116 -0.104 0.917     0.988     0.786
## structuraletiology -0.007    0.142 -0.046 0.963     0.993     0.752
## priorepilepsy       0.081    0.120  0.676 0.499     1.085     0.857
## status              0.434    0.127  3.407 0.001     1.544     1.202
## ageyears            0.004    0.011  0.342 0.733     1.004     0.982
## SEXnumeric          0.018    0.117  0.150 0.881     1.018     0.809
##                    upper .95
## intercept             17.831
## arm                    1.402
## TYPESTATUSnumeric      1.487
## day                    1.329
## earlyacademicyear      1.353
## white                  1.241
## structuraletiology     1.313
## priorepilepsy          1.373
## status                 1.982
## ageyears               1.026
## SEXnumeric             1.280
# First BZD later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  222 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       175 |        47 | 
##           |     0.788 |     0.212 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  105 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        79 |        26 | 
##           |     0.752 |     0.248 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  117 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        96 |        21 | 
##           |     0.821 |     0.179 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore60min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstBZDmore60min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.2505
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3289345 1.3348546
## sample estimates:
## odds ratio 
##  0.6659073
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -2.822    -8.588     2.945 0.338
## RMST (arm=1)/(arm=0)  0.905     0.735     1.114 0.344
## RMTL (arm=1)/(arm=0)  1.094     0.912     1.312 0.333
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept           36.710    4.676  7.850 0.000    27.545    45.876
## arm                 -2.822    2.942 -0.959 0.338    -8.588     2.945
## TYPESTATUSnumeric   -6.183    2.845 -2.174 0.030   -11.759    -0.608
## day                 -1.991    2.944 -0.676 0.499    -7.762     3.779
## earlyacademicyear   -2.187    2.861 -0.764 0.445    -7.794     3.421
## white                0.047    3.038  0.016 0.988    -5.907     6.002
## structuraletiology   0.723    3.534  0.204 0.838    -6.204     7.649
## priorepilepsy        0.639    3.001  0.213 0.831    -5.242     6.520
## status             -13.660    3.673 -3.720 0.000   -20.858    -6.462
## ageyears            -0.078    0.279 -0.280 0.780    -0.625     0.469
## SEXnumeric          -0.920    2.972 -0.310 0.757    -6.745     4.905
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.624    0.160 22.624 0.000    37.486    27.386
## arm                -0.100    0.106 -0.946 0.344     0.905     0.735
## TYPESTATUSnumeric  -0.228    0.108 -2.107 0.035     0.796     0.644
## day                -0.072    0.104 -0.695 0.487     0.931     0.759
## earlyacademicyear  -0.071    0.102 -0.693 0.488     0.932     0.763
## white               0.007    0.110  0.063 0.949     1.007     0.812
## structuraletiology  0.030    0.121  0.249 0.804     1.031     0.812
## priorepilepsy       0.015    0.104  0.148 0.882     1.016     0.829
## status             -0.610    0.196 -3.104 0.002     0.543     0.370
## ageyears           -0.003    0.010 -0.300 0.764     0.997     0.978
## SEXnumeric         -0.023    0.105 -0.218 0.828     0.977     0.795
##                    upper .95
## intercept             51.312
## arm                    1.114
## TYPESTATUSnumeric      0.984
## day                    1.140
## earlyacademicyear      1.138
## white                  1.249
## structuraletiology     1.308
## priorepilepsy          1.245
## status                 0.799
## ageyears               1.016
## SEXnumeric             1.202
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.177    0.156 20.364 0.000    23.967    17.654
## arm                 0.090    0.093  0.967 0.333     1.094     0.912
## TYPESTATUSnumeric   0.191    0.088  2.174 0.030     1.211     1.019
## day                 0.063    0.095  0.662 0.508     1.065     0.884
## earlyacademicyear   0.074    0.090  0.817 0.414     1.077     0.902
## white               0.002    0.095  0.019 0.985     1.002     0.832
## structuraletiology -0.020    0.115 -0.173 0.863     0.980     0.782
## priorepilepsy      -0.025    0.097 -0.259 0.795     0.975     0.806
## status              0.378    0.100  3.798 0.000     1.460     1.201
## ageyears            0.002    0.009  0.255 0.799     1.002     0.985
## SEXnumeric          0.036    0.095  0.378 0.705     1.037     0.861
##                    upper .95
## intercept             32.539
## arm                    1.312
## TYPESTATUSnumeric      1.438
## day                    1.281
## earlyacademicyear      1.285
## white                  1.207
## structuraletiology     1.228
## priorepilepsy          1.180
## status                 1.775
## ageyears               1.020
## SEXnumeric             1.248
# First non-BZD ASM later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  222 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        44 |       178 | 
##           |     0.198 |     0.802 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  105 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        23 |        82 | 
##           |     0.219 |     0.781 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  117 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        21 |        96 | 
##           |     0.179 |     0.821 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore40min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstASMmore40min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.5025
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.6273175 2.6272827
## sample estimates:
## odds ratio 
##    1.28078
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.249    -2.139     1.642 0.797
## RMST (arm=1)/(arm=0)  0.994     0.944     1.045 0.803
## RMTL (arm=1)/(arm=0)  1.120     0.561     2.236 0.747
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          34.841    1.848 18.850 0.000    31.219    38.464
## arm                -0.249    0.965 -0.258 0.797    -2.139     1.642
## TYPESTATUSnumeric  -1.285    0.937 -1.371 0.170    -3.122     0.552
## day                -0.404    0.983 -0.410 0.681    -2.331     1.524
## earlyacademicyear   1.235    0.911  1.356 0.175    -0.550     3.021
## white               1.104    1.045  1.056 0.291    -0.944     3.152
## structuraletiology -0.203    1.300 -0.156 0.876    -2.751     2.345
## priorepilepsy       1.922    1.035  1.856 0.063    -0.108     3.951
## status              0.943    1.033  0.913 0.361    -1.081     2.968
## ageyears            0.023    0.101  0.223 0.823    -0.176     0.221
## SEXnumeric          1.312    1.046  1.253 0.210    -0.740     3.363
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.552    0.051 69.850 0.000    34.879    31.570
## arm                -0.006    0.026 -0.250 0.803     0.994     0.944
## TYPESTATUSnumeric  -0.035    0.026 -1.356 0.175     0.966     0.919
## day                -0.011    0.026 -0.412 0.680     0.989     0.939
## earlyacademicyear   0.033    0.025  1.342 0.180     1.034     0.985
## white               0.030    0.028  1.048 0.294     1.030     0.974
## structuraletiology -0.005    0.035 -0.151 0.880     0.995     0.928
## priorepilepsy       0.052    0.028  1.846 0.065     1.053     0.997
## status              0.025    0.027  0.906 0.365     1.025     0.972
## ageyears            0.001    0.003  0.228 0.820     1.001     0.995
## SEXnumeric          0.035    0.028  1.235 0.217     1.036     0.980
##                    upper .95
## intercept             38.534
## arm                    1.045
## TYPESTATUSnumeric      1.016
## day                    1.042
## earlyacademicyear      1.085
## white                  1.089
## structuraletiology     1.066
## priorepilepsy          1.112
## status                 1.081
## ageyears               1.006
## SEXnumeric             1.095
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           1.731    0.531  3.259 0.001     5.648     1.994
## arm                 0.114    0.353  0.322 0.747     1.120     0.561
## TYPESTATUSnumeric   0.459    0.328  1.400 0.161     1.583     0.832
## day                 0.142    0.375  0.380 0.704     1.153     0.553
## earlyacademicyear  -0.514    0.359 -1.431 0.152     0.598     0.296
## white              -0.382    0.346 -1.102 0.270     0.683     0.346
## structuraletiology  0.083    0.409  0.202 0.840     1.086     0.487
## priorepilepsy      -0.735    0.437 -1.682 0.093     0.480     0.204
## status             -0.486    0.565 -0.859 0.390     0.615     0.203
## ageyears           -0.006    0.041 -0.155 0.877     0.994     0.918
## SEXnumeric         -0.527    0.366 -1.438 0.150     0.590     0.288
##                    upper .95
## intercept             15.998
## arm                    2.236
## TYPESTATUSnumeric      3.010
## day                    2.404
## earlyacademicyear      1.209
## white                  1.346
## structuraletiology     2.420
## priorepilepsy          1.129
## status                 1.863
## ageyears               1.076
## SEXnumeric             1.211
# First non-BZD ASM later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  222 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        80 |       142 | 
##           |     0.360 |     0.640 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  105 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        40 |        65 | 
##           |     0.381 |     0.619 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  117 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        40 |        77 | 
##           |     0.342 |     0.658 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore60min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstASMmore60min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.5773
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.6593377 2.1274157
## sample estimates:
## odds ratio 
##   1.183705
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.901    -2.692     4.493 0.623
## RMST (arm=1)/(arm=0) 1.018     0.950     1.091 0.618
## RMTL (arm=1)/(arm=0) 0.901     0.576     1.408 0.647
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          47.246    3.408 13.863 0.000    40.566    53.926
## arm                 0.901    1.833  0.491 0.623    -2.692     4.493
## TYPESTATUSnumeric  -4.472    1.891 -2.365 0.018    -8.179    -0.766
## day                -1.233    1.868 -0.660 0.509    -4.894     2.428
## earlyacademicyear   2.059    1.802  1.142 0.253    -1.473     5.591
## white               1.710    2.009  0.851 0.395    -2.227     5.648
## structuraletiology -0.394    2.453 -0.161 0.872    -5.201     4.414
## priorepilepsy       4.785    1.941  2.466 0.014     0.981     8.588
## status              1.735    2.045  0.848 0.396    -2.273     5.742
## ageyears            0.110    0.187  0.588 0.557    -0.257     0.478
## SEXnumeric          2.158    1.934  1.116 0.265    -1.632     5.948
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.856    0.068 56.645 0.000    47.296    41.388
## arm                 0.018    0.035  0.498 0.618     1.018     0.950
## TYPESTATUSnumeric  -0.087    0.038 -2.304 0.021     0.917     0.851
## day                -0.024    0.036 -0.668 0.504     0.976     0.910
## earlyacademicyear   0.040    0.035  1.139 0.255     1.040     0.972
## white               0.033    0.040  0.844 0.399     1.034     0.957
## structuraletiology -0.007    0.048 -0.143 0.887     0.993     0.904
## priorepilepsy       0.092    0.038  2.446 0.014     1.097     1.019
## status              0.033    0.038  0.848 0.396     1.033     0.958
## ageyears            0.002    0.004  0.598 0.550     1.002     0.995
## SEXnumeric          0.041    0.038  1.095 0.274     1.042     0.968
##                    upper .95
## intercept             54.047
## arm                    1.091
## TYPESTATUSnumeric      0.987
## day                    1.048
## earlyacademicyear      1.114
## white                  1.117
## structuraletiology     1.091
## priorepilepsy          1.181
## status                 1.114
## ageyears               1.009
## SEXnumeric             1.122
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.557    0.364  7.031 0.000    12.902     6.325
## arm                -0.105    0.228 -0.459 0.647     0.901     0.576
## TYPESTATUSnumeric   0.532    0.216  2.467 0.014     1.703     1.116
## day                 0.144    0.241  0.600 0.549     1.155     0.721
## earlyacademicyear  -0.264    0.239 -1.108 0.268     0.768     0.481
## white              -0.202    0.229 -0.881 0.378     0.817     0.522
## structuraletiology  0.072    0.274  0.262 0.793     1.074     0.628
## priorepilepsy      -0.616    0.271 -2.270 0.023     0.540     0.317
## status             -0.245    0.329 -0.746 0.456     0.782     0.411
## ageyears           -0.014    0.027 -0.500 0.617     0.987     0.936
## SEXnumeric         -0.287    0.235 -1.220 0.222     0.751     0.474
##                    upper .95
## intercept             26.317
## arm                    1.408
## TYPESTATUSnumeric      2.599
## day                    1.853
## earlyacademicyear      1.226
## white                  1.280
## structuraletiology     1.836
## priorepilepsy          0.919
## status                 1.491
## ageyears               1.040
## SEXnumeric             1.190
# First non-BZD ASM later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  222 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       144 |        78 | 
##           |     0.649 |     0.351 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  105 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        66 |        39 | 
##           |     0.629 |     0.371 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  117 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        78 |        39 | 
##           |     0.667 |     0.333 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore120min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstASMmore120min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.5757
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4695163 1.5256575
## sample estimates:
## odds ratio 
##  0.8467956
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, tau=120,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.271    -9.282     9.823 0.956
## RMST (arm=1)/(arm=0) 1.003     0.891     1.129 0.963
## RMTL (arm=1)/(arm=0) 0.991     0.774     1.268 0.941
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept           82.357    8.027 10.260 0.000    66.624    98.091
## arm                  0.271    4.874  0.055 0.956    -9.282     9.823
## TYPESTATUSnumeric  -23.433    4.896 -4.786 0.000   -33.030   -13.837
## day                 -4.770    4.778 -0.998 0.318   -14.134     4.594
## earlyacademicyear    1.120    4.802  0.233 0.816    -8.292    10.533
## white                2.790    5.184  0.538 0.590    -7.370    12.950
## structuraletiology  -3.895    6.295 -0.619 0.536   -16.233     8.443
## priorepilepsy        9.638    4.981  1.935 0.053    -0.123    19.400
## status              -1.904    5.915 -0.322 0.748   -13.498     9.690
## ageyears             0.468    0.459  1.020 0.308    -0.432     1.368
## SEXnumeric           2.109    4.999  0.422 0.673    -7.689    11.907
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.401    0.101 43.587 0.000    81.501    66.869
## arm                 0.003    0.060  0.047 0.963     1.003     0.891
## TYPESTATUSnumeric  -0.305    0.068 -4.506 0.000     0.737     0.645
## day                -0.057    0.059 -0.977 0.329     0.944     0.842
## earlyacademicyear   0.017    0.059  0.286 0.775     1.017     0.906
## white               0.034    0.066  0.519 0.604     1.035     0.909
## structuraletiology -0.046    0.081 -0.572 0.567     0.955     0.815
## priorepilepsy       0.118    0.062  1.914 0.056     1.125     0.997
## status             -0.020    0.073 -0.277 0.782     0.980     0.849
## ageyears            0.005    0.005  1.025 0.305     1.006     0.995
## SEXnumeric          0.027    0.062  0.435 0.663     1.027     0.910
##                    upper .95
## intercept             99.335
## arm                    1.129
## TYPESTATUSnumeric      0.842
## day                    1.059
## earlyacademicyear      1.142
## white                  1.178
## structuraletiology     1.119
## priorepilepsy          1.269
## status                 1.131
## ageyears               1.016
## SEXnumeric             1.159
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.577    0.210 17.010 0.000    35.753    23.677
## arm                -0.009    0.126 -0.075 0.941     0.991     0.774
## TYPESTATUSnumeric   0.568    0.122  4.660 0.000     1.765     1.390
## day                 0.131    0.128  1.020 0.308     1.140     0.887
## earlyacademicyear  -0.013    0.128 -0.101 0.919     0.987     0.769
## white              -0.074    0.128 -0.576 0.565     0.929     0.723
## structuraletiology  0.108    0.152  0.712 0.476     1.114     0.827
## priorepilepsy      -0.258    0.135 -1.909 0.056     0.773     0.593
## status              0.068    0.155  0.439 0.661     1.070     0.790
## ageyears           -0.014    0.014 -0.989 0.323     0.986     0.960
## SEXnumeric         -0.049    0.131 -0.376 0.707     0.952     0.736
##                    upper .95
## intercept             53.987
## arm                    1.268
## TYPESTATUSnumeric      2.242
## day                    1.464
## earlyacademicyear      1.268
## white                  1.193
## structuraletiology     1.501
## priorepilepsy          1.007
## status                 1.451
## ageyears               1.014
## SEXnumeric             1.231
# First CI later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  101 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        11 |        90 | 
##           |     0.109 |     0.891 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  45 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         3 |        42 | 
##           |     0.067 |     0.933 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         8 |        48 | 
##           |     0.143 |     0.857 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore60min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstCImore60min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.3373
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.06935858 1.94926376
## sample estimates:
## odds ratio 
##    0.43196
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$awareness, tau=60,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.404    -2.722     1.914 0.733
## RMST (arm=1)/(arm=0)  0.993     0.954     1.033 0.724
## RMTL (arm=1)/(arm=0)  1.006     0.283     3.573 0.992
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          61.809    1.976 31.281 0.000    57.936    65.682
## arm                -0.404    1.183 -0.342 0.733    -2.722     1.914
## TYPESTATUSnumeric  -1.338    1.696 -0.789 0.430    -4.661     1.986
## day                -1.722    1.291 -1.334 0.182    -4.253     0.808
## earlyacademicyear  -1.544    1.255 -1.230 0.219    -4.004     0.917
## white               0.326    1.547  0.211 0.833    -2.706     3.357
## structuraletiology -1.007    1.844 -0.546 0.585    -4.622     2.607
## priorepilepsy      -1.220    1.419 -0.860 0.390    -4.001     1.561
## status              3.073    1.332  2.308 0.021     0.463     5.683
## ageyears           -0.182    0.158 -1.151 0.250    -0.492     0.128
## SEXnumeric         -0.414    1.800 -0.230 0.818    -3.941     3.113
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)       z     p exp(coef) lower .95
## intercept           4.126    0.034 120.050 0.000    61.902    57.870
## arm                -0.007    0.020  -0.354 0.724     0.993     0.954
## TYPESTATUSnumeric  -0.023    0.030  -0.770 0.442     0.977     0.922
## day                -0.030    0.022  -1.323 0.186     0.971     0.929
## earlyacademicyear  -0.027    0.022  -1.224 0.221     0.974     0.933
## white               0.006    0.027   0.218 0.827     1.006     0.955
## structuraletiology -0.018    0.032  -0.541 0.589     0.983     0.922
## priorepilepsy      -0.021    0.025  -0.848 0.396     0.979     0.933
## status              0.052    0.023   2.267 0.023     1.054     1.007
## ageyears           -0.003    0.003  -1.126 0.260     0.997     0.991
## SEXnumeric         -0.007    0.031  -0.232 0.817     0.993     0.934
##                    upper .95
## intercept             66.215
## arm                    1.033
## TYPESTATUSnumeric      1.036
## day                    1.014
## earlyacademicyear      1.016
## white                  1.060
## structuraletiology     1.047
## priorepilepsy          1.028
## status                 1.102
## ageyears               1.002
## SEXnumeric             1.055
## 
## 
## Model summary (ratio of time-lost) 
##                       coef se(coef)       z     p exp(coef) lower .95
## intercept           -1.838    1.077  -1.706 0.088     0.159     0.019
## arm                  0.006    0.646   0.010 0.992     1.006     0.283
## TYPESTATUSnumeric    0.779    0.718   1.084 0.278     2.179     0.533
## day                  1.033    0.789   1.310 0.190     2.810     0.599
## earlyacademicyear    0.890    0.772   1.153 0.249     2.436     0.536
## white                0.076    0.907   0.083 0.934     1.079     0.182
## structuraletiology   0.455    0.696   0.654 0.513     1.577     0.403
## priorepilepsy        0.642    0.610   1.052 0.293     1.899     0.574
## status             -17.597    0.636 -27.682 0.000     0.000     0.000
## ageyears             0.101    0.047   2.150 0.032     1.107     1.009
## SEXnumeric           0.096    0.805   0.120 0.905     1.101     0.227
##                    upper .95
## intercept              1.314
## arm                    3.573
## TYPESTATUSnumeric      8.907
## day                   13.180
## earlyacademicyear     11.067
## white                  6.384
## structuraletiology     6.174
## priorepilepsy          6.280
## status                 0.000
## ageyears               1.214
## SEXnumeric             5.338
# First CI later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  101 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        28 |        73 | 
##           |     0.277 |     0.723 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  45 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        10 |        35 | 
##           |     0.222 |     0.778 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        18 |        38 | 
##           |     0.321 |     0.679 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore120min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstCImore120min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.3714
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.2181885 1.6086080
## sample estimates:
## odds ratio 
##  0.6061825
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$awareness, tau=120,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -5.383   -14.817     4.052 0.263
## RMST (arm=1)/(arm=0)  0.950     0.868     1.039 0.259
## RMTL (arm=1)/(arm=0)  1.430     0.663     3.082 0.362
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          119.675    9.301 12.867 0.000   101.445   137.905
## arm                 -5.383    4.814 -1.118 0.263   -14.817     4.052
## TYPESTATUSnumeric   -7.373    6.007 -1.227 0.220   -19.147     4.402
## day                 -7.316    5.153 -1.420 0.156   -17.415     2.784
## earlyacademicyear   -7.570    5.321 -1.423 0.155   -17.999     2.860
## white                4.501    5.835  0.771 0.441    -6.936    15.937
## structuraletiology  -3.727    7.082 -0.526 0.599   -17.608    10.153
## priorepilepsy       -5.954    5.466 -1.089 0.276   -16.668     4.759
## status              11.562    5.269  2.194 0.028     1.235    21.889
## ageyears            -0.098    0.491 -0.200 0.841    -1.061     0.864
## SEXnumeric          -2.441    5.576 -0.438 0.662   -13.369     8.488
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.791    0.087 55.309 0.000   120.405   101.605
## arm                -0.052    0.046 -1.130 0.259     0.950     0.868
## TYPESTATUSnumeric  -0.069    0.059 -1.178 0.239     0.933     0.831
## day                -0.068    0.048 -1.405 0.160     0.934     0.850
## earlyacademicyear  -0.072    0.050 -1.426 0.154     0.931     0.843
## white               0.042    0.055  0.764 0.445     1.043     0.936
## structuraletiology -0.037    0.068 -0.547 0.584     0.963     0.843
## priorepilepsy      -0.055    0.052 -1.068 0.286     0.946     0.854
## status              0.108    0.049  2.193 0.028     1.114     1.012
## ageyears           -0.001    0.005 -0.202 0.840     0.999     0.990
## SEXnumeric         -0.024    0.052 -0.450 0.653     0.977     0.881
##                    upper .95
## intercept            142.684
## arm                    1.039
## TYPESTATUSnumeric      1.047
## day                    1.027
## earlyacademicyear      1.027
## white                  1.162
## structuraletiology     1.101
## priorepilepsy          1.047
## status                 1.228
## ageyears               1.008
## SEXnumeric             1.082
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           1.546    0.797  1.939 0.052     4.691     0.984
## arm                 0.357    0.392  0.912 0.362     1.430     0.663
## TYPESTATUSnumeric   0.550    0.369  1.489 0.137     1.733     0.840
## day                 0.604    0.434  1.389 0.165     1.829     0.780
## earlyacademicyear   0.542    0.429  1.263 0.207     1.719     0.742
## white              -0.364    0.474 -0.768 0.442     0.695     0.274
## structuraletiology  0.175    0.504  0.347 0.729     1.191     0.444
## priorepilepsy       0.451    0.383  1.179 0.239     1.570     0.742
## status             -0.903    0.530 -1.706 0.088     0.405     0.144
## ageyears            0.005    0.037  0.134 0.893     1.005     0.935
## SEXnumeric          0.137    0.444  0.309 0.758     1.147     0.481
##                    upper .95
## intercept             22.368
## arm                    3.082
## TYPESTATUSnumeric      3.573
## day                    4.285
## earlyacademicyear      3.984
## white                  1.760
## structuraletiology     3.196
## priorepilepsy          3.323
## status                 1.144
## ageyears               1.080
## SEXnumeric             2.737
# First CI later than 240 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  101 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        60 |        41 | 
##           |     0.594 |     0.406 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  45 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        26 |        19 | 
##           |     0.578 |     0.422 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        34 |        22 | 
##           |     0.607 |     0.393 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore240min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstCImore240min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.8395
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3699671 2.1261956
## sample estimates:
## odds ratio 
##  0.8865199
# Difference adjusting for covariates within the first 240 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$awareness, tau=240,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 240  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -6.028   -32.811    20.755 0.659
## RMST (arm=1)/(arm=0)  0.961     0.820     1.126 0.623
## RMTL (arm=1)/(arm=0)  1.068     0.722     1.581 0.742
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          205.103   25.955  7.902 0.000   154.231   255.974
## arm                 -6.028   13.665 -0.441 0.659   -32.811    20.755
## TYPESTATUSnumeric  -35.976   16.276 -2.210 0.027   -67.876    -4.075
## day                -13.064   15.116 -0.864 0.387   -42.691    16.564
## earlyacademicyear  -23.262   14.402 -1.615 0.106   -51.490     4.967
## white               14.344   16.072  0.892 0.372   -17.157    45.844
## structuraletiology -11.834   18.869 -0.627 0.531   -48.816    25.148
## priorepilepsy        2.951   15.755  0.187 0.851   -27.927    33.830
## status              15.578   15.887  0.981 0.327   -15.559    46.715
## ageyears            -1.133    1.272 -0.890 0.373    -3.626     1.361
## SEXnumeric         -11.903   14.009 -0.850 0.395   -39.361    15.554
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           5.334    0.149 35.915 0.000   207.355   154.983
## arm                -0.040    0.081 -0.491 0.623     0.961     0.820
## TYPESTATUSnumeric  -0.223    0.106 -2.112 0.035     0.800     0.650
## day                -0.071    0.087 -0.815 0.415     0.931     0.785
## earlyacademicyear  -0.136    0.085 -1.605 0.109     0.873     0.739
## white               0.086    0.097  0.887 0.375     1.090     0.901
## structuraletiology -0.076    0.114 -0.666 0.505     0.927     0.742
## priorepilepsy       0.020    0.091  0.218 0.827     1.020     0.853
## status              0.100    0.092  1.087 0.277     1.105     0.923
## ageyears           -0.007    0.008 -0.904 0.366     0.993     0.979
## SEXnumeric         -0.073    0.082 -0.887 0.375     0.930     0.791
##                    upper .95
## intercept            277.424
## arm                    1.126
## TYPESTATUSnumeric      0.984
## day                    1.105
## earlyacademicyear      1.031
## white                  1.319
## structuraletiology     1.158
## priorepilepsy          1.219
## status                 1.323
## ageyears               1.008
## SEXnumeric             1.092
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.694    0.412  8.972 0.000    40.196    17.936
## arm                 0.066    0.200  0.329 0.742     1.068     0.722
## TYPESTATUSnumeric   0.471    0.209  2.250 0.024     1.601     1.063
## day                 0.224    0.235  0.954 0.340     1.251     0.789
## earlyacademicyear   0.346    0.220  1.575 0.115     1.413     0.919
## white              -0.202    0.226 -0.892 0.372     0.817     0.524
## structuraletiology  0.140    0.266  0.526 0.599     1.150     0.683
## priorepilepsy      -0.032    0.238 -0.134 0.894     0.969     0.607
## status             -0.180    0.249 -0.726 0.468     0.835     0.513
## ageyears            0.015    0.019  0.830 0.407     1.016     0.979
## SEXnumeric          0.159    0.210  0.755 0.450     1.172     0.776
##                    upper .95
## intercept             90.080
## arm                    1.581
## TYPESTATUSnumeric      2.412
## day                    1.985
## earlyacademicyear      2.173
## white                  1.273
## structuraletiology     1.937
## priorepilepsy          1.545
## status                 1.359
## ageyears               1.053
## SEXnumeric             1.769

Time to treatment in the hospital

# Patients in each category
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        46 |        60 | 
##           |     0.434 |     0.566 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Time to first BZD
summary(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00    9.00   52.88   24.75 1440.00
sd(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0)
## [1] 165.7452
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$BZDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##     106     106       9       6      15
# Figure time to first BZD
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")

# Time to first BZD depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    4.25    8.00   37.35   25.75  360.00
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00    9.50   64.78   24.00 1440.00
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness, rho = 1)
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0 46     24.9     23.6
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1 60     30.6     31.8
##                                                   (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0    0.0636     0.173
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1    0.0473     0.173
## 
##  Chisq= 0.2  on 1 degrees of freedom, p= 0.7
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.6777943
# Figure time to first BZD by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first BZD
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness + pSERG[pSERG$HOSPITALONSET=="yes", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="yes", ]$day + pSERG[pSERG$HOSPITALONSET=="yes", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="yes", ]$white +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="yes", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$status + pSERG[pSERG$HOSPITALONSET=="yes", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="yes", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "yes", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$status + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$ageyears + pSERG[pSERG$HOSPITALONSET == "yes", ]$SEX)
## 
##   n= 106, number of events= 106 
## 
##                                                                   coef
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.006995
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.324887
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.163687
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.240533
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.148264
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.007151
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy          -0.051527
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.276420
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.009745
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                -0.115834
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               1.007019
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.722609
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     1.177846
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       1.271927
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.862204
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      1.007177
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.949778
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  1.318402
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.990302
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.890623
##                                                               se(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.211025
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.255315
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.218641
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.209979
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.218467
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.232073
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.257945
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.299264
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.019584
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.226932
##                                                                   z
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.033
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -1.272
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.749
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       1.146
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.679
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.031
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy          -0.200
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.924
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.498
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                -0.510
##                                                              Pr(>|z|)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                 0.974
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.203
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.454
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.252
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.497
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.975
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.842
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.356
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.619
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.610
## 
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                 1.0070
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.7226
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       1.1778
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         1.2719
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.8622
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        1.0072
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.9498
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    1.3184
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9903
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.8906
##                                                              exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                  0.9930
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.3839
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        0.8490
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          0.7862
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.1598
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         0.9929
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              1.0529
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     0.7585
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.0098
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    1.1228
##                                                              lower .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                 0.6659
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.4381
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.7673
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.8428
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.5619
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.6391
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.5729
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.7334
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9530
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.5709
##                                                              upper .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                  1.523
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.192
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        1.808
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          1.920
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.323
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.587
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              1.575
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     2.370
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.029
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    1.390
## 
## Concordance= 0.578  (se = 0.035 )
## Rsquare= 0.069   (max possible= 0.999 )
## Likelihood ratio test= 7.58  on 10 df,   p=0.7
## Wald test            = 7.53  on 10 df,   p=0.7
## Score (logrank) test = 7.64  on 10 df,   p=0.7
# Time to first non-BZD AED
summary(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    3.00   22.25   40.50   99.53   85.25 1488.00
sd(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0)
## [1] 212.08
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$AEDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##   106.0   106.0    40.5    29.0    51.0
# Figure time to first non-BZD AED
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")

# Time to first non-BZD AED depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    5.00   20.25   44.50   79.70   86.75  503.00
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    3.00   23.00   36.00  114.73   79.75 1488.00
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness, rho = 1)
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0 46     23.1     23.8
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1 60     31.0     30.3
##                                                   (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0    0.0188    0.0509
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1    0.0148    0.0509
## 
##  Chisq= 0.1  on 1 degrees of freedom, p= 0.8
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.8214715
# Figure time to first non-BZD AED by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first non-BZD AED
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness + pSERG[pSERG$HOSPITALONSET=="yes", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="yes", ]$day + pSERG[pSERG$HOSPITALONSET=="yes", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="yes", ]$white +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="yes", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$status + pSERG[pSERG$HOSPITALONSET=="yes", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="yes", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "yes", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$status + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$ageyears + pSERG[pSERG$HOSPITALONSET == "yes", ]$SEX)
## 
##   n= 106, number of events= 106 
## 
##                                                                   coef
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.113074
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.170027
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.472664
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.251552
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.259565
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.722228
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.009493
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.403198
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.029762
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                -0.254245
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               1.119715
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.843642
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     1.604263
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       1.286019
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.771387
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      2.059016
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           1.009538
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  1.496603
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.970676
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.775501
##                                                               se(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.212003
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.249145
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.231143
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.215040
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.229414
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.234215
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.263304
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.298991
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.019763
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.218367
##                                                                   z
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.533
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.682
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     2.045
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       1.170
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -1.131
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      3.084
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.036
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  1.349
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -1.506
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                -1.164
##                                                              Pr(>|z|)   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.59378   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.49496   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.04086 * 
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.24208   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.25788   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.00205 **
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.97124   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.17749   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.13209   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.24430   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                 1.1197
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.8436
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       1.6043
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         1.2860
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.7714
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        2.0590
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             1.0095
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    1.4966
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9707
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.7755
##                                                              exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                  0.8931
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.1853
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        0.6233
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          0.7776
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.2964
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         0.4857
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              0.9906
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     0.6682
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.0302
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    1.2895
##                                                              lower .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                 0.7390
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.5177
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       1.0198
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.8437
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.4920
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        1.3011
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.6026
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.8329
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9338
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.5055
##                                                              upper .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                  1.697
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.375
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        2.524
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          1.960
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.209
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         3.259
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              1.691
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     2.689
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.009
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    1.190
## 
## Concordance= 0.621  (se = 0.034 )
## Rsquare= 0.172   (max possible= 0.999 )
## Likelihood ratio test= 19.97  on 10 df,   p=0.03
## Wald test            = 19.89  on 10 df,   p=0.03
## Score (logrank) test = 20.16  on 10 df,   p=0.03
# Time to first CI
summary(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   113.0   175.0   558.1   420.0  7200.0      55
sd(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0)
## [1] NA
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$CONTTIME.0) ~ 
##     1)
## 
##    55 observations deleted due to missingness 
##       n  events  median 0.95LCL 0.95UCL 
##      51      51     175     122     253
# Figure time to first CI
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")

# Time to first CI depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   121.0   210.0   386.6   462.0  2520.0      23
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    5.00   90.75  147.50  699.00  420.00 7200.00      32
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness, rho = 1)
## 
## n=51, 55 observations deleted due to missingness.
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0 23     10.9     12.7
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1 28     15.3     13.5
##                                                   (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0     0.240     0.702
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1     0.225     0.702
## 
##  Chisq= 0.7  on 1 degrees of freedom, p= 0.4
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.4022339
# Figure time to first CI by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first CI
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness + pSERG[pSERG$HOSPITALONSET=="yes", ]$TYPESTATUS + 
                pSERG[pSERG$HOSPITALONSET=="yes", ]$day + pSERG[pSERG$HOSPITALONSET=="yes", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="yes", ]$white +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="yes", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$status + pSERG[pSERG$HOSPITALONSET=="yes", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="yes", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "yes", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$status + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$ageyears + pSERG[pSERG$HOSPITALONSET == "yes", ]$SEX)
## 
##   n= 51, number of events= 51 
##    (55 observations deleted due to missingness)
## 
##                                                                   coef
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.132425
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.544186
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.068633
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.136325
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.005572
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology     -0.151311
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.040558
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.795154
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.026320
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.197528
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               1.141594
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.580314
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     1.071044
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       1.146054
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.994443
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.859580
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           1.041392
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  2.214782
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.974023
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 1.218387
##                                                               se(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.325070
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.363263
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.338336
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.313471
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.348243
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.331605
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.449628
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.549214
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.033234
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.307098
##                                                                   z
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.407
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -1.498
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.203
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.435
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.016
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology     -0.456
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.090
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  1.448
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.792
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.643
##                                                              Pr(>|z|)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                 0.684
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.134
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.839
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.664
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.987
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.648
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.928
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.148
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.428
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.520
## 
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                 1.1416
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.5803
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       1.0710
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         1.1461
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.9944
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.8596
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             1.0414
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    2.2148
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9740
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   1.2184
##                                                              exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                  0.8760
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.7232
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        0.9337
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          0.8726
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.0056
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.1634
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              0.9603
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     0.4515
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.0267
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    0.8208
##                                                              lower .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                 0.6037
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.2847
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.5518
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.6200
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.5025
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.4488
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.4314
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.7548
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9126
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.6674
##                                                              upper .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                  2.159
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.183
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        2.079
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          2.119
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.968
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.646
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              2.514
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     6.499
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.040
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    2.224
## 
## Concordance= 0.587  (se = 0.049 )
## Rsquare= 0.138   (max possible= 0.997 )
## Likelihood ratio test= 7.57  on 10 df,   p=0.7
## Wald test            = 7.53  on 10 df,   p=0.7
## Score (logrank) test = 7.86  on 10 df,   p=0.6
#### Recommendations and outliers in the hospital

# First BZD later than 20 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        72 |        34 | 
##           |     0.679 |     0.321 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  46 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        32 |        14 | 
##           |     0.696 |     0.304 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  60 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        40 |        20 | 
##           |     0.667 |     0.333 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore20min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstBZDmore20min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 0.835
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4639872 2.8576593
## sample estimates:
## odds ratio 
##   1.141421
# Difference adjusting for covariates within the first 20 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, tau=20,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 20  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.083    -2.859     2.693 0.953
## RMST (arm=1)/(arm=0)  1.004     0.778     1.297 0.975
## RMTL (arm=1)/(arm=0)  1.026     0.751     1.400 0.873
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept           9.791    2.189  4.473 0.000     5.501    14.082
## arm                -0.083    1.416 -0.059 0.953    -2.859     2.693
## TYPESTATUSnumeric  -0.945    1.590 -0.595 0.552    -4.061     2.170
## day                -1.659    1.433 -1.158 0.247    -4.469     1.150
## earlyacademicyear  -1.547    1.412 -1.096 0.273    -4.314     1.220
## white               0.925    1.542  0.600 0.549    -2.098     3.947
## structuraletiology -0.508    1.564 -0.325 0.745    -3.574     2.558
## priorepilepsy       2.277    1.688  1.349 0.177    -1.031     5.586
## status             -1.631    1.802 -0.905 0.365    -5.163     1.901
## ageyears            0.231    0.140  1.655 0.098    -0.043     0.505
## SEXnumeric          1.257    1.435  0.876 0.381    -1.556     4.069
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.270    0.209 10.854 0.000     9.682     6.426
## arm                 0.004    0.130  0.032 0.975     1.004     0.778
## TYPESTATUSnumeric  -0.088    0.153 -0.578 0.564     0.916     0.679
## day                -0.139    0.130 -1.072 0.284     0.870     0.674
## earlyacademicyear  -0.136    0.133 -1.020 0.308     0.873     0.673
## white               0.074    0.149  0.499 0.618     1.077     0.804
## structuraletiology -0.041    0.145 -0.282 0.778     0.960     0.722
## priorepilepsy       0.190    0.148  1.285 0.199     1.210     0.905
## status             -0.123    0.155 -0.792 0.428     0.884     0.652
## ageyears            0.020    0.012  1.638 0.101     1.020     0.996
## SEXnumeric          0.107    0.132  0.808 0.419     1.113     0.859
##                    upper .95
## intercept             14.589
## arm                    1.297
## TYPESTATUSnumeric      1.235
## day                    1.122
## earlyacademicyear      1.133
## white                  1.443
## structuraletiology     1.276
## priorepilepsy          1.617
## status                 1.199
## ageyears               1.044
## SEXnumeric             1.442
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.305    0.240  9.621 0.000    10.027     6.269
## arm                 0.025    0.159  0.160 0.873     1.026     0.751
## TYPESTATUSnumeric   0.104    0.174  0.602 0.547     1.110     0.790
## day                 0.203    0.165  1.228 0.219     1.225     0.886
## earlyacademicyear   0.184    0.157  1.172 0.241     1.202     0.884
## white              -0.120    0.165 -0.724 0.469     0.887     0.642
## structuraletiology  0.065    0.173  0.374 0.708     1.067     0.760
## priorepilepsy      -0.289    0.216 -1.336 0.182     0.749     0.491
## status              0.228    0.232  0.983 0.326     1.256     0.797
## ageyears           -0.028    0.018 -1.595 0.111     0.972     0.939
## SEXnumeric         -0.154    0.162 -0.955 0.340     0.857     0.625
##                    upper .95
## intercept             16.037
## arm                    1.400
## TYPESTATUSnumeric      1.560
## day                    1.692
## earlyacademicyear      1.636
## white                  1.227
## structuraletiology     1.498
## priorepilepsy          1.144
## status                 1.981
## ageyears               1.006
## SEXnumeric             1.176
# First BZD later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        87 |        19 | 
##           |     0.821 |     0.179 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  46 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        36 |        10 | 
##           |     0.783 |     0.217 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  60 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        51 |         9 | 
##           |     0.850 |     0.150 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore40min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstBZDmore40min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 0.4467
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.2061146 1.9456833
## sample estimates:
## odds ratio 
##  0.6380838
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -1.511    -6.780     3.757 0.574
## RMST (arm=1)/(arm=0)  0.919     0.655     1.289 0.624
## RMTL (arm=1)/(arm=0)  1.069     0.859     1.331 0.550
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          14.834    4.509  3.290 0.001     5.997    23.671
## arm                -1.511    2.688 -0.562 0.574    -6.780     3.757
## TYPESTATUSnumeric  -4.986    2.664 -1.872 0.061   -10.207     0.235
## day                -2.052    2.834 -0.724 0.469    -7.607     3.503
## earlyacademicyear  -2.731    2.750 -0.993 0.321    -8.120     2.658
## white               2.201    3.024  0.728 0.467    -3.726     8.128
## structuraletiology  0.157    3.056  0.051 0.959    -5.833     6.147
## priorepilepsy       2.852    3.481  0.819 0.413    -3.970     9.674
## status             -4.134    3.512 -1.177 0.239   -11.018     2.750
## ageyears            0.491    0.272  1.807 0.071    -0.042     1.023
## SEXnumeric          0.662    2.692  0.246 0.806    -4.614     5.937
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.668    0.302  8.832 0.000    14.417     7.975
## arm                -0.085    0.173 -0.490 0.624     0.919     0.655
## TYPESTATUSnumeric  -0.353    0.198 -1.781 0.075     0.703     0.477
## day                -0.106    0.180 -0.587 0.557     0.900     0.633
## earlyacademicyear  -0.171    0.183 -0.933 0.351     0.843     0.589
## white               0.127    0.205  0.620 0.535     1.135     0.760
## structuraletiology  0.021    0.195  0.110 0.912     1.022     0.697
## priorepilepsy       0.159    0.207  0.768 0.442     1.173     0.781
## status             -0.223    0.220 -1.014 0.311     0.800     0.519
## ageyears            0.029    0.016  1.834 0.067     1.030     0.998
## SEXnumeric          0.027    0.174  0.156 0.876     1.027     0.731
##                    upper .95
## intercept             26.065
## arm                    1.289
## TYPESTATUSnumeric      1.036
## day                    1.280
## earlyacademicyear      1.207
## white                  1.695
## structuraletiology     1.498
## priorepilepsy          1.760
## status                 1.232
## ageyears               1.063
## SEXnumeric             1.444
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.214    0.185 17.381 0.000    24.885    17.319
## arm                 0.067    0.112  0.598 0.550     1.069     0.859
## TYPESTATUSnumeric   0.197    0.106  1.855 0.064     1.218     0.989
## day                 0.095    0.119  0.796 0.426     1.099     0.871
## earlyacademicyear   0.115    0.114  1.015 0.310     1.122     0.898
## white              -0.098    0.123 -0.794 0.427     0.907     0.712
## structuraletiology -0.002    0.127 -0.013 0.989     0.998     0.778
## priorepilepsy      -0.129    0.156 -0.829 0.407     0.879     0.647
## status              0.190    0.155  1.219 0.223     1.209     0.891
## ageyears           -0.021    0.012 -1.720 0.085     0.979     0.956
## SEXnumeric         -0.035    0.112 -0.311 0.756     0.966     0.776
##                    upper .95
## intercept             35.756
## arm                    1.331
## TYPESTATUSnumeric      1.500
## day                    1.388
## earlyacademicyear      1.402
## white                  1.154
## structuraletiology     1.281
## priorepilepsy          1.193
## status                 1.639
## ageyears               1.003
## SEXnumeric             1.202
# First BZD later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        91 |        15 | 
##           |     0.858 |     0.142 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  46 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        38 |         8 | 
##           |     0.826 |     0.174 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  60 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        53 |         7 | 
##           |     0.883 |     0.117 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore60min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstBZDmore60min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 0.4158
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1777201 2.1803303
## sample estimates:
## odds ratio 
##  0.6301883
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -3.168   -10.546     4.211 0.400
## RMST (arm=1)/(arm=0)  0.850     0.576     1.256 0.415
## RMTL (arm=1)/(arm=0)  1.081     0.901     1.297 0.400
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          21.594    6.713  3.217 0.001     8.436    34.751
## arm                -3.168    3.765 -0.841 0.400   -10.546     4.211
## TYPESTATUSnumeric  -7.746    3.520 -2.201 0.028   -14.645    -0.847
## day                -2.471    4.080 -0.606 0.545   -10.468     5.526
## earlyacademicyear  -5.314    3.970 -1.339 0.181   -13.096     2.467
## white               2.103    4.439  0.474 0.636    -6.597    10.802
## structuraletiology  0.356    4.318  0.083 0.934    -8.107     8.820
## priorepilepsy       1.234    5.055  0.244 0.807    -8.673    11.141
## status             -5.587    4.687 -1.192 0.233   -14.773     3.598
## ageyears            0.653    0.394  1.660 0.097    -0.118     1.425
## SEXnumeric         -0.539    3.918 -0.138 0.891    -8.218     7.139
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.046    0.355  8.585 0.000    21.038    10.495
## arm                -0.162    0.199 -0.815 0.415     0.850     0.576
## TYPESTATUSnumeric  -0.475    0.234 -2.026 0.043     0.622     0.393
## day                -0.102    0.213 -0.478 0.633     0.903     0.595
## earlyacademicyear  -0.284    0.221 -1.283 0.199     0.753     0.488
## white               0.095    0.245  0.387 0.698     1.100     0.680
## structuraletiology  0.035    0.232  0.151 0.880     1.036     0.657
## priorepilepsy       0.049    0.248  0.197 0.844     1.050     0.646
## status             -0.268    0.261 -1.025 0.305     0.765     0.459
## ageyears            0.033    0.019  1.711 0.087     1.033     0.995
## SEXnumeric         -0.045    0.209 -0.217 0.828     0.956     0.634
##                    upper .95
## intercept             42.174
## arm                    1.256
## TYPESTATUSnumeric      0.985
## day                    1.371
## earlyacademicyear      1.162
## white                  1.777
## structuraletiology     1.633
## priorepilepsy          1.706
## status                 1.276
## ageyears               1.072
## SEXnumeric             1.440
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.642    0.167 21.807 0.000    38.186    27.525
## arm                 0.078    0.093  0.842 0.400     1.081     0.901
## TYPESTATUSnumeric   0.181    0.083  2.188 0.029     1.199     1.019
## day                 0.066    0.101  0.655 0.513     1.068     0.876
## earlyacademicyear   0.130    0.098  1.332 0.183     1.139     0.940
## white              -0.055    0.108 -0.512 0.608     0.946     0.766
## structuraletiology -0.005    0.106 -0.052 0.959     0.995     0.808
## priorepilepsy      -0.034    0.130 -0.262 0.794     0.967     0.750
## status              0.143    0.117  1.217 0.224     1.153     0.916
## ageyears           -0.016    0.010 -1.589 0.112     0.984     0.964
## SEXnumeric          0.009    0.096  0.095 0.924     1.009     0.836
##                    upper .95
## intercept             52.976
## arm                    1.297
## TYPESTATUSnumeric      1.410
## day                    1.303
## earlyacademicyear      1.380
## white                  1.169
## structuraletiology     1.224
## priorepilepsy          1.246
## status                 1.452
## ageyears               1.004
## SEXnumeric             1.218
# First non-BZD ASM later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        53 |        53 | 
##           |     0.500 |     0.500 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  46 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        22 |        24 | 
##           |     0.478 |     0.522 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  60 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        31 |        29 | 
##           |     0.517 |     0.483 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore40min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstASMmore40min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 0.8448
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3703187 1.9833858
## sample estimates:
## odds ratio 
##  0.8587752
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -1.621    -5.480     2.237 0.410
## RMST (arm=1)/(arm=0)  0.949     0.836     1.077 0.414
## RMTL (arm=1)/(arm=0)  1.188     0.783     1.802 0.418
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          28.911    3.297  8.770 0.000    22.450    35.372
## arm                -1.621    1.969 -0.824 0.410    -5.480     2.237
## TYPESTATUSnumeric   2.651    2.445  1.085 0.278    -2.140     7.443
## day                -4.473    2.180 -2.052 0.040    -8.746    -0.201
## earlyacademicyear   0.017    2.127  0.008 0.994    -4.152     4.186
## white               3.735    2.172  1.719 0.086    -0.523     7.992
## structuraletiology -3.455    2.170 -1.592 0.111    -7.708     0.798
## priorepilepsy       1.694    2.482  0.682 0.495    -3.170     6.557
## status             -2.928    2.804 -1.044 0.296    -8.424     2.568
## ageyears            0.438    0.207  2.117 0.034     0.033     0.844
## SEXnumeric          0.489    2.242  0.218 0.827    -3.905     4.882
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.358    0.112 30.116 0.000    28.738    23.096
## arm                -0.053    0.065 -0.816 0.414     0.949     0.836
## TYPESTATUSnumeric   0.088    0.079  1.117 0.264     1.092     0.936
## day                -0.148    0.073 -2.030 0.042     0.862     0.747
## earlyacademicyear   0.006    0.071  0.083 0.934     1.006     0.875
## white               0.127    0.075  1.692 0.091     1.136     0.980
## structuraletiology -0.118    0.076 -1.559 0.119     0.889     0.766
## priorepilepsy       0.052    0.079  0.659 0.510     1.053     0.903
## status             -0.095    0.092 -1.033 0.301     0.909     0.760
## ageyears            0.014    0.007  2.106 0.035     1.014     1.001
## SEXnumeric          0.014    0.074  0.186 0.853     1.014     0.876
##                    upper .95
## intercept             35.758
## arm                    1.077
## TYPESTATUSnumeric      1.275
## day                    0.995
## earlyacademicyear      1.157
## white                  1.316
## structuraletiology     1.031
## priorepilepsy          1.229
## status                 1.089
## ageyears               1.027
## SEXnumeric             1.173
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.348    0.344  6.818 0.000    10.467     5.329
## arm                 0.172    0.213  0.810 0.418     1.188     0.783
## TYPESTATUSnumeric  -0.271    0.292 -0.926 0.354     0.763     0.430
## day                 0.466    0.242  1.924 0.054     1.593     0.991
## earlyacademicyear   0.056    0.220  0.255 0.799     1.058     0.688
## white              -0.358    0.219 -1.636 0.102     0.699     0.455
## structuraletiology  0.327    0.211  1.554 0.120     1.387     0.918
## priorepilepsy      -0.213    0.326 -0.652 0.514     0.808     0.427
## status              0.333    0.331  1.006 0.314     1.396     0.729
## ageyears           -0.055    0.029 -1.911 0.056     0.947     0.895
## SEXnumeric         -0.074    0.232 -0.319 0.750     0.929     0.589
##                    upper .95
## intercept             20.558
## arm                    1.802
## TYPESTATUSnumeric      1.353
## day                    2.561
## earlyacademicyear      1.626
## white                  1.073
## structuraletiology     2.095
## priorepilepsy          1.531
## status                 2.673
## ageyears               1.001
## SEXnumeric             1.464
# First non-BZD ASM later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        70 |        36 | 
##           |     0.660 |     0.340 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  46 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        30 |        16 | 
##           |     0.652 |     0.348 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  60 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        40 |        20 | 
##           |     0.667 |     0.333 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore60min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstASMmore60min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3870208 2.2911897
## sample estimates:
## odds ratio 
##  0.9380757
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -3.609   -10.328     3.109 0.292
## RMST (arm=1)/(arm=0)  0.910     0.767     1.080 0.280
## RMTL (arm=1)/(arm=0)  1.182     0.844     1.654 0.330
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          38.778    5.697  6.806 0.000    27.611    49.944
## arm                -3.609    3.428 -1.053 0.292   -10.328     3.109
## TYPESTATUSnumeric   1.003    4.302  0.233 0.816    -7.429     9.435
## day                -8.555    3.701 -2.311 0.021   -15.809    -1.300
## earlyacademicyear   0.987    3.640  0.271 0.786    -6.147     8.121
## white               6.147    3.741  1.643 0.100    -1.185    13.480
## structuraletiology -7.831    3.569 -2.194 0.028   -14.825    -0.836
## priorepilepsy       1.394    4.310  0.323 0.746    -7.055     9.842
## status             -5.182    4.801 -1.079 0.280   -14.591     4.228
## ageyears            0.694    0.346  2.005 0.045     0.016     1.373
## SEXnumeric          2.342    3.731  0.628 0.530    -4.969     9.654
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.647    0.150 24.390 0.000    38.351    28.609
## arm                -0.094    0.087 -1.080 0.280     0.910     0.767
## TYPESTATUSnumeric   0.029    0.110  0.261 0.794     1.029     0.829
## day                -0.224    0.097 -2.321 0.020     0.799     0.662
## earlyacademicyear   0.037    0.096  0.384 0.701     1.037     0.860
## white               0.167    0.102  1.643 0.100     1.182     0.968
## structuraletiology -0.216    0.100 -2.171 0.030     0.805     0.663
## priorepilepsy       0.029    0.107  0.267 0.790     1.029     0.834
## status             -0.136    0.126 -1.081 0.280     0.872     0.681
## ageyears            0.017    0.008  2.006 0.045     1.017     1.000
## SEXnumeric          0.058    0.096  0.606 0.544     1.060     0.879
##                    upper .95
## intercept             51.410
## arm                    1.080
## TYPESTATUSnumeric      1.278
## day                    0.966
## earlyacademicyear      1.251
## white                  1.443
## structuraletiology     0.979
## priorepilepsy          1.269
## status                 1.117
## ageyears               1.034
## SEXnumeric             1.278
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.015    0.275 10.982 0.000    20.397    11.908
## arm                 0.167    0.172  0.974 0.330     1.182     0.844
## TYPESTATUSnumeric  -0.033    0.211 -0.157 0.875     0.967     0.640
## day                 0.403    0.190  2.114 0.035     1.496     1.030
## earlyacademicyear  -0.010    0.173 -0.059 0.953     0.990     0.705
## white              -0.268    0.173 -1.550 0.121     0.765     0.545
## structuraletiology  0.335    0.162  2.067 0.039     1.398     1.017
## priorepilepsy      -0.082    0.233 -0.351 0.726     0.921     0.583
## status              0.241    0.236  1.020 0.308     1.272     0.801
## ageyears           -0.038    0.020 -1.879 0.060     0.963     0.926
## SEXnumeric         -0.118    0.181 -0.655 0.513     0.888     0.623
##                    upper .95
## intercept             34.938
## arm                    1.654
## TYPESTATUSnumeric      1.463
## day                    2.173
## earlyacademicyear      1.389
## white                  1.073
## structuraletiology     1.921
## priorepilepsy          1.456
## status                 2.019
## ageyears               1.002
## SEXnumeric             1.266
# First non-BZD ASM later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        89 |        17 | 
##           |     0.840 |     0.160 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  46 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        39 |         7 | 
##           |     0.848 |     0.152 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  60 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        50 |        10 | 
##           |     0.833 |     0.167 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore120min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstASMmore120min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3456596 3.7818722
## sample estimates:
## odds ratio 
##   1.113139
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, tau=120,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -6.343   -20.061     7.376 0.365
## RMST (arm=1)/(arm=0)  0.889     0.690     1.144 0.360
## RMTL (arm=1)/(arm=0)  1.102     0.889     1.365 0.376
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept           58.931   12.551  4.695 0.000    34.331    83.530
## arm                 -6.343    6.999 -0.906 0.365   -20.061     7.376
## TYPESTATUSnumeric  -10.959    8.013 -1.368 0.171   -26.664     4.747
## day                -16.539    7.451 -2.220 0.026   -31.143    -1.935
## earlyacademicyear   -1.965    7.726 -0.254 0.799   -17.108    13.178
## white                9.463    7.348  1.288 0.198    -4.939    23.866
## structuraletiology -17.087    7.053 -2.423 0.015   -30.910    -3.263
## priorepilepsy        1.750    9.314  0.188 0.851   -16.505    20.005
## status              -9.308   10.198 -0.913 0.361   -29.296    10.679
## ageyears             1.410    0.718  1.964 0.050     0.003     2.818
## SEXnumeric           6.884    7.623  0.903 0.367    -8.058    21.825
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.064    0.235 17.304 0.000    58.197    36.728
## arm                -0.118    0.129 -0.916 0.360     0.889     0.690
## TYPESTATUSnumeric  -0.211    0.164 -1.287 0.198     0.810     0.587
## day                -0.307    0.138 -2.228 0.026     0.735     0.561
## earlyacademicyear  -0.013    0.151 -0.088 0.930     0.987     0.734
## white               0.188    0.145  1.296 0.195     1.207     0.908
## structuraletiology -0.354    0.146 -2.419 0.016     0.702     0.527
## priorepilepsy       0.007    0.167  0.045 0.964     1.007     0.726
## status             -0.172    0.197 -0.873 0.382     0.842     0.572
## ageyears            0.024    0.012  1.962 0.050     1.024     1.000
## SEXnumeric          0.122    0.138  0.882 0.378     1.129     0.862
##                    upper .95
## intercept             92.214
## arm                    1.144
## TYPESTATUSnumeric      1.117
## day                    0.964
## earlyacademicyear      1.326
## white                  1.605
## structuraletiology     0.935
## priorepilepsy          1.399
## status                 1.239
## ageyears               1.048
## SEXnumeric             1.480
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.101    0.193 21.243 0.000    60.415    41.381
## arm                 0.097    0.109  0.886 0.376     1.102     0.889
## TYPESTATUSnumeric   0.165    0.117  1.413 0.158     1.179     0.938
## day                 0.255    0.121  2.099 0.036     1.290     1.017
## earlyacademicyear   0.044    0.116  0.378 0.706     1.045     0.832
## white              -0.139    0.110 -1.261 0.207     0.870     0.701
## structuraletiology  0.242    0.105  2.297 0.022     1.274     1.036
## priorepilepsy      -0.039    0.151 -0.260 0.794     0.961     0.715
## status              0.143    0.158  0.910 0.363     1.154     0.847
## ageyears           -0.024    0.012 -1.882 0.060     0.977     0.953
## SEXnumeric         -0.109    0.119 -0.917 0.359     0.896     0.709
##                    upper .95
## intercept             88.202
## arm                    1.365
## TYPESTATUSnumeric      1.483
## day                    1.636
## earlyacademicyear      1.313
## white                  1.080
## structuraletiology     1.566
## priorepilepsy          1.292
## status                 1.572
## ageyears               1.001
## SEXnumeric             1.132
# First CI later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  51 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         6 |        45 | 
##           |     0.118 |     0.882 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  23 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         3 |        20 | 
##           |     0.130 |     0.870 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  28 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         3 |        25 | 
##           |     0.107 |     0.893 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore60min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstCImore60min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.1499791 10.3332141
## sample estimates:
## odds ratio 
##   1.244498
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$awareness, tau=60,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 2.856    -3.935     9.647 0.410
## RMST (arm=1)/(arm=0) 1.052     0.932     1.187 0.411
## RMTL (arm=1)/(arm=0) 0.036     0.000     7.667 0.224
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          52.621    5.122 10.273 0.000    42.582    62.661
## arm                 2.856    3.465  0.824 0.410    -3.935     9.647
## TYPESTATUSnumeric   3.849    3.415  1.127 0.260    -2.844    10.542
## day                -6.217    3.277 -1.897 0.058   -12.640     0.206
## earlyacademicyear   2.342    3.253  0.720 0.472    -4.034     8.717
## white               1.304    3.965  0.329 0.742    -6.467     9.075
## structuraletiology -2.219    4.221 -0.526 0.599   -10.492     6.055
## priorepilepsy       4.686    3.071  1.526 0.127    -1.332    10.705
## status              0.659    1.918  0.343 0.731    -3.100     4.418
## ageyears            0.254    0.268  0.949 0.343    -0.271     0.779
## SEXnumeric          1.125    4.257  0.264 0.792    -7.218     9.468
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.960    0.098 40.371 0.000    52.458    43.283
## arm                 0.051    0.062  0.823 0.411     1.052     0.932
## TYPESTATUSnumeric   0.068    0.062  1.091 0.275     1.070     0.948
## day                -0.109    0.061 -1.786 0.074     0.897     0.796
## earlyacademicyear   0.042    0.060  0.710 0.478     1.043     0.928
## white               0.026    0.075  0.344 0.731     1.026     0.886
## structuraletiology -0.040    0.078 -0.515 0.607     0.961     0.825
## priorepilepsy       0.082    0.057  1.448 0.147     1.085     0.972
## status              0.012    0.035  0.339 0.734     1.012     0.946
## ageyears            0.005    0.005  0.922 0.357     1.005     0.995
## SEXnumeric          0.020    0.076  0.260 0.795     1.020     0.879
##                    upper .95
## intercept             63.578
## arm                    1.187
## TYPESTATUSnumeric      1.208
## day                    1.011
## earlyacademicyear      1.173
## white                  1.188
## structuraletiology     1.119
## priorepilepsy          1.212
## status                 1.083
## ageyears               1.014
## SEXnumeric             1.184
## 
## 
## Model summary (ratio of time-lost) 
##                       coef se(coef)      z     p    exp(coef) lower .95
## intercept          -30.089   15.467 -1.945 0.052 0.000000e+00     0.000
## arm                 -3.336    2.742 -1.217 0.224 3.600000e-02     0.000
## TYPESTATUSnumeric   -6.922    7.027 -0.985 0.325 1.000000e-03     0.000
## day                 30.429   12.383  2.457 0.014 1.640917e+13   472.733
## earlyacademicyear    2.186    2.707  0.807 0.420 8.895000e+00     0.044
## white                7.312    7.441  0.983 0.326 1.497991e+03     0.001
## structuraletiology   6.785    6.175  1.099 0.272 8.847070e+02     0.005
## priorepilepsy      -25.509    5.790 -4.406 0.000 0.000000e+00     0.000
## status               1.394    2.089  0.667 0.505 4.030000e+00     0.067
## ageyears            -0.299    0.279 -1.071 0.284 7.420000e-01     0.430
## SEXnumeric          -3.688    3.298 -1.119 0.263 2.500000e-02     0.000
##                       upper .95
## intercept          1.254000e+00
## arm                7.667000e+00
## TYPESTATUSnumeric  9.452930e+02
## day                5.695835e+23
## earlyacademicyear  1.793332e+03
## white              3.232650e+09
## structuraletiology 1.596780e+08
## priorepilepsy      0.000000e+00
## status             2.417270e+02
## ageyears           1.281000e+00
## SEXnumeric         1.603300e+01
# First CI later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  51 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        17 |        34 | 
##           |     0.333 |     0.667 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  23 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         6 |        17 | 
##           |     0.261 |     0.739 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  28 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        11 |        17 | 
##           |     0.393 |     0.607 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore120min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstCImore120min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 0.381
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1343347 2.0889696
## sample estimates:
## odds ratio 
##  0.5519603
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$awareness, tau=120,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -2.805   -19.283    13.673 0.739
## RMST (arm=1)/(arm=0)  0.974     0.834     1.137 0.734
## RMTL (arm=1)/(arm=0)  1.204     0.342     4.240 0.773
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          101.070   11.623  8.695 0.000    78.289   123.851
## arm                 -2.805    8.407 -0.334 0.739   -19.283    13.673
## TYPESTATUSnumeric   11.275    8.492  1.328 0.184    -5.368    27.918
## day                -10.569    8.453 -1.250 0.211   -27.137     6.000
## earlyacademicyear    3.885    8.447  0.460 0.646   -12.671    20.442
## white               -2.514    9.540 -0.264 0.792   -21.212    16.183
## structuraletiology  -5.011   10.431 -0.480 0.631   -25.456    15.434
## priorepilepsy        6.419    9.071  0.708 0.479   -11.360    24.198
## status               1.494    8.585  0.174 0.862   -15.333    18.320
## ageyears             1.000    0.661  1.513 0.130    -0.295     2.295
## SEXnumeric           3.017    9.489  0.318 0.751   -15.581    21.616
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.610    0.118 39.166 0.000   100.519    79.809
## arm                -0.027    0.079 -0.340 0.734     0.974     0.834
## TYPESTATUSnumeric   0.109    0.083  1.311 0.190     1.115     0.948
## day                -0.100    0.084 -1.195 0.232     0.905     0.768
## earlyacademicyear   0.039    0.082  0.474 0.636     1.039     0.886
## white              -0.022    0.096 -0.229 0.819     0.978     0.811
## structuraletiology -0.048    0.103 -0.463 0.643     0.953     0.779
## priorepilepsy       0.060    0.088  0.682 0.495     1.062     0.894
## status              0.015    0.080  0.192 0.848     1.016     0.867
## ageyears            0.010    0.007  1.463 0.144     1.010     0.997
## SEXnumeric          0.028    0.092  0.302 0.762     1.028     0.859
##                    upper .95
## intercept            126.604
## arm                    1.137
## TYPESTATUSnumeric      1.312
## day                    1.066
## earlyacademicyear      1.219
## white                  1.180
## structuraletiology     1.167
## priorepilepsy          1.262
## status                 1.189
## ageyears               1.023
## SEXnumeric             1.230
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.600    0.712  3.652 0.000    13.464     3.336
## arm                 0.186    0.642  0.289 0.773     1.204     0.342
## TYPESTATUSnumeric  -0.765    0.701 -1.092 0.275     0.465     0.118
## day                 0.835    0.590  1.416 0.157     2.306     0.726
## earlyacademicyear  -0.186    0.642 -0.290 0.772     0.830     0.236
## white               0.357    0.517  0.691 0.490     1.429     0.519
## structuraletiology  0.380    0.645  0.589 0.556     1.462     0.413
## priorepilepsy      -0.487    0.660 -0.738 0.461     0.615     0.169
## status             -0.103    0.821 -0.126 0.900     0.902     0.181
## ageyears           -0.074    0.053 -1.395 0.163     0.928     0.836
## SEXnumeric         -0.270    0.595 -0.454 0.650     0.764     0.238
##                    upper .95
## intercept             54.346
## arm                    4.240
## TYPESTATUSnumeric      1.837
## day                    7.326
## earlyacademicyear      2.922
## white                  3.933
## structuraletiology     5.181
## priorepilepsy          2.239
## status                 4.505
## ageyears               1.031
## SEXnumeric             2.449
# First CI later than 240 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  51 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        33 |        18 | 
##           |     0.647 |     0.353 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  23 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        13 |        10 | 
##           |     0.565 |     0.435 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  28 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        20 |         8 | 
##           |     0.714 |     0.286 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore240min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstCImore240min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 0.3784
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1383207 1.9334817
## sample estimates:
## odds ratio 
##  0.5268577
# Difference adjusting for covariates within the first 240 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$awareness, tau=240,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 240  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                         Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -23.387   -64.120    17.346 0.260
## RMST (arm=1)/(arm=0)   0.867     0.679     1.108 0.255
## RMTL (arm=1)/(arm=0)   1.388     0.751     2.567 0.296
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          183.537   30.975  5.925 0.000   122.826   244.248
## arm                -23.387   20.782 -1.125 0.260   -64.120    17.346
## TYPESTATUSnumeric   -2.385   22.115 -0.108 0.914   -45.731    40.960
## day                -21.428   21.765 -0.984 0.325   -64.087    21.231
## earlyacademicyear    3.846   21.896  0.176 0.861   -39.069    46.761
## white              -17.596   22.494 -0.782 0.434   -61.684    26.492
## structuraletiology   8.556   26.206  0.326 0.744   -42.807    59.918
## priorepilepsy       -9.487   30.842 -0.308 0.758   -69.937    50.963
## status             -10.921   29.020 -0.376 0.707   -67.799    45.956
## ageyears             3.113    1.663  1.872 0.061    -0.147     6.374
## SEXnumeric          -1.786   22.440 -0.080 0.937   -45.767    42.195
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           5.208    0.189 27.578 0.000   182.778   126.231
## arm                -0.142    0.125 -1.139 0.255     0.867     0.679
## TYPESTATUSnumeric  -0.008    0.144 -0.053 0.958     0.992     0.748
## day                -0.132    0.135 -0.983 0.326     0.876     0.673
## earlyacademicyear   0.026    0.133  0.193 0.847     1.026     0.791
## white              -0.103    0.137 -0.756 0.450     0.902     0.690
## structuraletiology  0.056    0.161  0.345 0.730     1.057     0.771
## priorepilepsy      -0.068    0.194 -0.349 0.727     0.935     0.639
## status             -0.054    0.189 -0.289 0.773     0.947     0.654
## ageyears            0.018    0.010  1.829 0.067     1.018     0.999
## SEXnumeric         -0.008    0.136 -0.058 0.954     0.992     0.760
##                    upper .95
## intercept            264.655
## arm                    1.108
## TYPESTATUSnumeric      1.317
## day                    1.141
## earlyacademicyear      1.331
## white                  1.179
## structuraletiology     1.449
## priorepilepsy          1.367
## status                 1.370
## ageyears               1.038
## SEXnumeric             1.296
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.005    0.427  9.382 0.000    54.881    23.770
## arm                 0.328    0.314  1.045 0.296     1.388     0.751
## TYPESTATUSnumeric   0.066    0.266  0.249 0.803     1.069     0.634
## day                 0.291    0.294  0.990 0.322     1.338     0.752
## earlyacademicyear  -0.035    0.305 -0.115 0.909     0.966     0.531
## white               0.255    0.312  0.816 0.414     1.291     0.700
## structuraletiology -0.096    0.349 -0.274 0.784     0.909     0.458
## priorepilepsy       0.087    0.410  0.213 0.831     1.091     0.488
## status              0.201    0.368  0.546 0.585     1.223     0.594
## ageyears           -0.048    0.028 -1.720 0.086     0.953     0.903
## SEXnumeric          0.035    0.315  0.113 0.910     1.036     0.559
##                    upper .95
## intercept            126.709
## arm                    2.567
## TYPESTATUSnumeric      1.800
## day                    2.381
## earlyacademicyear      1.756
## white                  2.381
## structuraletiology     1.802
## priorepilepsy          2.439
## status                 2.516
## ageyears               1.007
## SEXnumeric             1.920

Time to treatment sensitivity analysis 1: comparison 2011-2016 versus 2017-2019

# Create variable awareness of delays 2017 in time to treatment
pSERG$awareness2017 <- ifelse(pSERG$yearSE >= 2017, 1, 0)
CrossTable(pSERG$awareness2017)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       237 |        91 | 
##           |     0.723 |     0.277 | 
##           |-----------|-----------|
## 
## 
## 
## 
## ALL PATIENTS


# Time to first BZD
summary(pSERG$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   17.00   63.74   45.00 1440.00
sd(pSERG$BZDTIME.0)
## [1] 157.5196
survfit(Surv(pSERG$BZDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG$BZDTIME.0) ~ 1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##     328     328      17      14      20
# Figure time to first BZD
plot(survfit(Surv(pSERG$BZDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")

# Time to first BZD depending on awareness
summary(pSERG[which(pSERG$awareness2017 == 0), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   17.00   59.53   48.00 1264.00
summary(pSERG[which(pSERG$awareness2017 == 1), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0     5.0    15.0    74.7    36.0  1440.0
survdiff(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho = 1)
## 
##                     N Observed Expected (O-E)^2/E (O-E)^2/V
## pSERG$awareness=0 151     76.8     81.3     0.245     0.733
## pSERG$awareness=1 177     94.1     89.6     0.223     0.733
## 
##  Chisq= 0.7  on 1 degrees of freedom, p= 0.4
pchisq(survdiff(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.3918653
# Figure time to first BZD by awareness
plot(survfit(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first BZD
summary(coxph(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness2017 + pSERG$TYPESTATUS + pSERG$HOSPITALONSET + 
                pSERG$day + pSERG$earlyacademicyear + pSERG$white +
                pSERG$structuraletiology + pSERG$priorepilepsy +
                pSERG$status + pSERG$ageyears + pSERG$SEX))
## Call:
## coxph(formula = Surv(pSERG$BZDTIME.0) ~ pSERG$awareness2017 + 
##     pSERG$TYPESTATUS + pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + 
##     pSERG$white + pSERG$structuraletiology + pSERG$priorepilepsy + 
##     pSERG$status + pSERG$ageyears + pSERG$SEX)
## 
##   n= 328, number of events= 328 
## 
##                                   coef exp(coef)  se(coef)      z Pr(>|z|)
## pSERG$awareness2017          -0.082672  0.920653  0.128813 -0.642  0.52101
## pSERG$TYPESTATUSintermittent -0.399841  0.670426  0.128163 -3.120  0.00181
## pSERG$HOSPITALONSETyes        0.376731  1.457512  0.125754  2.996  0.00274
## pSERG$day                     0.101469  1.106796  0.115304  0.880  0.37885
## pSERG$earlyacademicyear       0.186072  1.204509  0.112069  1.660  0.09685
## pSERG$white                   0.010736  1.010794  0.122555  0.088  0.93019
## pSERG$structuraletiology      0.054302  1.055804  0.135510  0.401  0.68862
## pSERG$priorepilepsy           0.019734  1.019930  0.124593  0.158  0.87415
## pSERG$status                  0.500398  1.649378  0.157600  3.175  0.00150
## pSERG$ageyears               -0.003008  0.996997  0.011126 -0.270  0.78691
## pSERG$SEXmale                 0.070919  1.073494  0.116168  0.610  0.54154
##                                
## pSERG$awareness2017            
## pSERG$TYPESTATUSintermittent **
## pSERG$HOSPITALONSETyes       **
## pSERG$day                      
## pSERG$earlyacademicyear      . 
## pSERG$white                    
## pSERG$structuraletiology       
## pSERG$priorepilepsy            
## pSERG$status                 **
## pSERG$ageyears                 
## pSERG$SEXmale                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                              exp(coef) exp(-coef) lower .95 upper .95
## pSERG$awareness2017             0.9207     1.0862    0.7152    1.1851
## pSERG$TYPESTATUSintermittent    0.6704     1.4916    0.5215    0.8619
## pSERG$HOSPITALONSETyes          1.4575     0.6861    1.1391    1.8649
## pSERG$day                       1.1068     0.9035    0.8829    1.3874
## pSERG$earlyacademicyear         1.2045     0.8302    0.9670    1.5004
## pSERG$white                     1.0108     0.9893    0.7950    1.2852
## pSERG$structuraletiology        1.0558     0.9471    0.8095    1.3770
## pSERG$priorepilepsy             1.0199     0.9805    0.7989    1.3020
## pSERG$status                    1.6494     0.6063    1.2111    2.2463
## pSERG$ageyears                  0.9970     1.0030    0.9755    1.0190
## pSERG$SEXmale                   1.0735     0.9315    0.8549    1.3480
## 
## Concordance= 0.615  (se = 0.02 )
## Rsquare= 0.107   (max possible= 1 )
## Likelihood ratio test= 37.03  on 11 df,   p=1e-04
## Wald test            = 39.1  on 11 df,   p=5e-05
## Score (logrank) test = 40.01  on 11 df,   p=4e-05
# Time to first non-BZD AED
summary(pSERG$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   33.75   65.50  162.60  150.00 4320.00
sd(pSERG$AEDTIME.0)
## [1] 333.9342
survfit(Surv(pSERG$AEDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG$AEDTIME.0) ~ 1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##   328.0   328.0    65.5    60.0    77.0
# Figure time to first non-BZD AED
plot(survfit(Surv(pSERG$AEDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")

# Time to first non-BZD AED depending on awareness
summary(pSERG[which(pSERG$awareness2017 == 0), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    35.0    65.0   165.2   150.0  4320.0
summary(pSERG[which(pSERG$awareness2017 == 1), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    10.0    31.5    66.0   155.9   151.5  1488.0
survdiff(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho = 1)
## 
##                     N Observed Expected (O-E)^2/E (O-E)^2/V
## pSERG$awareness=0 151     75.4     77.2    0.0412     0.117
## pSERG$awareness=1 177     90.4     88.6    0.0359     0.117
## 
##  Chisq= 0.1  on 1 degrees of freedom, p= 0.7
pchisq(survdiff(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.7328349
# Figure time to first non-BZD AED by awareness
plot(survfit(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first non-BZD AED
summary(coxph(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness2017 + pSERG$TYPESTATUS + pSERG$HOSPITALONSET + 
                pSERG$day + pSERG$earlyacademicyear + pSERG$white +
                pSERG$structuraletiology + pSERG$priorepilepsy +
                pSERG$status + pSERG$ageyears + pSERG$SEX))
## Call:
## coxph(formula = Surv(pSERG$AEDTIME.0) ~ pSERG$awareness2017 + 
##     pSERG$TYPESTATUS + pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + 
##     pSERG$white + pSERG$structuraletiology + pSERG$priorepilepsy + 
##     pSERG$status + pSERG$ageyears + pSERG$SEX)
## 
##   n= 328, number of events= 328 
## 
##                                  coef exp(coef) se(coef)      z Pr(>|z|)
## pSERG$awareness2017          -0.08924   0.91463  0.12971 -0.688   0.4915
## pSERG$TYPESTATUSintermittent -0.55775   0.57250  0.12735 -4.379 1.19e-05
## pSERG$HOSPITALONSETyes        0.69201   1.99772  0.12395  5.583 2.36e-08
## pSERG$day                     0.24181   1.27355  0.11596  2.085   0.0370
## pSERG$earlyacademicyear       0.14622   1.15745  0.11358  1.287   0.1980
## pSERG$white                  -0.02534   0.97498  0.11944 -0.212   0.8320
## pSERG$structuraletiology      0.26884   1.30845  0.13265  2.027   0.0427
## pSERG$priorepilepsy          -0.07114   0.93133  0.12429 -0.572   0.5670
## pSERG$status                  0.27849   1.32113  0.15704  1.773   0.0762
## pSERG$ageyears               -0.02367   0.97660  0.01113 -2.126   0.0335
## pSERG$SEXmale                 0.08118   1.08457  0.11694  0.694   0.4876
##                                 
## pSERG$awareness2017             
## pSERG$TYPESTATUSintermittent ***
## pSERG$HOSPITALONSETyes       ***
## pSERG$day                    *  
## pSERG$earlyacademicyear         
## pSERG$white                     
## pSERG$structuraletiology     *  
## pSERG$priorepilepsy             
## pSERG$status                 .  
## pSERG$ageyears               *  
## pSERG$SEXmale                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                              exp(coef) exp(-coef) lower .95 upper .95
## pSERG$awareness2017             0.9146     1.0933    0.7093    1.1794
## pSERG$TYPESTATUSintermittent    0.5725     1.7467    0.4460    0.7348
## pSERG$HOSPITALONSETyes          1.9977     0.5006    1.5669    2.5471
## pSERG$day                       1.2735     0.7852    1.0146    1.5985
## pSERG$earlyacademicyear         1.1574     0.8640    0.9265    1.4460
## pSERG$white                     0.9750     1.0257    0.7715    1.2321
## pSERG$structuraletiology        1.3084     0.7643    1.0089    1.6970
## pSERG$priorepilepsy             0.9313     1.0737    0.7300    1.1882
## pSERG$status                    1.3211     0.7569    0.9711    1.7973
## pSERG$ageyears                  0.9766     1.0240    0.9555    0.9982
## pSERG$SEXmale                   1.0846     0.9220    0.8624    1.3640
## 
## Concordance= 0.654  (se = 0.019 )
## Rsquare= 0.185   (max possible= 1 )
## Likelihood ratio test= 66.9  on 11 df,   p=5e-10
## Wald test            = 68.9  on 11 df,   p=2e-10
## Score (logrank) test = 70.36  on 11 df,   p=1e-10
# Time to first CI
summary(pSERG$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   113.5   173.5   523.7   543.2  7200.0     176
sd(pSERG$CONTTIME.0)
## [1] NA
survfit(Surv(pSERG$CONTTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG$CONTTIME.0) ~ 1)
## 
##    176 observations deleted due to missingness 
##       n  events  median 0.95LCL 0.95UCL 
##     152     152     174     154     230
# Figure time to first CI
plot(survfit(Surv(pSERG$CONTTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")

# Time to first CI depending on awareness
summary(pSERG[which(pSERG$awareness2017 == 0), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   121.0   180.0   499.1   539.0  7200.0     122
summary(pSERG[which(pSERG$awareness2017 == 1), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0    85.0   140.0   600.4   540.0  6003.0      54
survdiff(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, 
##     rho = 1)
## 
## n=152, 176 observations deleted due to missingness.
## 
##                    N Observed Expected (O-E)^2/E (O-E)^2/V
## pSERG$awareness=0 68     32.2     36.5     0.516      1.48
## pSERG$awareness=1 84     44.6     40.3     0.468      1.48
## 
##  Chisq= 1.5  on 1 degrees of freedom, p= 0.2
pchisq(survdiff(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.2236165
# Figure time to first CI by awareness
plot(survfit(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first CI
summary(coxph(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness2017 + pSERG$TYPESTATUS + pSERG$HOSPITALONSET + 
                pSERG$day + pSERG$earlyacademicyear + pSERG$white +
                pSERG$structuraletiology + pSERG$priorepilepsy +
                pSERG$status + pSERG$ageyears + pSERG$SEX))
## Call:
## coxph(formula = Surv(pSERG$CONTTIME.0) ~ pSERG$awareness2017 + 
##     pSERG$TYPESTATUS + pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + 
##     pSERG$white + pSERG$structuraletiology + pSERG$priorepilepsy + 
##     pSERG$status + pSERG$ageyears + pSERG$SEX)
## 
##   n= 152, number of events= 152 
##    (176 observations deleted due to missingness)
## 
##                                   coef exp(coef)  se(coef)      z Pr(>|z|)
## pSERG$awareness2017          -0.047674  0.953444  0.203674 -0.234   0.8149
## pSERG$TYPESTATUSintermittent -0.314521  0.730138  0.192225 -1.636   0.1018
## pSERG$HOSPITALONSETyes        0.115856  1.122834  0.186605  0.621   0.5347
## pSERG$day                    -0.009578  0.990467  0.175440 -0.055   0.9565
## pSERG$earlyacademicyear       0.243513  1.275723  0.177728  1.370   0.1706
## pSERG$white                  -0.348364  0.705842  0.193028 -1.805   0.0711
## pSERG$structuraletiology      0.198861  1.220012  0.206875  0.961   0.3364
## pSERG$priorepilepsy           0.201924  1.223755  0.200729  1.006   0.3144
## pSERG$status                  0.120557  1.128125  0.231689  0.520   0.6028
## pSERG$ageyears               -0.001996  0.998006  0.016978 -0.118   0.9064
## pSERG$SEXmale                 0.191114  1.210598  0.176706  1.082   0.2795
##                               
## pSERG$awareness2017           
## pSERG$TYPESTATUSintermittent  
## pSERG$HOSPITALONSETyes        
## pSERG$day                     
## pSERG$earlyacademicyear       
## pSERG$white                  .
## pSERG$structuraletiology      
## pSERG$priorepilepsy           
## pSERG$status                  
## pSERG$ageyears                
## pSERG$SEXmale                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                              exp(coef) exp(-coef) lower .95 upper .95
## pSERG$awareness2017             0.9534     1.0488    0.6396     1.421
## pSERG$TYPESTATUSintermittent    0.7301     1.3696    0.5009     1.064
## pSERG$HOSPITALONSETyes          1.1228     0.8906    0.7789     1.619
## pSERG$day                       0.9905     1.0096    0.7023     1.397
## pSERG$earlyacademicyear         1.2757     0.7839    0.9005     1.807
## pSERG$white                     0.7058     1.4167    0.4835     1.030
## pSERG$structuraletiology        1.2200     0.8197    0.8133     1.830
## pSERG$priorepilepsy             1.2238     0.8172    0.8257     1.814
## pSERG$status                    1.1281     0.8864    0.7164     1.777
## pSERG$ageyears                  0.9980     1.0020    0.9653     1.032
## pSERG$SEXmale                   1.2106     0.8260    0.8562     1.712
## 
## Concordance= 0.566  (se = 0.028 )
## Rsquare= 0.07   (max possible= 1 )
## Likelihood ratio test= 11.05  on 11 df,   p=0.4
## Wald test            = 11.31  on 11 df,   p=0.4
## Score (logrank) test = 11.37  on 11 df,   p=0.4
# First BZD later than 20 minutes
CrossTable(pSERG$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       187 |       141 | 
##           |     0.570 |     0.430 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  237 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       134 |       103 | 
##           |     0.565 |     0.435 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 1, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  91 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        53 |        38 | 
##           |     0.582 |     0.418 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstBZDmore20min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstBZDmore20min and pSERG$awareness2017
## p-value = 0.8044
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.5533601 1.5638451
## sample estimates:
## odds ratio 
##  0.9329985
# Difference adjusting for covariates within the first 20 minutes
rmst2(time=pSERG$BZDTIME.0, status=pSERG$event, arm=pSERG$awareness2017, tau=20,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 20  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.272    -2.011     1.467 0.759
## RMST (arm=1)/(arm=0)  0.984     0.861     1.124 0.808
## RMTL (arm=1)/(arm=0)  1.057     0.821     1.360 0.669
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            16.269    1.203 13.529 0.000    13.912    18.626
## arm                  -0.272    0.887 -0.306 0.759    -2.011     1.467
## TYPESTATUSnumeric    -0.474    0.806 -0.588 0.556    -2.053     1.105
## HOSPITALONSETnumeric -3.323    0.876 -3.795 0.000    -5.039    -1.607
## day                  -0.739    0.780 -0.947 0.343    -2.267     0.789
## earlyacademicyear    -1.183    0.775 -1.526 0.127    -2.703     0.336
## white                -0.045    0.792 -0.056 0.955    -1.597     1.508
## structuraletiology   -0.673    0.921 -0.731 0.465    -2.479     1.132
## priorepilepsy        -0.667    0.838 -0.796 0.426    -2.309     0.975
## status               -3.163    1.139 -2.778 0.005    -5.395    -0.932
## ageyears              0.044    0.078  0.559 0.576    -0.110     0.198
## SEXnumeric            0.439    0.787  0.557 0.578    -1.104     1.981
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             2.805    0.090 31.312 0.000    16.527    13.866
## arm                  -0.016    0.068 -0.242 0.808     0.984     0.861
## TYPESTATUSnumeric    -0.033    0.061 -0.547 0.585     0.967     0.858
## HOSPITALONSETnumeric -0.265    0.074 -3.578 0.000     0.767     0.664
## day                  -0.057    0.058 -0.985 0.325     0.944     0.843
## earlyacademicyear    -0.087    0.059 -1.485 0.138     0.917     0.817
## white                -0.005    0.059 -0.088 0.930     0.995     0.886
## structuraletiology   -0.051    0.071 -0.717 0.474     0.950     0.827
## priorepilepsy        -0.053    0.061 -0.869 0.385     0.949     0.842
## status               -0.265    0.101 -2.615 0.009     0.767     0.629
## ageyears              0.003    0.006  0.570 0.569     1.003     0.992
## SEXnumeric            0.033    0.059  0.561 0.575     1.034     0.921
##                      upper .95
## intercept               19.700
## arm                      1.124
## TYPESTATUSnumeric        1.090
## HOSPITALONSETnumeric     0.887
## day                      1.058
## earlyacademicyear        1.028
## white                    1.117
## structuraletiology       1.092
## priorepilepsy            1.069
## status                   0.936
## ageyears                 1.015
## SEXnumeric               1.161
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             1.429    0.190  7.521 0.000     4.173     2.876
## arm                   0.055    0.129  0.428 0.669     1.057     0.821
## TYPESTATUSnumeric     0.083    0.120  0.691 0.490     1.086     0.859
## HOSPITALONSETnumeric  0.462    0.120  3.843 0.000     1.587     1.254
## day                   0.105    0.121  0.870 0.384     1.111     0.877
## earlyacademicyear     0.185    0.118  1.578 0.115     1.204     0.956
## white                -0.002    0.121 -0.014 0.989     0.998     0.788
## structuraletiology    0.099    0.133  0.745 0.456     1.104     0.851
## priorepilepsy         0.090    0.138  0.650 0.516     1.094     0.834
## status                0.407    0.146  2.786 0.005     1.502     1.128
## ageyears             -0.007    0.012 -0.534 0.593     0.993     0.969
## SEXnumeric           -0.065    0.120 -0.537 0.591     0.938     0.741
##                      upper .95
## intercept                6.056
## arm                      1.360
## TYPESTATUSnumeric        1.375
## HOSPITALONSETnumeric     2.008
## day                      1.408
## earlyacademicyear        1.516
## white                    1.265
## structuraletiology       1.432
## priorepilepsy            1.435
## status                   2.000
## ageyears                 1.018
## SEXnumeric               1.187
# First BZD later than 40 minutes
CrossTable(pSERG$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       238 |        90 | 
##           |     0.726 |     0.274 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  237 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       168 |        69 | 
##           |     0.709 |     0.291 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 1, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  91 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        70 |        21 | 
##           |     0.769 |     0.231 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstBZDmore40min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstBZDmore40min and pSERG$awareness2017
## p-value = 0.3335
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3944209 1.3171488
## sample estimates:
## odds ratio 
##  0.7311137
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG$BZDTIME.0, status=pSERG$event, arm=pSERG$awareness2017, tau=40,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.719    -4.214     2.776 0.687
## RMST (arm=1)/(arm=0)  0.971     0.812     1.161 0.750
## RMTL (arm=1)/(arm=0)  1.043     0.878     1.240 0.628
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            25.570    2.439 10.486 0.000    20.790    30.349
## arm                  -0.719    1.783 -0.403 0.687    -4.214     2.776
## TYPESTATUSnumeric    -3.816    1.560 -2.447 0.014    -6.873    -0.760
## HOSPITALONSETnumeric -7.116    1.681 -4.233 0.000   -10.411    -3.821
## day                  -0.954    1.611 -0.592 0.554    -4.111     2.203
## earlyacademicyear    -2.171    1.572 -1.381 0.167    -5.252     0.910
## white                 0.770    1.630  0.473 0.636    -2.424     3.965
## structuraletiology    0.438    1.912  0.229 0.819    -3.310     4.186
## priorepilepsy         0.180    1.746  0.103 0.918    -3.243     3.603
## status               -6.864    2.174 -3.158 0.002   -11.124    -2.603
## ageyears              0.099    0.158  0.625 0.532    -0.211     0.409
## SEXnumeric            0.067    1.617  0.041 0.967    -3.103     3.237
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.259    0.120 27.187 0.000    26.021    20.573
## arm                  -0.029    0.091 -0.319 0.750     0.971     0.812
## TYPESTATUSnumeric    -0.190    0.082 -2.319 0.020     0.827     0.705
## HOSPITALONSETnumeric -0.378    0.097 -3.883 0.000     0.685     0.566
## day                  -0.049    0.078 -0.621 0.534     0.952     0.817
## earlyacademicyear    -0.105    0.079 -1.333 0.182     0.900     0.772
## white                 0.035    0.081  0.428 0.668     1.035     0.883
## structuraletiology    0.024    0.094  0.259 0.796     1.025     0.852
## priorepilepsy         0.001    0.082  0.007 0.995     1.001     0.853
## status               -0.384    0.136 -2.826 0.005     0.681     0.522
## ageyears              0.005    0.008  0.625 0.532     1.005     0.990
## SEXnumeric            0.006    0.079  0.072 0.943     1.006     0.861
##                      upper .95
## intercept               32.912
## arm                      1.161
## TYPESTATUSnumeric        0.971
## HOSPITALONSETnumeric     0.829
## day                      1.111
## earlyacademicyear        1.051
## white                    1.214
## structuraletiology       1.232
## priorepilepsy            1.174
## status                   0.889
## ageyears                 1.020
## SEXnumeric               1.175
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             2.698    0.128 21.129 0.000    14.853    11.564
## arm                   0.043    0.088  0.485 0.628     1.043     0.878
## TYPESTATUSnumeric     0.194    0.077  2.531 0.011     1.214     1.045
## HOSPITALONSETnumeric  0.344    0.080  4.286 0.000     1.411     1.205
## day                   0.048    0.084  0.570 0.569     1.049     0.890
## earlyacademicyear     0.113    0.080  1.416 0.157     1.120     0.957
## white                -0.044    0.083 -0.528 0.598     0.957     0.814
## structuraletiology   -0.020    0.098 -0.207 0.836     0.980     0.809
## priorepilepsy        -0.018    0.096 -0.190 0.849     0.982     0.814
## status                0.323    0.100  3.234 0.001     1.382     1.136
## ageyears             -0.005    0.008 -0.626 0.531     0.995     0.978
## SEXnumeric           -0.002    0.083 -0.022 0.982     0.998     0.848
##                      upper .95
## intercept               19.078
## arm                      1.240
## TYPESTATUSnumeric        1.411
## HOSPITALONSETnumeric     1.651
## day                      1.237
## earlyacademicyear        1.310
## white                    1.126
## structuraletiology       1.187
## priorepilepsy            1.184
## status                   1.681
## ageyears                 1.011
## SEXnumeric               1.174
# First BZD later than 60 minutes
CrossTable(pSERG$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       266 |        62 | 
##           |     0.811 |     0.189 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  237 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       190 |        47 | 
##           |     0.802 |     0.198 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 1, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  91 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        76 |        15 | 
##           |     0.835 |     0.165 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstBZDmore60min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstBZDmore60min and pSERG$awareness2017
## p-value = 0.5323
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3904113 1.5588798
## sample estimates:
## odds ratio 
##  0.7984247
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG$BZDTIME.0, status=pSERG$event, arm=pSERG$awareness2017, tau=60,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -1.373    -6.350     3.603 0.589
## RMST (arm=1)/(arm=0)  0.954     0.774     1.177 0.662
## RMTL (arm=1)/(arm=0)  1.044     0.909     1.199 0.544
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept             33.528    3.619  9.265 0.000    26.436    40.621
## arm                   -1.373    2.539 -0.541 0.589    -6.350     3.603
## TYPESTATUSnumeric     -6.758    2.223 -3.040 0.002   -11.116    -2.400
## HOSPITALONSETnumeric  -9.696    2.384 -4.067 0.000   -14.369    -5.023
## day                   -1.638    2.369 -0.692 0.489    -6.281     3.005
## earlyacademicyear     -3.367    2.286 -1.473 0.141    -7.848     1.114
## white                  0.464    2.414  0.192 0.847    -4.267     5.196
## structuraletiology     0.929    2.760  0.337 0.736    -4.480     6.339
## priorepilepsy          1.514    2.554  0.593 0.553    -3.491     6.520
## status               -10.981    2.902 -3.784 0.000   -16.669    -5.293
## ageyears               0.141    0.229  0.617 0.537    -0.308     0.591
## SEXnumeric            -0.695    2.352 -0.296 0.767    -5.305     3.914
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.544    0.142 24.898 0.000    34.617    26.189
## arm                  -0.047    0.107 -0.438 0.662     0.954     0.774
## TYPESTATUSnumeric    -0.280    0.098 -2.850 0.004     0.756     0.624
## HOSPITALONSETnumeric -0.421    0.114 -3.696 0.000     0.656     0.525
## day                  -0.067    0.093 -0.722 0.470     0.935     0.779
## earlyacademicyear    -0.131    0.093 -1.409 0.159     0.877     0.730
## white                 0.013    0.097  0.137 0.891     1.013     0.838
## structuraletiology    0.040    0.109  0.368 0.713     1.041     0.841
## priorepilepsy         0.047    0.096  0.489 0.625     1.048     0.869
## status               -0.509    0.154 -3.301 0.001     0.601     0.444
## ageyears              0.005    0.009  0.589 0.556     1.005     0.988
## SEXnumeric           -0.023    0.093 -0.250 0.803     0.977     0.814
##                      upper .95
## intercept               45.757
## arm                      1.177
## TYPESTATUSnumeric        0.916
## HOSPITALONSETnumeric     0.820
## day                      1.122
## earlyacademicyear        1.053
## white                    1.225
## structuraletiology       1.289
## priorepilepsy            1.264
## status                   0.813
## ageyears                 1.023
## SEXnumeric               1.173
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.302    0.107 30.768 0.000    27.155    22.005
## arm                   0.043    0.071  0.607 0.544     1.044     0.909
## TYPESTATUSnumeric     0.191    0.062  3.089 0.002     1.210     1.072
## HOSPITALONSETnumeric  0.267    0.065  4.106 0.000     1.306     1.150
## day                   0.047    0.070  0.676 0.499     1.048     0.914
## earlyacademicyear     0.099    0.066  1.505 0.132     1.104     0.971
## white                -0.017    0.069 -0.242 0.809     0.983     0.859
## structuraletiology   -0.026    0.080 -0.320 0.749     0.975     0.833
## priorepilepsy        -0.051    0.078 -0.651 0.515     0.950     0.816
## status                0.297    0.078  3.799 0.000     1.346     1.155
## ageyears             -0.004    0.007 -0.637 0.524     0.996     0.982
## SEXnumeric            0.021    0.068  0.314 0.754     1.022     0.894
##                      upper .95
## intercept               33.511
## arm                      1.199
## TYPESTATUSnumeric        1.366
## HOSPITALONSETnumeric     1.483
## day                      1.202
## earlyacademicyear        1.255
## white                    1.126
## structuraletiology       1.140
## priorepilepsy            1.107
## status                   1.569
## ageyears                 1.009
## SEXnumeric               1.167
# First non-BZD ASM later than 40 minutes
CrossTable(pSERG$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        97 |       231 | 
##           |     0.296 |     0.704 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  237 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        68 |       169 | 
##           |     0.287 |     0.713 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 1, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  91 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        29 |        62 | 
##           |     0.319 |     0.681 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstASMmore40min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstASMmore40min and pSERG$awareness2017
## p-value = 0.5905
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4959606 1.5127514
## sample estimates:
## odds ratio 
##  0.8606414
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG$AEDTIME.0, status=pSERG$event, arm=pSERG$awareness2017, tau=40,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.846    -1.158     2.850 0.408
## RMST (arm=1)/(arm=0) 1.025     0.968     1.086 0.394
## RMTL (arm=1)/(arm=0) 0.872     0.587     1.295 0.497
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            34.455    1.692 20.367 0.000    31.140    37.771
## arm                   0.846    1.022  0.827 0.408    -1.158     2.850
## TYPESTATUSnumeric     0.090    0.999  0.090 0.928    -1.868     2.048
## HOSPITALONSETnumeric -6.667    1.232 -5.412 0.000    -9.082    -4.252
## day                  -1.494    0.981 -1.524 0.128    -3.417     0.428
## earlyacademicyear     1.039    0.941  1.105 0.269    -0.804     2.883
## white                 1.771    1.037  1.708 0.088    -0.261     3.803
## structuraletiology   -1.388    1.177 -1.179 0.238    -3.696     0.919
## priorepilepsy         1.704    0.995  1.713 0.087    -0.245     3.653
## status               -0.783    1.194 -0.656 0.512    -3.124     1.557
## ageyears              0.166    0.100  1.667 0.096    -0.029     0.361
## SEXnumeric            0.892    1.030  0.866 0.386    -1.127     2.911
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.536    0.049 71.796 0.000    34.345    31.184
## arm                   0.025    0.029  0.853 0.394     1.025     0.968
## TYPESTATUSnumeric     0.004    0.028  0.131 0.896     1.004     0.949
## HOSPITALONSETnumeric -0.197    0.039 -5.043 0.000     0.821     0.761
## day                  -0.042    0.028 -1.506 0.132     0.959     0.907
## earlyacademicyear     0.029    0.027  1.086 0.277     1.030     0.977
## white                 0.051    0.030  1.673 0.094     1.052     0.991
## structuraletiology   -0.040    0.035 -1.150 0.250     0.961     0.897
## priorepilepsy         0.048    0.028  1.692 0.091     1.049     0.992
## status               -0.022    0.034 -0.635 0.525     0.979     0.916
## ageyears              0.005    0.003  1.676 0.094     1.005     0.999
## SEXnumeric            0.025    0.029  0.838 0.402     1.025     0.967
##                      upper .95
## intercept               37.826
## arm                      1.086
## TYPESTATUSnumeric        1.061
## HOSPITALONSETnumeric     0.887
## day                      1.013
## earlyacademicyear        1.086
## white                    1.116
## structuraletiology       1.029
## priorepilepsy            1.108
## status                   1.046
## ageyears                 1.010
## SEXnumeric               1.086
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             1.508    0.341  4.420 0.000     4.519     2.315
## arm                  -0.137    0.202 -0.680 0.497     0.872     0.587
## TYPESTATUSnumeric     0.050    0.225  0.224 0.823     1.052     0.676
## HOSPITALONSETnumeric  1.252    0.215  5.813 0.000     3.496     2.293
## day                   0.337    0.215  1.572 0.116     1.401     0.920
## earlyacademicyear    -0.234    0.195 -1.197 0.231     0.792     0.540
## white                -0.362    0.199 -1.823 0.068     0.696     0.472
## structuraletiology    0.266    0.204  1.303 0.192     1.304     0.875
## priorepilepsy        -0.430    0.252 -1.708 0.088     0.650     0.397
## status                0.236    0.279  0.847 0.397     1.267     0.733
## ageyears             -0.037    0.024 -1.513 0.130     0.964     0.919
## SEXnumeric           -0.244    0.214 -1.137 0.255     0.784     0.515
##                      upper .95
## intercept                8.821
## arm                      1.295
## TYPESTATUSnumeric        1.636
## HOSPITALONSETnumeric     5.332
## day                      2.135
## earlyacademicyear        1.160
## white                    1.028
## structuraletiology       1.944
## priorepilepsy            1.066
## status                   2.188
## ageyears                 1.011
## SEXnumeric               1.193
# First non-BZD ASM later than 60 minutes
CrossTable(pSERG$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       150 |       178 | 
##           |     0.457 |     0.543 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  237 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       107 |       130 | 
##           |     0.451 |     0.549 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 1, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  91 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        43 |        48 | 
##           |     0.473 |     0.527 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstASMmore60min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstASMmore60min and pSERG$awareness2017
## p-value = 0.8046
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.5500938 1.5376924
## sample estimates:
## odds ratio 
##  0.9190219
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG$AEDTIME.0, status=pSERG$event, arm=pSERG$awareness2017, tau=60,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.882    -2.818     4.581 0.640
## RMST (arm=1)/(arm=0) 1.021     0.944     1.104 0.607
## RMTL (arm=1)/(arm=0) 0.957     0.715     1.280 0.767
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept             48.144    2.973 16.196 0.000    42.318    53.970
## arm                    0.882    1.888  0.467 0.640    -2.818     4.581
## TYPESTATUSnumeric     -2.317    1.835 -1.263 0.206    -5.913     1.278
## HOSPITALONSETnumeric -12.915    2.130 -6.063 0.000   -17.090    -8.740
## day                   -3.295    1.781 -1.849 0.064    -6.786     0.197
## earlyacademicyear      2.069    1.720  1.203 0.229    -1.303     5.440
## white                  2.791    1.873  1.490 0.136    -0.880     6.462
## structuraletiology    -3.130    2.086 -1.500 0.134    -7.219     0.959
## priorepilepsy          3.427    1.809  1.894 0.058    -0.119     6.974
## status                -1.606    2.122 -0.757 0.449    -5.766     2.553
## ageyears               0.313    0.175  1.793 0.073    -0.029     0.656
## SEXnumeric             1.948    1.823  1.069 0.285    -1.625     5.520
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.869    0.064 60.472 0.000    47.880    42.238
## arm                   0.021    0.040  0.514 0.607     1.021     0.944
## TYPESTATUSnumeric    -0.047    0.039 -1.200 0.230     0.954     0.884
## HOSPITALONSETnumeric -0.285    0.052 -5.498 0.000     0.752     0.679
## day                  -0.068    0.037 -1.832 0.067     0.934     0.868
## earlyacademicyear     0.042    0.036  1.164 0.244     1.043     0.972
## white                 0.058    0.041  1.426 0.154     1.060     0.979
## structuraletiology   -0.067    0.047 -1.435 0.151     0.935     0.854
## priorepilepsy         0.070    0.038  1.855 0.064     1.072     0.996
## status               -0.031    0.044 -0.711 0.477     0.969     0.888
## ageyears              0.006    0.004  1.798 0.072     1.006     0.999
## SEXnumeric            0.039    0.038  1.015 0.310     1.040     0.964
##                      upper .95
## intercept               54.277
## arm                      1.104
## TYPESTATUSnumeric        1.030
## HOSPITALONSETnumeric     0.832
## day                      1.005
## earlyacademicyear        1.120
## white                    1.147
## structuraletiology       1.025
## priorepilepsy            1.154
## status                   1.057
## ageyears                 1.014
## SEXnumeric               1.121
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             2.366    0.238  9.947 0.000    10.655     6.684
## arm                  -0.044    0.149 -0.296 0.767     0.957     0.715
## TYPESTATUSnumeric     0.225    0.151  1.487 0.137     1.252     0.931
## HOSPITALONSETnumeric  0.975    0.151  6.469 0.000     2.651     1.973
## day                   0.285    0.156  1.821 0.069     1.329     0.978
## earlyacademicyear    -0.190    0.145 -1.314 0.189     0.827     0.623
## white                -0.244    0.144 -1.699 0.089     0.783     0.591
## structuraletiology    0.248    0.148  1.669 0.095     1.281     0.958
## priorepilepsy        -0.332    0.173 -1.923 0.054     0.717     0.511
## status                0.183    0.192  0.955 0.340     1.201     0.825
## ageyears             -0.028    0.017 -1.683 0.092     0.972     0.941
## SEXnumeric           -0.200    0.152 -1.318 0.188     0.819     0.608
##                      upper .95
## intercept               16.983
## arm                      1.280
## TYPESTATUSnumeric        1.684
## HOSPITALONSETnumeric     3.562
## day                      1.806
## earlyacademicyear        1.098
## white                    1.038
## structuraletiology       1.713
## priorepilepsy            1.006
## status                   1.749
## ageyears                 1.005
## SEXnumeric               1.102
# First non-BZD ASM later than 120 minutes
CrossTable(pSERG$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  328 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       233 |        95 | 
##           |     0.710 |     0.290 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  237 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       166 |        71 | 
##           |     0.700 |     0.300 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 1, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  91 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        67 |        24 | 
##           |     0.736 |     0.264 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstASMmore120min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstASMmore120min and pSERG$awareness2017
## p-value = 0.5874
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4639769 1.4808285
## sample estimates:
## odds ratio 
##  0.8379485
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG$AEDTIME.0, status=pSERG$event, arm=pSERG$awareness2017, tau=120,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 1.113    -7.569     9.794 0.802
## RMST (arm=1)/(arm=0) 1.021     0.904     1.154 0.736
## RMTL (arm=1)/(arm=0) 0.990     0.826     1.185 0.909
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept             82.174    6.616 12.420 0.000    69.206    95.142
## arm                    1.113    4.430  0.251 0.802    -7.569     9.794
## TYPESTATUSnumeric    -18.974    4.069 -4.663 0.000   -26.950   -10.998
## HOSPITALONSETnumeric -28.567    4.545 -6.286 0.000   -37.474   -19.659
## day                   -7.881    4.132 -1.907 0.057   -15.980     0.219
## earlyacademicyear      0.921    4.052  0.227 0.820    -7.021     8.863
## white                  4.342    4.279  1.015 0.310    -4.045    12.729
## structuraletiology    -8.465    4.795 -1.765 0.078   -17.864     0.934
## priorepilepsy          6.921    4.330  1.598 0.110    -1.565    15.408
## status                -6.584    5.079 -1.296 0.195   -16.539     3.372
## ageyears               0.808    0.388  2.083 0.037     0.048     1.568
## SEXnumeric             3.326    4.177  0.796 0.426    -4.861    11.514
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             4.409    0.093 47.196 0.000    82.211    68.455
## arm                   0.021    0.062  0.337 0.736     1.021     0.904
## TYPESTATUSnumeric    -0.273    0.062 -4.419 0.000     0.761     0.674
## HOSPITALONSETnumeric -0.427    0.076 -5.621 0.000     0.652     0.562
## day                  -0.109    0.057 -1.921 0.055     0.897     0.802
## earlyacademicyear     0.010    0.056  0.179 0.858     1.010     0.905
## white                 0.054    0.062  0.873 0.383     1.055     0.935
## structuraletiology   -0.120    0.073 -1.638 0.101     0.887     0.769
## priorepilepsy         0.090    0.058  1.537 0.124     1.094     0.976
## status               -0.082    0.072 -1.144 0.252     0.921     0.800
## ageyears              0.010    0.005  2.048 0.041     1.010     1.000
## SEXnumeric            0.043    0.058  0.747 0.455     1.044     0.932
##                      upper .95
## intercept               98.731
## arm                      1.154
## TYPESTATUSnumeric        0.859
## HOSPITALONSETnumeric     0.757
## day                      1.002
## earlyacademicyear        1.128
## white                    1.190
## structuraletiology       1.024
## priorepilepsy            1.226
## status                   1.060
## ageyears                 1.020
## SEXnumeric               1.170
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.632    0.141 25.828 0.000    37.798    28.692
## arm                  -0.011    0.092 -0.114 0.909     0.990     0.826
## TYPESTATUSnumeric     0.387    0.083  4.660 0.000     1.473     1.251
## HOSPITALONSETnumeric  0.564    0.089  6.310 0.000     1.758     1.475
## day                   0.166    0.092  1.816 0.069     1.181     0.987
## earlyacademicyear    -0.025    0.087 -0.291 0.771     0.975     0.821
## white                -0.107    0.087 -1.231 0.218     0.898     0.757
## structuraletiology    0.176    0.092  1.905 0.057     1.192     0.995
## priorepilepsy        -0.165    0.100 -1.641 0.101     0.848     0.696
## status                0.164    0.110  1.491 0.136     1.178     0.950
## ageyears             -0.019    0.009 -2.032 0.042     0.981     0.963
## SEXnumeric           -0.081    0.090 -0.902 0.367     0.922     0.774
##                      upper .95
## intercept               49.793
## arm                      1.185
## TYPESTATUSnumeric        1.733
## HOSPITALONSETnumeric     2.094
## day                      1.413
## earlyacademicyear        1.157
## white                    1.066
## structuraletiology       1.429
## priorepilepsy            1.033
## status                   1.462
## ageyears                 0.999
## SEXnumeric               1.099
# First CI later than 60 minutes
CrossTable(pSERG$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  152 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        17 |       135 | 
##           |     0.112 |     0.888 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  115 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        11 |       104 | 
##           |     0.096 |     0.904 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 1, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  37 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         6 |        31 | 
##           |     0.162 |     0.838 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstCImore60min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstCImore60min and pSERG$awareness2017
## p-value = 0.3665
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1691578 1.9595938
## sample estimates:
## odds ratio 
##  0.5489383
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0), ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0), ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0), ]$awareness2017, tau=60,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -1.738    -6.312     2.835 0.456
## RMST (arm=1)/(arm=0)  0.970     0.895     1.052 0.463
## RMTL (arm=1)/(arm=0)  2.268     0.396    12.996 0.358
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            59.428    1.859 31.965 0.000    55.784    63.071
## arm                  -1.738    2.334 -0.745 0.456    -6.312     2.835
## TYPESTATUSnumeric     0.121    1.607  0.075 0.940    -3.030     3.271
## HOSPITALONSETnumeric -0.865    1.939 -0.446 0.656    -4.666     2.936
## day                  -2.789    1.239 -2.251 0.024    -5.218    -0.361
## earlyacademicyear    -0.643    1.462 -0.440 0.660    -3.508     2.222
## white                 1.161    1.566  0.741 0.459    -1.909     4.231
## structuraletiology   -0.894    1.865 -0.479 0.632    -4.548     2.761
## priorepilepsy        -0.396    1.289 -0.307 0.759    -2.922     2.131
## status                3.099    1.177  2.633 0.008     0.792     5.407
## ageyears             -0.017    0.148 -0.118 0.906    -0.308     0.273
## SEXnumeric           -0.198    1.596 -0.124 0.902    -3.326     2.931
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)       z     p exp(coef) lower .95
## intercept             4.085    0.032 126.425 0.000    59.413    55.768
## arm                  -0.030    0.041  -0.735 0.463     0.970     0.895
## TYPESTATUSnumeric     0.002    0.028   0.073 0.942     1.002     0.949
## HOSPITALONSETnumeric -0.015    0.034  -0.440 0.660     0.985     0.921
## day                  -0.048    0.022  -2.216 0.027     0.953     0.913
## earlyacademicyear    -0.011    0.025  -0.447 0.655     0.989     0.941
## white                 0.020    0.028   0.741 0.458     1.021     0.967
## structuraletiology   -0.016    0.033  -0.471 0.637     0.985     0.923
## priorepilepsy        -0.007    0.022  -0.303 0.762     0.993     0.951
## status                0.053    0.020   2.595 0.009     1.054     1.013
## ageyears              0.000    0.003  -0.112 0.911     1.000     0.995
## SEXnumeric           -0.004    0.028  -0.133 0.894     0.996     0.944
##                      upper .95
## intercept               63.297
## arm                      1.052
## TYPESTATUSnumeric        1.058
## HOSPITALONSETnumeric     1.053
## day                      0.994
## earlyacademicyear        1.039
## white                    1.077
## structuraletiology       1.050
## priorepilepsy            1.038
## status                   1.097
## ageyears                 1.005
## SEXnumeric               1.052
## 
## 
## Model summary (ratio of time-lost) 
##                         coef se(coef)       z     p exp(coef) lower .95
## intercept             -0.700    1.118  -0.626 0.531     0.497     0.056
## arm                    0.819    0.891   0.919 0.358     2.268     0.396
## TYPESTATUSnumeric     -0.114    0.692  -0.165 0.869     0.892     0.230
## HOSPITALONSETnumeric   0.395    0.642   0.615 0.538     1.485     0.422
## day                    1.630    0.873   1.867 0.062     5.106     0.922
## earlyacademicyear      0.229    0.640   0.358 0.721     1.257     0.358
## white                 -0.276    0.577  -0.478 0.633     0.759     0.245
## structuraletiology     0.451    0.558   0.809 0.419     1.570     0.526
## priorepilepsy          0.228    0.579   0.394 0.694     1.256     0.404
## status               -18.018    0.607 -29.677 0.000     0.000     0.000
## ageyears               0.020    0.050   0.400 0.689     1.020     0.924
## SEXnumeric            -0.139    0.720  -0.193 0.847     0.870     0.212
##                      upper .95
## intercept                4.440
## arm                     12.996
## TYPESTATUSnumeric        3.465
## HOSPITALONSETnumeric     5.226
## day                     28.285
## earlyacademicyear        4.411
## white                    2.353
## structuraletiology       4.687
## priorepilepsy            3.905
## status                   0.000
## ageyears                 1.126
## SEXnumeric               3.566
# First CI later than 120 minutes
CrossTable(pSERG$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  152 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        45 |       107 | 
##           |     0.296 |     0.704 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  115 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        29 |        86 | 
##           |     0.252 |     0.748 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 1, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  37 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        16 |        21 | 
##           |     0.432 |     0.568 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstCImore120min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstCImore120min and pSERG$awareness2017
## p-value = 0.04126
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1911348 1.0429817
## sample estimates:
## odds ratio 
##  0.4451879
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0), ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0), ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0), ]$awareness2017, tau=120,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                         Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -10.329   -22.681     2.024 0.101
## RMST (arm=1)/(arm=0)   0.905     0.801     1.024 0.112
## RMTL (arm=1)/(arm=0)   1.973     0.949     4.106 0.069
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept            112.093    6.571 17.060 0.000    99.215   124.972
## arm                  -10.329    6.302 -1.639 0.101   -22.681     2.024
## TYPESTATUSnumeric     -1.920    4.992 -0.385 0.700   -11.704     7.863
## HOSPITALONSETnumeric   1.181    5.276  0.224 0.823    -9.160    11.523
## day                   -7.005    4.282 -1.636 0.102   -15.398     1.387
## earlyacademicyear     -3.480    4.663 -0.746 0.456   -12.619     5.660
## white                  3.305    4.820  0.686 0.493    -6.142    12.752
## structuraletiology    -3.885    5.737 -0.677 0.498   -15.129     7.360
## priorepilepsy         -4.959    4.781 -1.037 0.300   -14.329     4.411
## status                 9.618    4.539  2.119 0.034     0.723    18.514
## ageyears               0.270    0.412  0.656 0.512    -0.537     1.078
## SEXnumeric            -0.866    4.698 -0.184 0.854   -10.074     8.342
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             4.719    0.061 77.068 0.000   112.075    99.400
## arm                  -0.100    0.063 -1.587 0.112     0.905     0.801
## TYPESTATUSnumeric    -0.018    0.048 -0.368 0.713     0.983     0.895
## HOSPITALONSETnumeric  0.012    0.050  0.234 0.815     1.012     0.917
## day                  -0.066    0.041 -1.623 0.105     0.936     0.864
## earlyacademicyear    -0.033    0.044 -0.743 0.458     0.968     0.888
## white                 0.031    0.046  0.677 0.498     1.032     0.943
## structuraletiology   -0.037    0.055 -0.668 0.504     0.964     0.864
## priorepilepsy        -0.046    0.045 -1.024 0.306     0.955     0.873
## status                0.090    0.043  2.104 0.035     1.094     1.006
## ageyears              0.003    0.004  0.658 0.511     1.003     0.995
## SEXnumeric           -0.009    0.044 -0.195 0.845     0.991     0.909
##                      upper .95
## intercept              126.366
## arm                      1.024
## TYPESTATUSnumeric        1.079
## HOSPITALONSETnumeric     1.116
## day                      1.014
## earlyacademicyear        1.055
## white                    1.129
## structuraletiology       1.074
## priorepilepsy            1.043
## status                   1.189
## ageyears                 1.010
## SEXnumeric               1.081
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             2.092    0.541  3.868 0.000     8.101     2.806
## arm                   0.680    0.374  1.819 0.069     1.973     0.949
## TYPESTATUSnumeric     0.176    0.336  0.525 0.600     1.193     0.617
## HOSPITALONSETnumeric -0.058    0.359 -0.162 0.871     0.943     0.467
## day                   0.520    0.326  1.595 0.111     1.681     0.888
## earlyacademicyear     0.269    0.359  0.751 0.453     1.309     0.648
## white                -0.251    0.344 -0.730 0.466     0.778     0.396
## structuraletiology    0.266    0.373  0.714 0.475     1.305     0.629
## priorepilepsy         0.382    0.343  1.115 0.265     1.465     0.749
## status               -0.804    0.414 -1.941 0.052     0.448     0.199
## ageyears             -0.019    0.031 -0.634 0.526     0.981     0.924
## SEXnumeric            0.029    0.360  0.079 0.937     1.029     0.508
##                      upper .95
## intercept               23.383
## arm                      4.106
## TYPESTATUSnumeric        2.305
## HOSPITALONSETnumeric     1.907
## day                      3.184
## earlyacademicyear        2.645
## white                    1.527
## structuraletiology       2.710
## priorepilepsy            2.867
## status                   1.008
## ageyears                 1.041
## SEXnumeric               2.082
# First CI later than 240 minutes
CrossTable(pSERG$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  152 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        93 |        59 | 
##           |     0.612 |     0.388 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  115 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        70 |        45 | 
##           |     0.609 |     0.391 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 1, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  37 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        23 |        14 | 
##           |     0.622 |     0.378 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstCImore240min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstCImore240min and pSERG$awareness2017
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4054674 2.1555749
## sample estimates:
## odds ratio 
##  0.9471852
# Difference adjusting for covariates within the first 240 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0), ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0), ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0), ]$awareness2017, tau=240,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 240  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                         Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -15.759   -46.597    15.080 0.317
## RMST (arm=1)/(arm=0)   0.908     0.746     1.105 0.337
## RMTL (arm=1)/(arm=0)   1.234     0.844     1.804 0.278
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept            192.735   19.144 10.068 0.000   155.214   230.257
## arm                  -15.759   15.734 -1.002 0.317   -46.597    15.080
## TYPESTATUSnumeric    -23.895   12.929 -1.848 0.065   -49.235     1.445
## HOSPITALONSETnumeric  -2.718   13.306 -0.204 0.838   -28.798    23.362
## day                  -14.779   12.141 -1.217 0.224   -38.574     9.017
## earlyacademicyear     -8.959   12.423 -0.721 0.471   -33.307    15.390
## white                  6.239   13.094  0.476 0.634   -19.425    31.903
## structuraletiology    -4.503   15.098 -0.298 0.766   -34.095    25.089
## priorepilepsy         -6.358   13.866 -0.459 0.647   -33.534    20.819
## status                 5.165   14.247  0.363 0.717   -22.758    33.088
## ageyears               0.275    1.109  0.248 0.804    -1.899     2.449
## SEXnumeric            -6.738   12.135 -0.555 0.579   -30.522    17.046
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             5.268    0.111 47.579 0.000   193.933   156.104
## arm                  -0.096    0.100 -0.961 0.337     0.908     0.746
## TYPESTATUSnumeric    -0.148    0.083 -1.782 0.075     0.863     0.733
## HOSPITALONSETnumeric -0.015    0.081 -0.191 0.848     0.985     0.841
## day                  -0.086    0.071 -1.207 0.227     0.917     0.798
## earlyacademicyear    -0.052    0.074 -0.700 0.484     0.950     0.822
## white                 0.036    0.078  0.458 0.647     1.037     0.889
## structuraletiology   -0.028    0.091 -0.311 0.756     0.972     0.814
## priorepilepsy        -0.036    0.081 -0.441 0.659     0.965     0.823
## status                0.032    0.084  0.379 0.705     1.032     0.875
## ageyears              0.001    0.006  0.227 0.820     1.001     0.989
## SEXnumeric           -0.040    0.072 -0.559 0.576     0.961     0.834
##                      upper .95
## intercept              240.929
## arm                      1.105
## TYPESTATUSnumeric        1.015
## HOSPITALONSETnumeric     1.153
## day                      1.055
## earlyacademicyear        1.097
## white                    1.209
## structuraletiology       1.162
## priorepilepsy            1.131
## status                   1.218
## ageyears                 1.014
## SEXnumeric               1.106
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.910    0.287 13.615 0.000    49.884    28.414
## arm                   0.210    0.194  1.084 0.278     1.234     0.844
## TYPESTATUSnumeric     0.312    0.161  1.931 0.053     1.366     0.995
## HOSPITALONSETnumeric  0.041    0.178  0.233 0.816     1.042     0.735
## day                   0.218    0.179  1.218 0.223     1.243     0.876
## earlyacademicyear     0.135    0.177  0.763 0.445     1.145     0.809
## white                -0.095    0.183 -0.518 0.604     0.910     0.635
## structuraletiology    0.054    0.207  0.263 0.793     1.056     0.704
## priorepilepsy         0.099    0.200  0.496 0.620     1.104     0.746
## status               -0.065    0.203 -0.321 0.748     0.937     0.630
## ageyears             -0.005    0.016 -0.296 0.767     0.995     0.964
## SEXnumeric            0.093    0.172  0.542 0.588     1.098     0.783
##                      upper .95
## intercept               87.579
## arm                      1.804
## TYPESTATUSnumeric        1.874
## HOSPITALONSETnumeric     1.478
## day                      1.766
## earlyacademicyear        1.619
## white                    1.302
## structuraletiology       1.583
## priorepilepsy            1.634
## status                   1.394
## ageyears                 1.027
## SEXnumeric               1.538
## OUT OF THE HOSPITAL

# At least one benzodiazepine before hospital arrival
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  157 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        59 |        98 | 
##           |     0.376 |     0.624 | 
##           |-----------|-----------|
## 
## 
## 
## 
# At least one benzodiazepine before hospital arrival depending on awareness
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  126 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        51 |        75 | 
##           |     0.405 |     0.595 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  31 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         8 |        23 | 
##           |     0.258 |     0.742 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDbeforehospital, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017)
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$AEDbeforehospital and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.1513
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.7657267 5.4431247
## sample estimates:
## odds ratio 
##    1.94711
# Logistic regression adjusting for potential confounders
logistic_out_of_hospital_BZD <- glm(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDbeforehospital ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX, family="binomial")

cbind(exp(cbind("Odds ratio" = coef(logistic_out_of_hospital_BZD), confint(logistic_out_of_hospital_BZD, level = 0.95))), "p-value" = coef(summary(logistic_out_of_hospital_BZD))[ , 4])
## Waiting for profiling to be done...
##                                                             Odds ratio
## (Intercept)                                                  3.4107042
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           2.6032630
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.3198674
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     1.0773025
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.2033688
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.7238517
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.6376308
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           1.0962135
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  6.9722164
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                1.0323259
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.5535459
##                                                                 2.5 %
## (Intercept)                                                 0.9737275
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          0.9791029
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent 0.1283232
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    0.5044118
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear      0.5799497
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  0.3252843
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     0.2672026
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          0.5252690
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 2.1232997
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               0.9628699
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                0.2581508
##                                                                 97.5 %
## (Intercept)                                                 12.9228368
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           7.5078220
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.7436255
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     2.3080334
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       2.5115588
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   1.5756203
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      1.5114287
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           2.2894750
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 32.0796254
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                1.1095969
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.1576292
##                                                                 p-value
## (Intercept)                                                 0.061170161
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          0.063202056
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent 0.010407453
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    0.847133469
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear      0.619126232
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  0.419595091
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     0.305559108
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          0.806037721
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 0.003866216
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               0.375832055
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                0.120832720
# At least one benzodiazepine before hospital arrival among those with prior epilepsy
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  85 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        29 |        56 | 
##           |     0.341 |     0.659 | 
##           |-----------|-----------|
## 
## 
## 
## 
# At least one benzodiazepine before hospital arrival depending on awareness
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$awareness2017 == 0), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  67 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        28 |        39 | 
##           |     0.418 |     0.582 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$awareness2017 == 1), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  18 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         1 |        17 | 
##           |     0.056 |     0.944 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$AEDbeforehospital, pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$awareness2017)
## 
##  Fisher's Exact Test for Count Data
## 
## data:  
## p-value = 0.004169
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##    1.677579 526.609412
## sample estimates:
## odds ratio 
##   11.95204
# Logistic regression adjusting for potential confounders among those with prior epilepsy
logistic_out_of_hospital_BZD_prior_epilepsy <- glm(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$AEDbeforehospital ~ pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$day + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$white +
                pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$structuraletiology + 
                pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$status + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$SEX, family="binomial")

cbind(exp(cbind("Odds ratio" = coef(logistic_out_of_hospital_BZD_prior_epilepsy), confint(logistic_out_of_hospital_BZD_prior_epilepsy, level = 0.95))), "p-value" = coef(summary(logistic_out_of_hospital_BZD_prior_epilepsy))[ , 4])
## Waiting for profiling to be done...
##                                                                                        Odds ratio
## (Intercept)                                                                             1.4942690
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness2017          21.9410103
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent  0.3826524
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                     1.9304558
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear       0.7720178
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                   0.5789567
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology      1.1847008
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                  9.2745040
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears                1.1110673
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                 0.5327827
##                                                                                             2.5 %
## (Intercept)                                                                            0.19803326
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness2017          3.18941042
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent 0.09695779
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                    0.62686806
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear      0.23331676
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                  0.16834295
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology     0.31837716
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                 1.87152844
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears               0.98483043
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                0.16140764
##                                                                                            97.5 %
## (Intercept)                                                                             12.343563
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness2017          459.883730
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent   1.362955
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                      6.286297
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear        2.490484
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                    1.882913
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology       4.583590
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                  73.927343
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears                 1.272520
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                  1.633239
##                                                                                            p-value
## (Intercept)                                                                            0.698426134
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness2017          0.008139511
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent 0.148696991
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                    0.258434442
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear      0.665081969
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                  0.368944308
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology     0.801018438
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                 0.013883210
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears               0.101668884
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                0.280933038
# Patients in each group
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  222 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       168 |        54 | 
##           |     0.757 |     0.243 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Time to first BZD
summary(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    7.00   20.00   68.93   55.00 1264.00
sd(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0)
## [1] 153.5504
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$BZDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##     222     222      20      20      30
# Figure time to first BZD
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")

# Time to first BZD depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    7.75   20.00   70.96   56.25 1264.00
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   20.00   62.59   48.75  517.00
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017, rho = 1)
## 
##                                                        N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017=0 168     87.0     89.2
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017=1  54     29.4     27.2
##                                                      (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017=0    0.0546     0.367
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017=1    0.1793     0.367
## 
##  Chisq= 0.4  on 1 degrees of freedom, p= 0.5
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.5443757
# Figure time to first BZD by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first BZD
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "no", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$status + pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$SEX)
## 
##   n= 222, number of events= 222 
## 
##                                                                  coef
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           0.004282
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -0.435545
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.060566
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.129393
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.112752
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.166863
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.049098
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.614537
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               -0.000615
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.146140
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           1.004292
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.646912
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     1.062438
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.138138
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   1.119355
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      1.181593
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           1.050323
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  1.848800
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.999385
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.157358
##                                                              se(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           0.164358
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.156263
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.144272
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.138468
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.150598
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.173591
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.147696
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.194934
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.014304
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.141588
##                                                                  z
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           0.026
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -2.787
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.420
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.934
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.749
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.961
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.332
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  3.153
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               -0.043
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.032
##                                                             Pr(>|z|)   
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           0.97921   
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.00532 **
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.67463   
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.35006   
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.45404   
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.33643   
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.73957   
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.00162 **
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.96570   
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.30200   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             1.0043
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.6469
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.0624
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.1381
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     1.1194
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.1816
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.0503
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.8488
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9994
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.1574
##                                                             exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017              0.9957
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     1.5458
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        0.9412
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          0.8786
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      0.8934
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         0.8463
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              0.9521
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     0.5409
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   1.0006
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    0.8640
##                                                             lower .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             0.7277
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.4762
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.8008
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.8676
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.8333
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.8408
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.7863
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.2617
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9718
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.8769
##                                                             upper .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             1.3860
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.8787
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.4096
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.4930
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     1.5037
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.6605
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.4029
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    2.7091
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  1.0278
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.5275
## 
## Concordance= 0.599  (se = 0.025 )
## Rsquare= 0.102   (max possible= 1 )
## Likelihood ratio test= 23.78  on 10 df,   p=0.008
## Wald test            = 25.49  on 10 df,   p=0.004
## Score (logrank) test = 26.45  on 10 df,   p=0.003
# Time to first non-BZD AED
summary(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    45.5    81.0   192.7   170.0  4320.0
sd(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0)
## [1] 375.2449
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$AEDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##     222     222      81      70     103
# Figure time to first non-BZD AED
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")

# Time to first non-BZD AED depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    45.0    83.0   203.2   165.2  4320.0
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   10.00   51.25   78.50  160.02  206.75  720.00
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017, rho = 1)
## 
##                                                        N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017=0 168     85.7     84.5
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017=1  54     26.7     27.9
##                                                      (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017=0    0.0173     0.105
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017=1    0.0522     0.105
## 
##  Chisq= 0.1  on 1 degrees of freedom, p= 0.7
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.7462884
# Figure time to first non-BZD AED by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first non-BZD AED
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "no", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$status + pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$SEX)
## 
##   n= 222, number of events= 222 
## 
##                                                                  coef
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          -0.010312
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -0.761135
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.152477
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.053240
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -0.086916
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     -0.007509
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          -0.133687
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.113238
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               -0.021746
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.238823
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           0.989741
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.467136
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     1.164716
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.054683
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.916754
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.992519
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.874864
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  1.119899
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.978489
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.269753
##                                                              se(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           0.166239
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.154171
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.147347
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.140347
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.146723
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.170864
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.150690
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.193886
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.014084
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.147449
##                                                                  z
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          -0.062
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -4.937
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     1.035
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.379
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -0.592
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     -0.044
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          -0.887
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.584
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               -1.544
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.620
##                                                             Pr(>|z|)    
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             0.951    
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent 7.94e-07 ***
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.301    
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.704    
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.554    
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.965    
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.375    
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.559    
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.123    
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.105    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             0.9897
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.4671
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.1647
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.0547
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.9168
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.9925
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.8749
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.1199
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9785
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.2698
##                                                             exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017              1.0104
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     2.1407
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        0.8586
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          0.9482
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      1.0908
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         1.0075
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              1.1430
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     0.8929
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   1.0220
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    0.7876
##                                                             lower .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             0.7145
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.3453
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.8726
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.8010
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.6876
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.7101
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.6511
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.7658
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9518
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.9511
##                                                             upper .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             1.3710
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.6319
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.5547
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.3886
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     1.2222
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.3873
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.1755
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.6376
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  1.0059
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.6952
## 
## Concordance= 0.621  (se = 0.023 )
## Rsquare= 0.153   (max possible= 1 )
## Likelihood ratio test= 36.79  on 10 df,   p=6e-05
## Wald test            = 37.33  on 10 df,   p=5e-05
## Score (logrank) test = 39.01  on 10 df,   p=3e-05
# Time to first CI
summary(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    15.0   118.0   172.0   506.4   626.0  4320.0     121
sd(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0)
## [1] NA
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$CONTTIME.0) ~ 
##     1)
## 
##    121 observations deleted due to missingness 
##       n  events  median 0.95LCL 0.95UCL 
##     101     101     172     150     295
# Figure time to first CI
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")

# Time to first CI depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    20.0   123.5   172.0   474.7   604.0  4320.0      85
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    15.0    67.5   217.5   652.4   900.0  3008.0      36
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017, rho = 1)
## 
## n=101, 121 observations deleted due to missingness.
## 
##                                                       N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017=0 83    41.61    42.48
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017=1 18     9.53     8.67
##                                                      (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017=0    0.0175     0.162
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017=1    0.0855     0.162
## 
##  Chisq= 0.2  on 1 degrees of freedom, p= 0.7
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.6874723
# Figure time to first CI by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first CI
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS + 
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "no", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$status + pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$SEX)
## 
##   n= 101, number of events= 101 
##    (121 observations deleted due to missingness)
## 
##                                                                   coef
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          -0.1311061
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -0.2350549
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    -0.0735340
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.3557352
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -0.3903055
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.3745878
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.1919138
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 -0.0097923
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               -0.0007926
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.1934605
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           0.8771247
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.7905274
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.9291046
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.4272296
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.6768500
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      1.4543919
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           1.2115661
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.9902555
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.9992078
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.2134415
##                                                               se(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           0.2886248
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.2355082
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.2250262
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.2340959
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.2620340
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.2815969
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.2562268
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.2775334
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.0218656
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.2370470
##                                                                  z
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          -0.454
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -0.998
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    -0.327
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.520
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -1.490
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      1.330
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.749
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 -0.035
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               -0.036
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.816
##                                                             Pr(>|z|)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             0.650
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.318
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.744
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.129
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.136
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.183
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.454
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.972
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.971
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.414
## 
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             0.8771
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.7905
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.9291
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.4272
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.6769
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.4544
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.2116
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.9903
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9992
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.2134
##                                                             exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017              1.1401
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     1.2650
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        1.0763
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          0.7007
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      1.4774
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         0.6876
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              0.8254
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     1.0098
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   1.0008
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    0.8241
##                                                             lower .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             0.4982
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.4983
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.5978
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.9021
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.4050
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.8375
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.7332
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.5748
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9573
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.7625
##                                                             upper .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017              1.544
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     1.254
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        1.444
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          2.258
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      1.131
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         2.526
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              2.002
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     1.706
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   1.043
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    1.931
## 
## Concordance= 0.576  (se = 0.034 )
## Rsquare= 0.075   (max possible= 0.999 )
## Likelihood ratio test= 7.82  on 10 df,   p=0.6
## Wald test            = 7.99  on 10 df,   p=0.6
## Score (logrank) test = 8.05  on 10 df,   p=0.6
#### Recommendations and outliers out of the hospital

# First BZD later than 20 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  222 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       115 |       107 | 
##           |     0.518 |     0.482 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  168 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        87 |        81 | 
##           |     0.518 |     0.482 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  54 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        28 |        26 | 
##           |     0.519 |     0.481 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore20min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstBZDmore20min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.5145226 1.9287505
## sample estimates:
## odds ratio 
##  0.9973663
# Difference adjusting for covariates within the first 20 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=20,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 20  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.264    -2.432     1.905 0.811
## RMST (arm=1)/(arm=0)  0.980     0.840     1.143 0.795
## RMTL (arm=1)/(arm=0)  1.035     0.712     1.504 0.858
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          17.999    1.534 11.730 0.000    14.991    21.006
## arm                -0.264    1.106 -0.239 0.811    -2.432     1.905
## TYPESTATUSnumeric  -0.104    0.919 -0.113 0.910    -1.905     1.698
## day                -0.786    0.909 -0.865 0.387    -2.567     0.995
## earlyacademicyear  -0.443    0.891 -0.498 0.619    -2.190     1.303
## white              -0.663    0.922 -0.719 0.472    -2.470     1.145
## structuraletiology -0.952    1.091 -0.873 0.383    -3.089     1.186
## priorepilepsy      -2.225    0.936 -2.379 0.017    -4.059    -0.392
## status             -4.771    1.387 -3.440 0.001    -7.489    -2.053
## ageyears           -0.036    0.093 -0.383 0.701    -0.218     0.146
## SEXnumeric          0.090    0.919  0.098 0.922    -1.712     1.892
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.910    0.103 28.345 0.000    18.349    15.005
## arm                -0.020    0.079 -0.260 0.795     0.980     0.840
## TYPESTATUSnumeric  -0.009    0.063 -0.136 0.892     0.991     0.876
## day                -0.055    0.063 -0.879 0.379     0.946     0.837
## earlyacademicyear  -0.030    0.062 -0.494 0.621     0.970     0.860
## white              -0.045    0.063 -0.709 0.478     0.956     0.846
## structuraletiology -0.065    0.077 -0.851 0.395     0.937     0.806
## priorepilepsy      -0.152    0.066 -2.310 0.021     0.859     0.756
## status             -0.386    0.129 -3.004 0.003     0.680     0.528
## ageyears           -0.003    0.006 -0.415 0.678     0.997     0.985
## SEXnumeric          0.007    0.064  0.115 0.909     1.007     0.889
##                    upper .95
## intercept             22.438
## arm                    1.143
## TYPESTATUSnumeric      1.122
## day                    1.070
## earlyacademicyear      1.094
## white                  1.082
## structuraletiology     1.089
## priorepilepsy          0.977
## status                 0.874
## ageyears               1.010
## SEXnumeric             1.142
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           1.008    0.320  3.151 0.002     2.741     1.464
## arm                 0.034    0.191  0.179 0.858     1.035     0.712
## TYPESTATUSnumeric   0.010    0.171  0.058 0.954     1.010     0.723
## day                 0.141    0.167  0.840 0.401     1.151     0.829
## earlyacademicyear   0.084    0.166  0.504 0.614     1.087     0.785
## white               0.128    0.176  0.729 0.466     1.137     0.806
## structuraletiology  0.175    0.190  0.920 0.357     1.191     0.820
## priorepilepsy       0.438    0.184  2.384 0.017     1.550     1.081
## status              0.668    0.181  3.692 0.000     1.950     1.368
## ageyears            0.005    0.017  0.297 0.766     1.005     0.972
## SEXnumeric         -0.009    0.170 -0.053 0.958     0.991     0.711
##                    upper .95
## intercept              5.132
## arm                    1.504
## TYPESTATUSnumeric      1.411
## day                    1.597
## earlyacademicyear      1.506
## white                  1.603
## structuraletiology     1.730
## priorepilepsy          2.223
## status                 2.779
## ageyears               1.039
## SEXnumeric             1.382
# First BZD later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  222 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       151 |        71 | 
##           |     0.680 |     0.320 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  168 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       113 |        55 | 
##           |     0.673 |     0.327 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  54 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        38 |        16 | 
##           |     0.704 |     0.296 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore40min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstBZDmore40min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.7389
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4129322 1.7553289
## sample estimates:
## odds ratio 
##  0.8656447
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.283    -4.973     4.408 0.906
## RMST (arm=1)/(arm=0)  0.988     0.798     1.223 0.911
## RMTL (arm=1)/(arm=0)  1.018     0.783     1.323 0.895
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          27.875    3.120  8.935 0.000    21.760    33.989
## arm                -0.283    2.393 -0.118 0.906    -4.973     4.408
## TYPESTATUSnumeric  -3.300    1.952 -1.690 0.091    -7.126     0.526
## day                -1.190    1.986 -0.599 0.549    -5.083     2.703
## earlyacademicyear  -1.276    1.929 -0.661 0.508    -5.056     2.505
## white              -0.018    2.006 -0.009 0.993    -3.949     3.912
## structuraletiology  0.345    2.404  0.144 0.886    -4.366     5.057
## priorepilepsy      -1.493    2.032 -0.735 0.463    -5.475     2.489
## status             -9.029    2.749 -3.284 0.001   -14.417    -3.640
## ageyears           -0.074    0.193 -0.382 0.703    -0.451     0.304
## SEXnumeric         -0.223    2.019 -0.110 0.912    -4.181     3.735
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.344    0.134 24.892 0.000    28.319    21.764
## arm                -0.012    0.109 -0.112 0.911     0.988     0.798
## TYPESTATUSnumeric  -0.150    0.090 -1.673 0.094     0.860     0.721
## day                -0.054    0.087 -0.620 0.535     0.947     0.798
## earlyacademicyear  -0.054    0.086 -0.629 0.530     0.948     0.801
## white               0.001    0.089  0.011 0.992     1.001     0.840
## structuraletiology  0.018    0.104  0.170 0.865     1.018     0.830
## priorepilepsy      -0.069    0.089 -0.776 0.438     0.933     0.784
## status             -0.488    0.173 -2.814 0.005     0.614     0.437
## ageyears           -0.003    0.009 -0.383 0.702     0.997     0.980
## SEXnumeric         -0.006    0.090 -0.067 0.947     0.994     0.834
##                    upper .95
## intercept             36.847
## arm                    1.223
## TYPESTATUSnumeric      1.026
## day                    1.124
## earlyacademicyear      1.121
## white                  1.192
## structuraletiology     1.248
## priorepilepsy          1.111
## status                 0.862
## ageyears               1.014
## SEXnumeric             1.185
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.538    0.190 13.323 0.000    12.655     8.712
## arm                 0.018    0.134  0.132 0.895     1.018     0.783
## TYPESTATUSnumeric   0.185    0.111  1.676 0.094     1.204     0.969
## day                 0.067    0.116  0.574 0.566     1.069     0.851
## earlyacademicyear   0.078    0.112  0.697 0.486     1.081     0.869
## white               0.004    0.115  0.032 0.974     1.004     0.801
## structuraletiology -0.016    0.143 -0.114 0.909     0.984     0.744
## priorepilepsy       0.082    0.121  0.680 0.496     1.086     0.857
## status              0.438    0.128  3.423 0.001     1.549     1.206
## ageyears            0.004    0.011  0.378 0.706     1.004     0.982
## SEXnumeric          0.019    0.117  0.162 0.871     1.019     0.810
##                    upper .95
## intercept             18.383
## arm                    1.323
## TYPESTATUSnumeric      1.495
## day                    1.343
## earlyacademicyear      1.345
## white                  1.257
## structuraletiology     1.302
## priorepilepsy          1.375
## status                 1.991
## ageyears               1.026
## SEXnumeric             1.282
# First BZD later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  222 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       175 |        47 | 
##           |     0.788 |     0.212 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  168 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       131 |        37 | 
##           |     0.780 |     0.220 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  54 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        44 |        10 | 
##           |     0.815 |     0.185 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore60min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstBZDmore60min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.7028
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3292996 1.8258519
## sample estimates:
## odds ratio 
##  0.8054587
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.875    -7.634     5.884 0.800
## RMST (arm=1)/(arm=0)  0.971     0.756     1.247 0.815
## RMTL (arm=1)/(arm=0)  1.029     0.838     1.264 0.786
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept           35.863    4.648  7.716 0.000    26.753    44.973
## arm                 -0.875    3.448 -0.254 0.800    -7.634     5.884
## TYPESTATUSnumeric   -6.354    2.854 -2.226 0.026   -11.948    -0.760
## day                 -2.103    2.950 -0.713 0.476    -7.884     3.679
## earlyacademicyear   -2.147    2.859 -0.751 0.453    -7.750     3.456
## white               -0.393    2.996 -0.131 0.895    -6.265     5.478
## structuraletiology   0.939    3.544  0.265 0.791    -6.007     7.886
## priorepilepsy        0.642    3.019  0.213 0.832    -5.275     6.558
## status             -13.704    3.668 -3.736 0.000   -20.893    -6.515
## ageyears            -0.085    0.280 -0.303 0.762    -0.634     0.464
## SEXnumeric          -0.998    2.990 -0.334 0.739    -6.858     4.863
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.598    0.160 22.436 0.000    36.508    26.663
## arm                -0.030    0.128 -0.234 0.815     0.971     0.756
## TYPESTATUSnumeric  -0.235    0.109 -2.156 0.031     0.791     0.639
## day                -0.075    0.104 -0.724 0.469     0.928     0.757
## earlyacademicyear  -0.071    0.102 -0.693 0.488     0.932     0.763
## white              -0.012    0.107 -0.110 0.912     0.988     0.801
## structuraletiology  0.037    0.122  0.301 0.763     1.037     0.817
## priorepilepsy       0.016    0.104  0.152 0.879     1.016     0.828
## status             -0.612    0.196 -3.122 0.002     0.542     0.369
## ageyears           -0.003    0.010 -0.308 0.758     0.997     0.978
## SEXnumeric         -0.028    0.106 -0.264 0.791     0.972     0.790
##                    upper .95
## intercept             49.989
## arm                    1.247
## TYPESTATUSnumeric      0.979
## day                    1.136
## earlyacademicyear      1.138
## white                  1.220
## structuraletiology     1.317
## priorepilepsy          1.247
## status                 0.796
## ageyears               1.016
## SEXnumeric             1.197
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.206    0.154 20.883 0.000    24.685    18.270
## arm                 0.028    0.105  0.271 0.786     1.029     0.838
## TYPESTATUSnumeric   0.196    0.088  2.224 0.026     1.217     1.024
## day                 0.067    0.095  0.705 0.481     1.069     0.888
## earlyacademicyear   0.072    0.090  0.795 0.427     1.074     0.900
## white               0.014    0.094  0.147 0.884     1.014     0.844
## structuraletiology -0.027    0.115 -0.238 0.812     0.973     0.776
## priorepilepsy      -0.025    0.098 -0.258 0.796     0.975     0.805
## status              0.379    0.099  3.811 0.000     1.461     1.202
## ageyears            0.003    0.009  0.294 0.769     1.003     0.985
## SEXnumeric          0.037    0.095  0.387 0.699     1.037     0.861
##                    upper .95
## intercept             33.351
## arm                    1.264
## TYPESTATUSnumeric      1.447
## day                    1.287
## earlyacademicyear      1.282
## white                  1.218
## structuraletiology     1.220
## priorepilepsy          1.181
## status                 1.776
## ageyears               1.020
## SEXnumeric             1.250
# First non-BZD ASM later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  222 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        44 |       178 | 
##           |     0.198 |     0.802 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  168 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        35 |       133 | 
##           |     0.208 |     0.792 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  54 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         9 |        45 | 
##           |     0.167 |     0.833 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore40min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstASMmore40min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.5618
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.5632003 3.3548033
## sample estimates:
## odds ratio 
##   1.314194
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.896    -1.137     2.930 0.388
## RMST (arm=1)/(arm=0) 1.024     0.970     1.081 0.389
## RMTL (arm=1)/(arm=0) 0.681     0.279     1.663 0.399
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          34.702    1.819 19.073 0.000    31.136    38.268
## arm                 0.896    1.038  0.864 0.388    -1.137     2.930
## TYPESTATUSnumeric  -1.286    0.950 -1.353 0.176    -3.148     0.576
## day                -0.548    0.996 -0.550 0.582    -2.499     1.404
## earlyacademicyear   1.327    0.918  1.446 0.148    -0.472     3.126
## white               0.959    1.067  0.899 0.368    -1.131     3.050
## structuraletiology -0.201    1.292 -0.156 0.876    -2.733     2.331
## priorepilepsy       1.878    1.040  1.805 0.071    -0.161     3.917
## status              0.836    1.000  0.836 0.403    -1.125     2.797
## ageyears            0.026    0.102  0.251 0.802    -0.174     0.226
## SEXnumeric          1.225    1.052  1.165 0.244    -0.836     3.287
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.548    0.050 70.727 0.000    34.745    31.491
## arm                 0.024    0.028  0.861 0.389     1.024     0.970
## TYPESTATUSnumeric  -0.034    0.026 -1.330 0.184     0.966     0.918
## day                -0.015    0.027 -0.552 0.581     0.985     0.935
## earlyacademicyear   0.035    0.025  1.429 0.153     1.036     0.987
## white               0.026    0.029  0.896 0.370     1.026     0.970
## structuraletiology -0.005    0.035 -0.148 0.882     0.995     0.929
## priorepilepsy       0.051    0.028  1.799 0.072     1.052     0.995
## status              0.022    0.026  0.827 0.408     1.022     0.971
## ageyears            0.001    0.003  0.259 0.796     1.001     0.995
## SEXnumeric          0.033    0.028  1.151 0.250     1.033     0.977
##                    upper .95
## intercept             38.335
## arm                    1.081
## TYPESTATUSnumeric      1.016
## day                    1.038
## earlyacademicyear      1.088
## white                  1.086
## structuraletiology     1.066
## priorepilepsy          1.111
## status                 1.076
## ageyears               1.006
## SEXnumeric             1.093
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           1.750    0.508  3.445 0.001     5.752     2.126
## arm                -0.385    0.456 -0.844 0.399     0.681     0.279
## TYPESTATUSnumeric   0.500    0.326  1.537 0.124     1.649     0.871
## day                 0.191    0.372  0.514 0.607     1.211     0.584
## earlyacademicyear  -0.556    0.364 -1.526 0.127     0.573     0.281
## white              -0.318    0.358 -0.890 0.373     0.727     0.361
## structuraletiology  0.092    0.413  0.223 0.824     1.096     0.488
## priorepilepsy      -0.714    0.447 -1.597 0.110     0.490     0.204
## status             -0.424    0.543 -0.782 0.434     0.654     0.226
## ageyears           -0.005    0.041 -0.111 0.911     0.995     0.919
## SEXnumeric         -0.481    0.373 -1.289 0.197     0.618     0.298
##                    upper .95
## intercept             15.564
## arm                    1.663
## TYPESTATUSnumeric      3.122
## day                    2.509
## earlyacademicyear      1.171
## white                  1.466
## structuraletiology     2.461
## priorepilepsy          1.176
## status                 1.895
## ageyears               1.079
## SEXnumeric             1.284
# First non-BZD ASM later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  222 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        80 |       142 | 
##           |     0.360 |     0.640 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  168 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        62 |       106 | 
##           |     0.369 |     0.631 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  54 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        18 |        36 | 
##           |     0.333 |     0.667 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore60min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstASMmore60min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.7449
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.5881457 2.3831406
## sample estimates:
## odds ratio 
##   1.168994
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 1.471    -2.549     5.490 0.473
## RMST (arm=1)/(arm=0) 1.028     0.952     1.110 0.479
## RMTL (arm=1)/(arm=0) 0.811     0.469     1.402 0.454
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          47.437    3.304 14.359 0.000    40.962    53.912
## arm                 1.471    2.051  0.717 0.473    -2.549     5.490
## TYPESTATUSnumeric  -4.400    1.904 -2.312 0.021    -8.131    -0.669
## day                -1.362    1.895 -0.719 0.472    -5.076     2.352
## earlyacademicyear   2.154    1.816  1.186 0.236    -1.406     5.715
## white               1.722    2.042  0.843 0.399    -2.281     5.725
## structuraletiology -0.484    2.429 -0.199 0.842    -5.244     4.277
## priorepilepsy       4.730    1.947  2.429 0.015     0.913     8.546
## status              1.622    2.018  0.804 0.421    -2.332     5.577
## ageyears            0.117    0.189  0.618 0.537    -0.254     0.487
## SEXnumeric          2.085    1.944  1.072 0.284    -1.725     5.896
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.860    0.066 58.475 0.000    47.474    41.712
## arm                 0.028    0.039  0.707 0.479     1.028     0.952
## TYPESTATUSnumeric  -0.086    0.038 -2.246 0.025     0.918     0.852
## day                -0.026    0.037 -0.719 0.472     0.974     0.907
## earlyacademicyear   0.041    0.035  1.178 0.239     1.042     0.973
## white               0.034    0.040  0.835 0.404     1.034     0.956
## structuraletiology -0.009    0.048 -0.182 0.856     0.991     0.903
## priorepilepsy       0.091    0.038  2.411 0.016     1.096     1.017
## status              0.030    0.038  0.801 0.423     1.031     0.957
## ageyears            0.002    0.004  0.629 0.529     1.002     0.995
## SEXnumeric          0.040    0.038  1.056 0.291     1.041     0.966
##                    upper .95
## intercept             54.031
## arm                    1.110
## TYPESTATUSnumeric      0.989
## day                    1.046
## earlyacademicyear      1.116
## white                  1.119
## structuraletiology     1.088
## priorepilepsy          1.180
## status                 1.110
## ageyears               1.009
## SEXnumeric             1.121
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.530    0.351  7.218 0.000    12.553     6.315
## arm                -0.209    0.279 -0.749 0.454     0.811     0.469
## TYPESTATUSnumeric   0.529    0.214  2.476 0.013     1.698     1.117
## day                 0.169    0.241  0.701 0.483     1.185     0.738
## earlyacademicyear  -0.282    0.241 -1.171 0.241     0.754     0.470
## white              -0.202    0.232 -0.873 0.383     0.817     0.519
## structuraletiology  0.078    0.273  0.286 0.775     1.081     0.633
## priorepilepsy      -0.608    0.272 -2.236 0.025     0.544     0.319
## status             -0.231    0.324 -0.713 0.476     0.794     0.421
## ageyears           -0.014    0.027 -0.509 0.610     0.986     0.936
## SEXnumeric         -0.273    0.237 -1.148 0.251     0.761     0.478
##                    upper .95
## intercept             24.952
## arm                    1.402
## TYPESTATUSnumeric      2.581
## day                    1.902
## earlyacademicyear      1.209
## white                  1.286
## structuraletiology     1.845
## priorepilepsy          0.928
## status                 1.497
## ageyears               1.040
## SEXnumeric             1.213
# First non-BZD ASM later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  222 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       144 |        78 | 
##           |     0.649 |     0.351 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  168 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       107 |        61 | 
##           |     0.637 |     0.363 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  54 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        37 |        17 | 
##           |     0.685 |     0.315 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore120min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstASMmore120min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.6235
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3911767 1.6152067
## sample estimates:
## odds ratio 
##  0.8067087
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=120,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.769    -9.795    11.333 0.887
## RMST (arm=1)/(arm=0) 1.008     0.885     1.148 0.908
## RMTL (arm=1)/(arm=0) 0.974     0.739     1.283 0.849
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept           82.393    7.813 10.546 0.000    67.079    97.706
## arm                  0.769    5.390  0.143 0.887    -9.795    11.333
## TYPESTATUSnumeric  -23.407    4.922 -4.755 0.000   -33.054   -13.760
## day                 -4.854    4.831 -1.005 0.315   -14.323     4.615
## earlyacademicyear    1.179    4.840  0.243 0.808    -8.309    10.666
## white                2.758    5.155  0.535 0.593    -7.346    12.862
## structuraletiology  -3.928    6.266 -0.627 0.531   -16.209     8.354
## priorepilepsy        9.607    4.996  1.923 0.055    -0.186    19.399
## status              -1.973    5.920 -0.333 0.739   -13.575     9.629
## ageyears             0.472    0.460  1.025 0.305    -0.430     1.373
## SEXnumeric           2.060    4.999  0.412 0.680    -7.738    11.858
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.401    0.098 44.698 0.000    81.531    67.222
## arm                 0.008    0.066  0.115 0.908     1.008     0.885
## TYPESTATUSnumeric  -0.305    0.068 -4.480 0.000     0.737     0.645
## day                -0.058    0.059 -0.981 0.327     0.944     0.840
## earlyacademicyear   0.017    0.060  0.293 0.770     1.018     0.905
## white               0.034    0.066  0.517 0.605     1.035     0.909
## structuraletiology -0.047    0.080 -0.579 0.562     0.955     0.815
## priorepilepsy       0.117    0.062  1.901 0.057     1.125     0.996
## status             -0.021    0.074 -0.286 0.775     0.979     0.848
## ageyears            0.006    0.005  1.027 0.304     1.006     0.995
## SEXnumeric          0.026    0.062  0.428 0.668     1.027     0.910
##                    upper .95
## intercept             98.886
## arm                    1.148
## TYPESTATUSnumeric      0.842
## day                    1.060
## earlyacademicyear      1.144
## white                  1.177
## structuraletiology     1.117
## priorepilepsy          1.269
## status                 1.131
## ageyears               1.016
## SEXnumeric             1.159
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.575    0.205 17.477 0.000    35.699    23.908
## arm                -0.027    0.141 -0.191 0.849     0.974     0.739
## TYPESTATUSnumeric   0.568    0.123  4.633 0.000     1.764     1.388
## day                 0.134    0.130  1.032 0.302     1.143     0.887
## earlyacademicyear  -0.015    0.129 -0.119 0.905     0.985     0.765
## white              -0.073    0.127 -0.575 0.565     0.930     0.725
## structuraletiology  0.109    0.152  0.720 0.472     1.115     0.829
## priorepilepsy      -0.257    0.135 -1.901 0.057     0.774     0.594
## status              0.070    0.155  0.454 0.650     1.073     0.792
## ageyears           -0.014    0.014 -0.998 0.318     0.986     0.960
## SEXnumeric         -0.048    0.131 -0.362 0.717     0.954     0.737
##                    upper .95
## intercept             53.306
## arm                    1.283
## TYPESTATUSnumeric      2.243
## day                    1.475
## earlyacademicyear      1.268
## white                  1.192
## structuraletiology     1.501
## priorepilepsy          1.008
## status                 1.452
## ageyears               1.013
## SEXnumeric             1.234
# First CI later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  101 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        11 |        90 | 
##           |     0.109 |     0.891 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  83 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         7 |        76 | 
##           |     0.084 |     0.916 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  18 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         4 |        14 | 
##           |     0.222 |     0.778 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore60min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstCImore60min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.1041
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.07110971 1.72835211
## sample estimates:
## odds ratio 
##   0.327079
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=60,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -3.612    -8.859     1.634 0.177
## RMST (arm=1)/(arm=0)  0.939     0.853     1.033 0.194
## RMTL (arm=1)/(arm=0)  6.055     1.425    25.723 0.015
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          61.577    1.677 36.723 0.000    58.290    64.863
## arm                -3.612    2.677 -1.349 0.177    -8.859     1.634
## TYPESTATUSnumeric  -1.206    1.649 -0.731 0.465    -4.438     2.026
## day                -1.177    1.214 -0.970 0.332    -3.557     1.203
## earlyacademicyear  -1.517    1.262 -1.203 0.229    -3.990     0.955
## white               0.458    1.579  0.290 0.772    -2.637     3.553
## structuraletiology -0.927    1.703 -0.544 0.586    -4.265     2.411
## priorepilepsy      -1.137    1.381 -0.823 0.410    -3.843     1.569
## status              3.334    1.464  2.278 0.023     0.465     6.203
## ageyears           -0.199    0.160 -1.242 0.214    -0.513     0.115
## SEXnumeric         -0.072    1.722 -0.042 0.967    -3.447     3.303
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)       z     p exp(coef) lower .95
## intercept           4.121    0.029 141.368 0.000    61.649    58.225
## arm                -0.063    0.049  -1.300 0.194     0.939     0.853
## TYPESTATUSnumeric  -0.021    0.029  -0.708 0.479     0.980     0.926
## day                -0.020    0.021  -0.966 0.334     0.980     0.941
## earlyacademicyear  -0.026    0.022  -1.196 0.232     0.974     0.934
## white               0.008    0.027   0.295 0.768     1.008     0.955
## structuraletiology -0.016    0.030  -0.537 0.591     0.984     0.928
## priorepilepsy      -0.019    0.024  -0.798 0.425     0.981     0.936
## status              0.056    0.025   2.249 0.025     1.058     1.007
## ageyears           -0.003    0.003  -1.207 0.227     0.997     0.991
## SEXnumeric         -0.002    0.030  -0.055 0.956     0.998     0.942
##                    upper .95
## intercept             65.275
## arm                    1.033
## TYPESTATUSnumeric      1.037
## day                    1.021
## earlyacademicyear      1.017
## white                  1.064
## structuraletiology     1.044
## priorepilepsy          1.028
## status                 1.111
## ageyears               1.002
## SEXnumeric             1.058
## 
## 
## Model summary (ratio of time-lost) 
##                       coef se(coef)       z     p exp(coef) lower .95
## intercept           -2.153    1.087  -1.981 0.048     0.116     0.014
## arm                  1.801    0.738   2.440 0.015     6.055     1.425
## TYPESTATUSnumeric    0.888    0.544   1.633 0.102     2.431     0.837
## day                  0.737    0.851   0.866 0.386     2.090     0.394
## earlyacademicyear    0.967    0.644   1.502 0.133     2.629     0.745
## white                0.033    0.783   0.043 0.966     1.034     0.223
## structuraletiology   0.343    0.733   0.468 0.640     1.409     0.335
## priorepilepsy        0.890    0.625   1.425 0.154     2.436     0.716
## status             -18.307    0.800 -22.889 0.000     0.000     0.000
## ageyears             0.127    0.047   2.685 0.007     1.135     1.035
## SEXnumeric          -0.497    0.770  -0.646 0.519     0.608     0.135
##                    upper .95
## intercept              0.978
## arm                   25.723
## TYPESTATUSnumeric      7.060
## day                   11.081
## earlyacademicyear      9.283
## white                  4.801
## structuraletiology     5.929
## priorepilepsy          8.283
## status                 0.000
## ageyears               1.245
## SEXnumeric             2.750
# First CI later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  101 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        28 |        73 | 
##           |     0.277 |     0.723 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  83 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        20 |        63 | 
##           |     0.241 |     0.759 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  18 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         8 |        10 | 
##           |     0.444 |     0.556 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore120min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstCImore120min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.09028
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.122463 1.339615
## sample estimates:
## odds ratio 
##  0.4009637
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=120,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                         Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -13.266   -29.283     2.751 0.105
## RMST (arm=1)/(arm=0)   0.878     0.742     1.039 0.129
## RMTL (arm=1)/(arm=0)   2.334     1.053     5.174 0.037
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          117.482    8.632 13.610 0.000   100.563   134.400
## arm                -13.266    8.172 -1.623 0.105   -29.283     2.751
## TYPESTATUSnumeric   -7.692    5.938 -1.295 0.195   -19.331     3.947
## day                 -5.985    5.059 -1.183 0.237   -15.900     3.930
## earlyacademicyear   -7.451    5.401 -1.380 0.168   -18.037     3.134
## white                4.986    5.769  0.864 0.387    -6.320    16.293
## structuraletiology  -2.905    6.699 -0.434 0.665   -16.035    10.226
## priorepilepsy       -5.775    5.421 -1.065 0.287   -16.401     4.850
## status              12.396    5.326  2.328 0.020     1.958    22.833
## ageyears            -0.163    0.495 -0.329 0.742    -1.133     0.807
## SEXnumeric          -1.588    5.464 -0.291 0.771   -12.297     9.121
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.769    0.080 59.857 0.000   117.794   100.764
## arm                -0.130    0.086 -1.517 0.129     0.878     0.742
## TYPESTATUSnumeric  -0.072    0.058 -1.232 0.218     0.931     0.830
## day                -0.055    0.047 -1.173 0.241     0.946     0.863
## earlyacademicyear  -0.070    0.051 -1.373 0.170     0.933     0.844
## white               0.046    0.055  0.846 0.398     1.048     0.941
## structuraletiology -0.028    0.064 -0.442 0.658     0.972     0.857
## priorepilepsy      -0.052    0.051 -1.012 0.311     0.949     0.858
## status              0.114    0.050  2.293 0.022     1.121     1.017
## ageyears           -0.002    0.005 -0.329 0.742     0.998     0.989
## SEXnumeric         -0.016    0.051 -0.320 0.749     0.984     0.890
##                    upper .95
## intercept            137.702
## arm                    1.039
## TYPESTATUSnumeric      1.043
## day                    1.038
## earlyacademicyear      1.030
## white                  1.166
## structuraletiology     1.102
## priorepilepsy          1.050
## status                 1.236
## ageyears               1.008
## SEXnumeric             1.088
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           1.628    0.785  2.075 0.038     5.093     1.094
## arm                 0.848    0.406  2.088 0.037     2.334     1.053
## TYPESTATUSnumeric   0.625    0.362  1.726 0.084     1.868     0.919
## day                 0.503    0.437  1.150 0.250     1.654     0.702
## earlyacademicyear   0.610    0.464  1.313 0.189     1.840     0.741
## white              -0.430    0.451 -0.954 0.340     0.651     0.269
## structuraletiology  0.156    0.501  0.311 0.756     1.168     0.438
## priorepilepsy       0.551    0.396  1.391 0.164     1.735     0.798
## status             -1.096    0.510 -2.149 0.032     0.334     0.123
## ageyears            0.010    0.036  0.280 0.779     1.010     0.941
## SEXnumeric         -0.003    0.453 -0.007 0.994     0.997     0.410
##                    upper .95
## intercept             23.699
## arm                    5.174
## TYPESTATUSnumeric      3.799
## day                    3.898
## earlyacademicyear      4.573
## white                  1.574
## structuraletiology     3.116
## priorepilepsy          3.773
## status                 0.908
## ageyears               1.084
## SEXnumeric             2.425
# First CI later than 240 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  101 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        60 |        41 | 
##           |     0.594 |     0.406 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  83 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        51 |        32 | 
##           |     0.614 |     0.386 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  18 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         9 |         9 | 
##           |     0.500 |     0.500 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore240min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstCImore240min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.4318
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4992948 5.0519405
## sample estimates:
## odds ratio 
##   1.586161
# Difference adjusting for covariates within the first 240 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=240,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 240  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                         Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -10.645   -51.237    29.946 0.607
## RMST (arm=1)/(arm=0)   0.934     0.722     1.207 0.601
## RMTL (arm=1)/(arm=0)   1.134     0.678     1.898 0.632
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          202.755   24.543  8.261 0.000   154.651   250.860
## arm                -10.645   20.710 -0.514 0.607   -51.237    29.946
## TYPESTATUSnumeric  -36.583   16.202 -2.258 0.024   -68.339    -4.828
## day                -12.290   14.685 -0.837 0.403   -41.072    16.492
## earlyacademicyear  -23.157   14.493 -1.598 0.110   -51.564     5.249
## white               14.733   15.888  0.927 0.354   -16.407    45.873
## structuraletiology -10.943   18.284 -0.599 0.549   -46.778    24.892
## priorepilepsy        3.040   15.755  0.193 0.847   -27.840    33.920
## status              16.192   15.972  1.014 0.311   -15.112    47.496
## ageyears            -1.186    1.278 -0.928 0.353    -3.690     1.318
## SEXnumeric         -11.396   14.109 -0.808 0.419   -39.049    16.257
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           5.319    0.138 38.624 0.000   204.092   155.817
## arm                -0.069    0.131 -0.523 0.601     0.934     0.722
## TYPESTATUSnumeric  -0.227    0.106 -2.147 0.032     0.797     0.647
## day                -0.067    0.084 -0.795 0.426     0.935     0.793
## earlyacademicyear  -0.135    0.085 -1.589 0.112     0.874     0.740
## white               0.089    0.096  0.921 0.357     1.093     0.905
## structuraletiology -0.069    0.109 -0.634 0.526     0.933     0.754
## priorepilepsy       0.022    0.091  0.240 0.810     1.022     0.855
## status              0.102    0.092  1.108 0.268     1.107     0.925
## ageyears           -0.007    0.008 -0.941 0.347     0.993     0.978
## SEXnumeric         -0.070    0.082 -0.850 0.395     0.932     0.793
##                    upper .95
## intercept            267.322
## arm                    1.207
## TYPESTATUSnumeric      0.980
## day                    1.103
## earlyacademicyear      1.032
## white                  1.320
## structuraletiology     1.155
## priorepilepsy          1.222
## status                 1.326
## ageyears               1.008
## SEXnumeric             1.096
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.717    0.404  9.204 0.000    41.159    18.650
## arm                 0.126    0.263  0.479 0.632     1.134     0.678
## TYPESTATUSnumeric   0.478    0.205  2.328 0.020     1.613     1.078
## day                 0.211    0.232  0.911 0.362     1.235     0.784
## earlyacademicyear   0.349    0.223  1.568 0.117     1.418     0.916
## white              -0.206    0.223 -0.923 0.356     0.814     0.526
## structuraletiology  0.134    0.264  0.507 0.612     1.143     0.682
## priorepilepsy      -0.026    0.239 -0.108 0.914     0.974     0.609
## status             -0.196    0.251 -0.781 0.435     0.822     0.503
## ageyears            0.016    0.018  0.864 0.388     1.016     0.980
## SEXnumeric          0.149    0.214  0.694 0.487     1.160     0.762
##                    upper .95
## intercept             90.836
## arm                    1.898
## TYPESTATUSnumeric      2.412
## day                    1.946
## earlyacademicyear      2.195
## white                  1.260
## structuraletiology     1.916
## priorepilepsy          1.558
## status                 1.345
## ageyears               1.054
## SEXnumeric             1.766
## IN THE HOSPITAL

# Patients in each group
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        69 |        37 | 
##           |     0.651 |     0.349 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Time to first BZD
summary(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00    9.00   52.88   24.75 1440.00
sd(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0)
## [1] 165.7452
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$BZDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##     106     106       9       6      15
# Figure time to first BZD
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")

# Time to first BZD depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0     4.0     9.0    31.7    26.0   360.0
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.00    5.00    9.00   92.38   23.00 1440.00
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017, rho = 1)
## 
##                                                        N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017=0 69     37.1     35.2
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017=1 37     18.4     20.3
##                                                       (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017=0     0.103     0.439
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017=1     0.179     0.439
## 
##  Chisq= 0.4  on 1 degrees of freedom, p= 0.5
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.5073782
# Figure time to first BZD by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first BZD
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="yes", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="yes", ]$day + pSERG[pSERG$HOSPITALONSET=="yes", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="yes", ]$white +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="yes", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$status + pSERG[pSERG$HOSPITALONSET=="yes", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="yes", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "yes", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$status + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$ageyears + pSERG[pSERG$HOSPITALONSET == "yes", ]$SEX)
## 
##   n= 106, number of events= 106 
## 
##                                                                   coef
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017          -0.123640
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.304963
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.156174
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.242866
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.128864
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology     -0.001492
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy          -0.033578
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.245805
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.011140
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                -0.076751
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.883698
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.737151
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     1.169030
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       1.274898
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.879093
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.998509
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.966979
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  1.278650
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.988922
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.926120
##                                                               se(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.234115
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.253876
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.219812
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.210579
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.219801
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.232757
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.257892
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.304712
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.019597
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.234414
##                                                                   z
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017          -0.528
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -1.201
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.710
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       1.153
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.586
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology     -0.006
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy          -0.130
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.807
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.568
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                -0.327
##                                                              Pr(>|z|)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             0.597
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.230
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.477
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.249
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.558
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.995
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.896
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.420
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.570
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.743
## 
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             0.8837
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.7372
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       1.1690
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         1.2749
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.8791
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.9985
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.9670
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    1.2786
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9889
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.9261
##                                                              exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017              1.1316
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.3566
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        0.8554
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          0.7844
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.1375
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.0015
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              1.0341
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     0.7821
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.0112
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    1.0798
##                                                              lower .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             0.5585
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.4482
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.7598
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.8438
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.5714
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.6327
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.5833
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.7037
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9517
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.5850
##                                                              upper .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017              1.398
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.212
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        1.799
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          1.926
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.352
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.576
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              1.603
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     2.323
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.028
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    1.466
## 
## Concordance= 0.591  (se = 0.035 )
## Rsquare= 0.071   (max possible= 0.999 )
## Likelihood ratio test= 7.86  on 10 df,   p=0.6
## Wald test            = 7.93  on 10 df,   p=0.6
## Score (logrank) test = 8.05  on 10 df,   p=0.6
# Time to first non-BZD AED
summary(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    3.00   22.25   40.50   99.53   85.25 1488.00
sd(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0)
## [1] 212.08
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$AEDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##   106.0   106.0    40.5    29.0    51.0
# Figure time to first non-BZD AED
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")

# Time to first non-BZD AED depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    3.00   20.00   42.00   72.51   76.00  503.00
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    10.0    24.0    31.0   149.9    96.0  1488.0
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017, rho = 1)
## 
##                                                        N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017=0 69     35.8     34.6
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017=1 37     18.3     19.5
##                                                       (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017=0    0.0402     0.169
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017=1    0.0714     0.169
## 
##  Chisq= 0.2  on 1 degrees of freedom, p= 0.7
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.6807389
# Figure time to first non-BZD AED by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first non-BZD AED
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="yes", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="yes", ]$day + pSERG[pSERG$HOSPITALONSET=="yes", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="yes", ]$white +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="yes", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$status + pSERG[pSERG$HOSPITALONSET=="yes", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="yes", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "yes", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$status + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$ageyears + pSERG[pSERG$HOSPITALONSET == "yes", ]$SEX)
## 
##   n= 106, number of events= 106 
## 
##                                                                  coef
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.07638
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.16562
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.48198
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.23556
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.24809
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.72974
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.01601
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.40781
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.02949
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                -0.25784
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017            1.07937
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent   0.84737
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                      1.61928
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear        1.26562
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                    0.78029
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology       2.07454
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy            1.01613
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                   1.50351
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                 0.97094
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                  0.77272
##                                                              se(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.23979
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.24964
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.24084
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.21482
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.22920
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.23838
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.26260
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.30050
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.01972
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.22674
##                                                                   z
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.319
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.663
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     2.001
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       1.097
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -1.082
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      3.061
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.061
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  1.357
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -1.495
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                -1.137
##                                                              Pr(>|z|)   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017            0.7501   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent   0.5070   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                      0.0454 * 
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear        0.2728   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                    0.2791   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology       0.0022 **
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy            0.9514   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                   0.1748   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                 0.1348   
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                  0.2555   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             1.0794
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.8474
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       1.6193
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         1.2656
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.7803
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        2.0745
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             1.0161
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    1.5035
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9709
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.7727
##                                                              exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017              0.9265
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.1801
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        0.6176
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          0.7901
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.2816
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         0.4820
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              0.9841
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     0.6651
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.0299
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    1.2941
##                                                              lower .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             0.6746
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.5195
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       1.0100
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.8307
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.4979
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        1.3002
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.6073
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.8343
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9341
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.4955
##                                                              upper .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017              1.727
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.382
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        2.596
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          1.928
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.223
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         3.310
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              1.700
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     2.710
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.009
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    1.205
## 
## Concordance= 0.618  (se = 0.034 )
## Rsquare= 0.17   (max possible= 0.999 )
## Likelihood ratio test= 19.79  on 10 df,   p=0.03
## Wald test            = 19.82  on 10 df,   p=0.03
## Score (logrank) test = 20.08  on 10 df,   p=0.03
# Time to first CI
summary(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   113.0   175.0   558.1   420.0  7200.0      55
sd(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0)
## [1] NA
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$CONTTIME.0) ~ 
##     1)
## 
##    55 observations deleted due to missingness 
##       n  events  median 0.95LCL 0.95UCL 
##      51      51     175     122     253
# Figure time to first CI
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")

# Time to first CI depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   120.0   186.0   562.3   487.5  7200.0      37
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0    90.5   135.0   551.1   326.5  6003.0      18
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017, rho = 1)
## 
## n=51, 55 observations deleted due to missingness.
## 
##                                                        N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017=0 32     15.6     17.3
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017=1 19     10.6      8.9
##                                                       (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017=0     0.172     0.756
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017=1     0.334     0.756
## 
##  Chisq= 0.8  on 1 degrees of freedom, p= 0.4
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.3845
# Figure time to first CI by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first CI
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="yes", ]$TYPESTATUS + 
                pSERG[pSERG$HOSPITALONSET=="yes", ]$day + pSERG[pSERG$HOSPITALONSET=="yes", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="yes", ]$white +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="yes", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$status + pSERG[pSERG$HOSPITALONSET=="yes", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="yes", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "yes", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$status + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$ageyears + pSERG[pSERG$HOSPITALONSET == "yes", ]$SEX)
## 
##   n= 51, number of events= 51 
##    (55 observations deleted due to missingness)
## 
##                                                                   coef
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.313739
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.574764
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.136634
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.103404
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.011430
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology     -0.089874
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy          -0.001939
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.868622
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.024956
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.080351
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           1.368532
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.562838
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     1.146409
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       1.108940
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.988635
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.914046
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.998063
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  2.383625
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.975353
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 1.083667
##                                                               se(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.363683
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.361937
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.353350
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.311759
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.345741
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.335300
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.454676
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.554866
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.031960
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.346770
##                                                                   z
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.863
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -1.588
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.387
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.332
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.033
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology     -0.268
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy          -0.004
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  1.565
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.781
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.232
##                                                              Pr(>|z|)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             0.388
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.112
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.699
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.740
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.974
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.789
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.997
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.117
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.435
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.817
## 
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             1.3685
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.5628
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       1.1464
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         1.1089
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.9886
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.9140
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.9981
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    2.3836
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9754
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   1.0837
##                                                              exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017              0.7307
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.7767
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        0.8723
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          0.9018
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.0115
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.0940
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              1.0019
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     0.4195
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.0253
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    0.9228
##                                                              lower .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             0.6709
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.2769
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.5735
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.6019
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.5020
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.4738
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.4094
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.8034
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9161
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.5492
##                                                              upper .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017              2.791
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.144
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        2.291
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          2.043
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.947
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.764
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              2.433
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     7.072
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.038
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    2.138
## 
## Concordance= 0.597  (se = 0.049 )
## Rsquare= 0.148   (max possible= 0.997 )
## Likelihood ratio test= 8.14  on 10 df,   p=0.6
## Wald test            = 8.1  on 10 df,   p=0.6
## Score (logrank) test = 8.45  on 10 df,   p=0.6
#### Recommendations and outliers in the hospital

# First BZD later than 20 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        72 |        34 | 
##           |     0.679 |     0.321 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  69 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        47 |        22 | 
##           |     0.681 |     0.319 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  37 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        25 |        12 | 
##           |     0.676 |     0.324 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore20min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstBZDmore20min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3934397 2.5974709
## sample estimates:
## odds ratio 
##   1.025226
# Difference adjusting for covariates within the first 20 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=20,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 20  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.423    -2.307     3.153 0.762
## RMST (arm=1)/(arm=0) 1.048     0.820     1.339 0.710
## RMTL (arm=1)/(arm=0) 0.964     0.706     1.317 0.819
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept           9.595    2.096  4.579 0.000     5.487    13.702
## arm                 0.423    1.393  0.303 0.762    -2.307     3.153
## TYPESTATUSnumeric  -0.905    1.552 -0.583 0.560    -3.948     2.137
## day                -1.626    1.429 -1.137 0.255    -4.427     1.176
## earlyacademicyear  -1.541    1.398 -1.103 0.270    -4.281     1.199
## white               0.860    1.509  0.570 0.569    -2.097     3.817
## structuraletiology -0.437    1.560 -0.280 0.779    -3.495     2.621
## priorepilepsy       2.258    1.680  1.344 0.179    -1.034     5.551
## status             -1.578    1.791 -0.881 0.378    -5.089     1.933
## ageyears            0.235    0.140  1.673 0.094    -0.040     0.510
## SEXnumeric          1.180    1.434  0.823 0.411    -1.630     3.990
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.255    0.199 11.358 0.000     9.532     6.460
## arm                 0.047    0.125  0.372 0.710     1.048     0.820
## TYPESTATUSnumeric  -0.087    0.150 -0.580 0.562     0.917     0.683
## day                -0.136    0.129 -1.050 0.294     0.873     0.677
## earlyacademicyear  -0.137    0.132 -1.040 0.299     0.872     0.674
## white               0.070    0.146  0.483 0.629     1.073     0.806
## structuraletiology -0.034    0.146 -0.232 0.817     0.967     0.726
## priorepilepsy       0.189    0.147  1.282 0.200     1.208     0.905
## status             -0.117    0.155 -0.757 0.449     0.889     0.657
## ageyears            0.020    0.012  1.665 0.096     1.020     0.996
## SEXnumeric          0.100    0.132  0.761 0.447     1.105     0.854
##                    upper .95
## intercept             14.065
## arm                    1.339
## TYPESTATUSnumeric      1.230
## day                    1.125
## earlyacademicyear      1.129
## white                  1.427
## structuraletiology     1.287
## priorepilepsy          1.612
## status                 1.205
## ageyears               1.045
## SEXnumeric             1.431
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.330    0.231 10.096 0.000    10.283     6.541
## arm                -0.036    0.159 -0.228 0.819     0.964     0.706
## TYPESTATUSnumeric   0.096    0.168  0.572 0.567     1.101     0.792
## day                 0.200    0.165  1.211 0.226     1.221     0.884
## earlyacademicyear   0.181    0.156  1.163 0.245     1.198     0.883
## white              -0.110    0.162 -0.679 0.497     0.896     0.651
## structuraletiology  0.057    0.171  0.333 0.739     1.059     0.757
## priorepilepsy      -0.285    0.215 -1.328 0.184     0.752     0.493
## status              0.224    0.231  0.972 0.331     1.251     0.796
## ageyears           -0.028    0.018 -1.603 0.109     0.972     0.939
## SEXnumeric         -0.144    0.160 -0.898 0.369     0.866     0.633
##                    upper .95
## intercept             16.166
## arm                    1.317
## TYPESTATUSnumeric      1.530
## day                    1.686
## earlyacademicyear      1.626
## white                  1.231
## structuraletiology     1.479
## priorepilepsy          1.146
## status                 1.966
## ageyears               1.006
## SEXnumeric             1.185
# First BZD later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        87 |        19 | 
##           |     0.821 |     0.179 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  69 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        55 |        14 | 
##           |     0.797 |     0.203 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  37 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        32 |         5 | 
##           |     0.865 |     0.135 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore40min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstBZDmore40min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 0.4385
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1586844 2.0307057
## sample estimates:
## odds ratio 
##  0.6165311
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.502    -5.650     4.646 0.848
## RMST (arm=1)/(arm=0)  0.988     0.708     1.379 0.945
## RMTL (arm=1)/(arm=0)  1.029     0.832     1.273 0.790
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          14.267    4.395  3.246 0.001     5.652    22.881
## arm                -0.502    2.627 -0.191 0.848    -5.650     4.646
## TYPESTATUSnumeric  -4.775    2.611 -1.829 0.067    -9.893     0.343
## day                -2.112    2.850 -0.741 0.459    -7.698     3.474
## earlyacademicyear  -2.608    2.741 -0.951 0.341    -7.981     2.764
## white               1.951    2.963  0.659 0.510    -3.855     7.758
## structuraletiology  0.249    3.056  0.081 0.935    -5.741     6.239
## priorepilepsy       2.770    3.493  0.793 0.428    -4.076     9.617
## status             -4.191    3.465 -1.209 0.227   -10.982     2.601
## ageyears            0.495    0.273  1.810 0.070    -0.041     1.031
## SEXnumeric          0.582    2.684  0.217 0.828    -4.678     5.843
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.628    0.295  8.906 0.000    13.841     7.763
## arm                -0.012    0.170 -0.069 0.945     0.988     0.708
## TYPESTATUSnumeric  -0.342    0.197 -1.737 0.082     0.710     0.483
## day                -0.109    0.180 -0.605 0.545     0.897     0.630
## earlyacademicyear  -0.163    0.182 -0.896 0.370     0.850     0.595
## white               0.110    0.201  0.549 0.583     1.117     0.753
## structuraletiology  0.028    0.197  0.142 0.887     1.028     0.699
## priorepilepsy       0.156    0.208  0.751 0.453     1.169     0.777
## status             -0.224    0.217 -1.035 0.301     0.799     0.523
## ageyears            0.030    0.016  1.849 0.065     1.030     0.998
## SEXnumeric          0.026    0.172  0.150 0.881     1.026     0.732
##                    upper .95
## intercept             24.679
## arm                    1.379
## TYPESTATUSnumeric      1.045
## day                    1.276
## earlyacademicyear      1.213
## white                  1.656
## structuraletiology     1.512
## priorepilepsy          1.759
## status                 1.222
## ageyears               1.064
## SEXnumeric             1.438
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.236    0.180 17.943 0.000    25.428    17.857
## arm                 0.029    0.108  0.267 0.790     1.029     0.832
## TYPESTATUSnumeric   0.188    0.103  1.821 0.069     1.206     0.986
## day                 0.098    0.120  0.814 0.416     1.103     0.872
## earlyacademicyear   0.111    0.113  0.977 0.328     1.117     0.895
## white              -0.088    0.121 -0.729 0.466     0.916     0.723
## structuraletiology -0.006    0.127 -0.048 0.962     0.994     0.776
## priorepilepsy      -0.125    0.157 -0.798 0.425     0.883     0.649
## status              0.193    0.154  1.254 0.210     1.213     0.897
## ageyears           -0.021    0.012 -1.718 0.086     0.979     0.955
## SEXnumeric         -0.030    0.111 -0.268 0.789     0.971     0.781
##                    upper .95
## intercept             36.210
## arm                    1.273
## TYPESTATUSnumeric      1.476
## day                    1.395
## earlyacademicyear      1.395
## white                  1.160
## structuraletiology     1.274
## priorepilepsy          1.200
## status                 1.641
## ageyears               1.003
## SEXnumeric             1.206
# First BZD later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        91 |        15 | 
##           |     0.858 |     0.142 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  69 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        59 |        10 | 
##           |     0.855 |     0.145 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  37 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        32 |         5 | 
##           |     0.865 |     0.135 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore60min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstBZDmore60min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.2271364 3.2802464
## sample estimates:
## odds ratio 
##  0.9225637
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.939    -8.180     6.302 0.799
## RMST (arm=1)/(arm=0)  0.974     0.654     1.449 0.895
## RMTL (arm=1)/(arm=0)  1.028     0.863     1.225 0.757
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          20.364    6.565  3.102 0.002     7.497    33.230
## arm                -0.939    3.694 -0.254 0.799    -8.180     6.302
## TYPESTATUSnumeric  -7.297    3.469 -2.103 0.035   -14.095    -0.498
## day                -2.587    4.110 -0.630 0.529   -10.643     5.468
## earlyacademicyear  -5.057    3.947 -1.281 0.200   -12.792     2.679
## white               1.567    4.359  0.360 0.719    -6.976    10.110
## structuraletiology  0.566    4.293  0.132 0.895    -7.848     8.980
## priorepilepsy       1.059    5.089  0.208 0.835    -8.915    11.034
## status             -5.692    4.615 -1.233 0.217   -14.737     3.353
## ageyears            0.663    0.398  1.663 0.096    -0.118     1.443
## SEXnumeric         -0.724    3.872 -0.187 0.852    -8.314     6.866
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.972    0.355  8.363 0.000    19.528     9.732
## arm                -0.027    0.203 -0.132 0.895     0.974     0.654
## TYPESTATUSnumeric  -0.454    0.235 -1.933 0.053     0.635     0.401
## day                -0.109    0.214 -0.507 0.612     0.897     0.589
## earlyacademicyear  -0.268    0.218 -1.228 0.219     0.765     0.499
## white               0.064    0.243  0.265 0.791     1.067     0.662
## structuraletiology  0.046    0.232  0.200 0.841     1.048     0.665
## priorepilepsy       0.043    0.251  0.169 0.866     1.043     0.638
## status             -0.271    0.255 -1.061 0.289     0.763     0.463
## ageyears            0.033    0.019  1.717 0.086     1.034     0.995
## SEXnumeric         -0.047    0.206 -0.226 0.821     0.954     0.638
##                    upper .95
## intercept             39.187
## arm                    1.449
## TYPESTATUSnumeric      1.006
## day                    1.365
## earlyacademicyear      1.173
## white                  1.718
## structuraletiology     1.651
## priorepilepsy          1.708
## status                 1.258
## ageyears               1.074
## SEXnumeric             1.429
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.671    0.162 22.610 0.000    39.276    28.572
## arm                 0.028    0.089  0.309 0.757     1.028     0.863
## TYPESTATUSnumeric   0.170    0.081  2.105 0.035     1.185     1.012
## day                 0.069    0.102  0.679 0.497     1.072     0.877
## earlyacademicyear   0.125    0.097  1.281 0.200     1.133     0.936
## white              -0.043    0.106 -0.405 0.685     0.958     0.779
## structuraletiology -0.011    0.105 -0.106 0.916     0.989     0.806
## priorepilepsy      -0.029    0.130 -0.223 0.824     0.971     0.753
## status              0.146    0.116  1.258 0.208     1.157     0.922
## ageyears           -0.017    0.010 -1.593 0.111     0.984     0.964
## SEXnumeric          0.015    0.095  0.161 0.872     1.015     0.844
##                    upper .95
## intercept             53.991
## arm                    1.225
## TYPESTATUSnumeric      1.388
## day                    1.309
## earlyacademicyear      1.371
## white                  1.179
## structuraletiology     1.214
## priorepilepsy          1.254
## status                 1.453
## ageyears               1.004
## SEXnumeric             1.222
# First non-BZD ASM later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        53 |        53 | 
##           |     0.500 |     0.500 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  69 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        33 |        36 | 
##           |     0.478 |     0.522 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  37 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        20 |        17 | 
##           |     0.541 |     0.459 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore40min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstASMmore40min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 0.6839
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3232202 1.8703559
## sample estimates:
## odds ratio 
##   0.781013
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.093    -4.175     3.989 0.964
## RMST (arm=1)/(arm=0)  0.995     0.869     1.140 0.943
## RMTL (arm=1)/(arm=0)  0.985     0.648     1.498 0.945
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          28.139    3.408  8.257 0.000    21.459    34.818
## arm                -0.093    2.083 -0.045 0.964    -4.175     3.989
## TYPESTATUSnumeric   2.906    2.489  1.168 0.243    -1.972     7.784
## day                -4.501    2.169 -2.076 0.038    -8.751    -0.251
## earlyacademicyear   0.149    2.135  0.070 0.944    -4.035     4.332
## white               3.417    2.224  1.536 0.125    -0.943     7.776
## structuraletiology -3.291    2.275 -1.447 0.148    -7.750     1.168
## priorepilepsy       1.592    2.501  0.637 0.524    -3.309     6.493
## status             -2.933    2.832 -1.036 0.300    -8.483     2.617
## ageyears            0.446    0.211  2.110 0.035     0.032     0.860
## SEXnumeric          0.332    2.303  0.144 0.885    -4.183     4.846
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.333    0.115 28.884 0.000    28.029    22.355
## arm                -0.005    0.069 -0.072 0.943     0.995     0.869
## TYPESTATUSnumeric   0.096    0.080  1.196 0.232     1.101     0.940
## day                -0.149    0.073 -2.048 0.041     0.862     0.748
## earlyacademicyear   0.010    0.071  0.133 0.894     1.010     0.878
## white               0.117    0.077  1.527 0.127     1.124     0.967
## structuraletiology -0.113    0.079 -1.421 0.155     0.893     0.765
## priorepilepsy       0.049    0.079  0.617 0.537     1.050     0.899
## status             -0.095    0.093 -1.021 0.307     0.910     0.758
## ageyears            0.014    0.007  2.091 0.036     1.014     1.001
## SEXnumeric          0.010    0.077  0.124 0.901     1.010     0.869
##                    upper .95
## intercept             35.143
## arm                    1.140
## TYPESTATUSnumeric      1.289
## day                    0.994
## earlyacademicyear      1.161
## white                  1.307
## structuraletiology     1.044
## priorepilepsy          1.227
## status                 1.091
## ageyears               1.028
## SEXnumeric             1.173
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.436    0.353  6.911 0.000    11.432     5.728
## arm                -0.015    0.214 -0.068 0.945     0.985     0.648
## TYPESTATUSnumeric  -0.304    0.297 -1.026 0.305     0.738     0.412
## day                 0.477    0.239  1.995 0.046     1.612     1.008
## earlyacademicyear   0.033    0.220  0.152 0.879     1.034     0.672
## white              -0.321    0.225 -1.422 0.155     0.726     0.467
## structuraletiology  0.307    0.216  1.422 0.155     1.359     0.890
## priorepilepsy      -0.198    0.328 -0.605 0.545     0.820     0.431
## status              0.337    0.335  1.005 0.315     1.400     0.726
## ageyears           -0.055    0.029 -1.936 0.053     0.946     0.895
## SEXnumeric         -0.052    0.235 -0.220 0.826     0.950     0.599
##                    upper .95
## intercept             22.813
## arm                    1.498
## TYPESTATUSnumeric      1.320
## day                    2.576
## earlyacademicyear      1.592
## white                  1.129
## structuraletiology     2.074
## priorepilepsy          1.559
## status                 2.698
## ageyears               1.001
## SEXnumeric             1.506
# First non-BZD ASM later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        70 |        36 | 
##           |     0.660 |     0.340 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  69 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        45 |        24 | 
##           |     0.652 |     0.348 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  37 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        25 |        12 | 
##           |     0.676 |     0.324 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore60min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstASMmore60min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 0.8334
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3478949 2.2616493
## sample estimates:
## odds ratio 
##  0.9008993
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -2.401    -9.368     4.566 0.499
## RMST (arm=1)/(arm=0)  0.934     0.778     1.120 0.462
## RMTL (arm=1)/(arm=0)  1.094     0.787     1.520 0.592
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          37.865    5.776  6.556 0.000    26.545    49.185
## arm                -2.401    3.555 -0.675 0.499    -9.368     4.566
## TYPESTATUSnumeric   1.431    4.331  0.330 0.741    -7.058     9.920
## day                -8.797    3.671 -2.396 0.017   -15.992    -1.602
## earlyacademicyear   1.283    3.637  0.353 0.724    -5.846     8.412
## white               5.688    3.792  1.500 0.134    -1.744    13.120
## structuraletiology -7.786    3.679 -2.116 0.034   -14.997    -0.574
## priorepilepsy       1.237    4.340  0.285 0.776    -7.269     9.744
## status             -5.466    4.810 -1.136 0.256   -14.894     3.961
## ageyears            0.695    0.355  1.961 0.050     0.000     1.391
## SEXnumeric          2.346    3.818  0.614 0.539    -5.138     9.830
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.624    0.152 23.802 0.000    37.479    27.810
## arm                -0.068    0.093 -0.736 0.462     0.934     0.778
## TYPESTATUSnumeric   0.040    0.111  0.360 0.719     1.041     0.837
## day                -0.230    0.096 -2.406 0.016     0.795     0.659
## earlyacademicyear   0.044    0.096  0.453 0.651     1.045     0.865
## white               0.156    0.103  1.512 0.131     1.169     0.955
## structuraletiology -0.217    0.103 -2.099 0.036     0.805     0.658
## priorepilepsy       0.026    0.108  0.240 0.810     1.026     0.831
## status             -0.145    0.127 -1.139 0.255     0.865     0.675
## ageyears            0.017    0.009  1.956 0.051     1.017     1.000
## SEXnumeric          0.061    0.098  0.616 0.538     1.062     0.876
##                    upper .95
## intercept             50.511
## arm                    1.120
## TYPESTATUSnumeric      1.294
## day                    0.958
## earlyacademicyear      1.261
## white                  1.431
## structuraletiology     0.986
## priorepilepsy          1.268
## status                 1.110
## ageyears               1.034
## SEXnumeric             1.289
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.063    0.275 11.124 0.000    21.388    12.468
## arm                 0.090    0.168  0.535 0.592     1.094     0.787
## TYPESTATUSnumeric  -0.055    0.212 -0.259 0.796     0.947     0.625
## day                 0.416    0.189  2.205 0.027     1.516     1.047
## earlyacademicyear  -0.028    0.171 -0.164 0.870     0.972     0.695
## white              -0.244    0.176 -1.392 0.164     0.783     0.555
## structuraletiology  0.328    0.164  1.995 0.046     1.388     1.006
## priorepilepsy      -0.069    0.234 -0.297 0.767     0.933     0.590
## status              0.253    0.236  1.071 0.284     1.288     0.811
## ageyears           -0.038    0.020 -1.849 0.065     0.963     0.925
## SEXnumeric         -0.111    0.183 -0.608 0.544     0.895     0.625
##                    upper .95
## intercept             36.688
## arm                    1.520
## TYPESTATUSnumeric      1.434
## day                    2.193
## earlyacademicyear      1.360
## white                  1.105
## structuraletiology     1.914
## priorepilepsy          1.476
## status                 2.045
## ageyears               1.002
## SEXnumeric             1.281
# First non-BZD ASM later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        89 |        17 | 
##           |     0.840 |     0.160 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  69 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        59 |        10 | 
##           |     0.855 |     0.145 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  37 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        30 |         7 | 
##           |     0.811 |     0.189 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore120min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstASMmore120min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 0.586
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4005423 4.4694842
## sample estimates:
## odds ratio 
##   1.372337
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=120,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -1.918   -16.262    12.426 0.793
## RMST (arm=1)/(arm=0)  0.958     0.735     1.249 0.751
## RMTL (arm=1)/(arm=0)  1.024     0.821     1.277 0.835
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept           56.481   12.457  4.534 0.000    32.065    80.897
## arm                 -1.918    7.319 -0.262 0.793   -16.262    12.426
## TYPESTATUSnumeric  -10.061    7.903 -1.273 0.203   -25.550     5.428
## day                -16.775    7.358 -2.280 0.023   -31.197    -2.352
## earlyacademicyear   -1.449    7.715 -0.188 0.851   -16.571    13.673
## white                8.395    7.577  1.108 0.268    -6.455    23.245
## structuraletiology -16.673    7.061 -2.361 0.018   -30.512    -2.833
## priorepilepsy        1.402    9.305  0.151 0.880   -16.834    19.639
## status              -9.522   10.218 -0.932 0.351   -29.549    10.504
## ageyears             1.428    0.722  1.979 0.048     0.013     2.843
## SEXnumeric           6.520    7.583  0.860 0.390    -8.342    21.382
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.018    0.235 17.103 0.000    55.600    35.083
## arm                -0.043    0.135 -0.317 0.751     0.958     0.735
## TYPESTATUSnumeric  -0.194    0.162 -1.203 0.229     0.823     0.600
## day                -0.310    0.136 -2.278 0.023     0.734     0.562
## earlyacademicyear  -0.009    0.151 -0.057 0.955     0.991     0.737
## white               0.169    0.150  1.128 0.259     1.185     0.882
## structuraletiology -0.347    0.147 -2.357 0.018     0.707     0.530
## priorepilepsy       0.005    0.168  0.029 0.977     1.005     0.724
## status             -0.176    0.199 -0.883 0.377     0.839     0.568
## ageyears            0.024    0.012  1.974 0.048     1.024     1.000
## SEXnumeric          0.120    0.138  0.873 0.383     1.128     0.861
##                    upper .95
## intercept             88.116
## arm                    1.249
## TYPESTATUSnumeric      1.130
## day                    0.958
## earlyacademicyear      1.333
## white                  1.590
## structuraletiology     0.943
## priorepilepsy          1.396
## status                 1.239
## ageyears               1.049
## SEXnumeric             1.477
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.139    0.191 21.697 0.000    62.728    43.161
## arm                 0.024    0.113  0.209 0.835     1.024     0.821
## TYPESTATUSnumeric   0.151    0.115  1.310 0.190     1.162     0.928
## day                 0.260    0.120  2.170 0.030     1.296     1.025
## earlyacademicyear   0.033    0.116  0.286 0.775     1.034     0.824
## white              -0.121    0.113 -1.071 0.284     0.886     0.709
## structuraletiology  0.235    0.104  2.252 0.024     1.265     1.031
## priorepilepsy      -0.031    0.150 -0.208 0.835     0.969     0.722
## status              0.147    0.158  0.931 0.352     1.158     0.850
## ageyears           -0.024    0.013 -1.894 0.058     0.977     0.953
## SEXnumeric         -0.101    0.118 -0.852 0.394     0.904     0.718
##                    upper .95
## intercept             91.166
## arm                    1.277
## TYPESTATUSnumeric      1.456
## day                    1.639
## earlyacademicyear      1.297
## white                  1.106
## structuraletiology     1.553
## priorepilepsy          1.301
## status                 1.579
## ageyears               1.001
## SEXnumeric             1.140
# First CI later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  51 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         6 |        45 | 
##           |     0.118 |     0.882 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  32 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         4 |        28 | 
##           |     0.125 |     0.875 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  19 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         2 |        17 | 
##           |     0.105 |     0.895 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore60min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstCImore60min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.1537173 14.7214553
## sample estimates:
## odds ratio 
##   1.209752
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=60,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.759    -9.410     7.893 0.864
## RMST (arm=1)/(arm=0)  0.986     0.843     1.153 0.856
## RMTL (arm=1)/(arm=0)  0.264     0.041     1.694 0.160
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          54.624    4.340 12.585 0.000    46.117    63.131
## arm                -0.759    4.414 -0.172 0.864    -9.410     7.893
## TYPESTATUSnumeric   3.860    3.431  1.125 0.261    -2.864    10.585
## day                -6.700    3.667 -1.827 0.068   -13.888     0.488
## earlyacademicyear   1.881    3.206  0.587 0.557    -4.403     8.165
## white               1.302    4.130  0.315 0.753    -6.793     9.396
## structuraletiology -2.124    4.832 -0.440 0.660   -11.594     7.346
## priorepilepsy       4.855    3.240  1.499 0.134    -1.495    11.205
## status              0.565    2.090  0.270 0.787    -3.532     4.662
## ageyears            0.255    0.279  0.914 0.361    -0.292     0.803
## SEXnumeric          1.687    4.715  0.358 0.720    -7.553    10.927
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.997    0.081 49.232 0.000    54.442    46.433
## arm                -0.014    0.080 -0.181 0.856     0.986     0.843
## TYPESTATUSnumeric   0.069    0.063  1.099 0.272     1.072     0.947
## day                -0.119    0.070 -1.692 0.091     0.888     0.774
## earlyacademicyear   0.035    0.059  0.587 0.557     1.035     0.922
## white               0.026    0.079  0.327 0.744     1.026     0.879
## structuraletiology -0.039    0.090 -0.428 0.669     0.962     0.806
## priorepilepsy       0.083    0.058  1.425 0.154     1.087     0.969
## status              0.011    0.038  0.303 0.762     1.012     0.939
## ageyears            0.004    0.005  0.878 0.380     1.004     0.994
## SEXnumeric          0.029    0.085  0.343 0.732     1.030     0.871
##                    upper .95
## intercept             63.832
## arm                    1.153
## TYPESTATUSnumeric      1.213
## day                    1.019
## earlyacademicyear      1.162
## white                  1.197
## structuraletiology     1.148
## priorepilepsy          1.219
## status                 1.089
## ageyears               1.015
## SEXnumeric             1.217
## 
## 
## Model summary (ratio of time-lost) 
##                       coef se(coef)       z     p    exp(coef)
## intercept          -21.893    3.808  -5.749 0.000 0.000000e+00
## arm                 -1.330    0.948  -1.404 0.160 2.640000e-01
## TYPESTATUSnumeric   -3.307    1.997  -1.656 0.098 3.700000e-02
## day                 23.591    2.769   8.521 0.000 1.760421e+10
## earlyacademicyear    1.008    1.121   0.899 0.369 2.740000e+00
## white                2.979    1.805   1.651 0.099 1.967000e+01
## structuraletiology   3.216    1.854   1.735 0.083 2.493600e+01
## priorepilepsy      -20.872    1.390 -15.011 0.000 0.000000e+00
## status              -0.251    1.299  -0.194 0.846 7.780000e-01
## ageyears            -0.187    0.118  -1.582 0.114 8.300000e-01
## SEXnumeric          -1.582    0.977  -1.618 0.106 2.060000e-01
##                       lower .95    upper .95
## intercept                 0.000 0.000000e+00
## arm                       0.041 1.694000e+00
## TYPESTATUSnumeric         0.001 1.834000e+00
## day                77441672.292 4.001829e+12
## earlyacademicyear         0.304 2.466700e+01
## white                     0.572 6.760250e+02
## structuraletiology        0.659 9.433340e+02
## priorepilepsy             0.000 0.000000e+00
## status                    0.061 9.915000e+00
## ageyears                  0.658 1.046000e+00
## SEXnumeric                0.030 1.396000e+00
# First CI later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  51 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        17 |        34 | 
##           |     0.333 |     0.667 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  32 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         9 |        23 | 
##           |     0.281 |     0.719 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  19 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         8 |        11 | 
##           |     0.421 |     0.579 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore120min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstCImore120min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 0.3652
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1395128 2.1093868
## sample estimates:
## odds ratio 
##  0.5448555
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=120,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -7.833   -27.168    11.502 0.427
## RMST (arm=1)/(arm=0)  0.926     0.764     1.122 0.431
## RMTL (arm=1)/(arm=0)  1.486     0.473     4.669 0.498
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          103.224   10.846  9.517 0.000    81.966   124.482
## arm                 -7.833    9.865 -0.794 0.427   -27.168    11.502
## TYPESTATUSnumeric   10.915    8.485  1.286 0.198    -5.715    27.545
## day                -12.174    8.969 -1.357 0.175   -29.753     5.405
## earlyacademicyear    4.246    8.321  0.510 0.610   -12.063    20.555
## white               -2.149    9.744 -0.221 0.825   -21.247    16.948
## structuraletiology  -6.228   11.043 -0.564 0.573   -27.872    15.417
## priorepilepsy        6.163    9.201  0.670 0.503   -11.872    24.197
## status               1.701    8.487  0.200 0.841   -14.934    18.336
## ageyears             0.957    0.678  1.412 0.158    -0.371     2.285
## SEXnumeric           4.400   10.040  0.438 0.661   -15.278    24.077
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.632    0.107 43.148 0.000   102.719    83.229
## arm                -0.077    0.098 -0.788 0.431     0.926     0.764
## TYPESTATUSnumeric   0.107    0.083  1.276 0.202     1.112     0.945
## day                -0.117    0.091 -1.284 0.199     0.889     0.744
## earlyacademicyear   0.043    0.080  0.531 0.596     1.044     0.891
## white              -0.018    0.098 -0.181 0.856     0.982     0.810
## structuraletiology -0.061    0.111 -0.549 0.583     0.941     0.757
## priorepilepsy       0.056    0.089  0.634 0.526     1.058     0.889
## status              0.018    0.080  0.226 0.821     1.018     0.870
## ageyears            0.009    0.007  1.370 0.171     1.009     0.996
## SEXnumeric          0.041    0.098  0.420 0.674     1.042     0.860
##                    upper .95
## intercept            126.773
## arm                    1.122
## TYPESTATUSnumeric      1.310
## day                    1.064
## earlyacademicyear      1.222
## white                  1.191
## structuraletiology     1.169
## priorepilepsy          1.259
## status                 1.191
## ageyears               1.022
## SEXnumeric             1.263
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.540    0.762  3.334 0.001    12.679     2.849
## arm                 0.396    0.584  0.678 0.498     1.486     0.473
## TYPESTATUSnumeric  -0.708    0.702 -1.009 0.313     0.493     0.125
## day                 0.847    0.563  1.505 0.132     2.333     0.774
## earlyacademicyear  -0.205    0.667 -0.307 0.759     0.815     0.220
## white               0.357    0.537  0.664 0.507     1.429     0.498
## structuraletiology  0.378    0.659  0.574 0.566     1.459     0.401
## priorepilepsy      -0.492    0.669 -0.736 0.462     0.611     0.165
## status             -0.114    0.790 -0.144 0.885     0.892     0.190
## ageyears           -0.071    0.054 -1.304 0.192     0.932     0.838
## SEXnumeric         -0.316    0.580 -0.545 0.586     0.729     0.234
##                    upper .95
## intercept             56.429
## arm                    4.669
## TYPESTATUSnumeric      1.949
## day                    7.026
## earlyacademicyear      3.013
## white                  4.097
## structuraletiology     5.311
## priorepilepsy          2.267
## status                 4.200
## ageyears               1.036
## SEXnumeric             2.272
# First CI later than 240 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  51 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        33 |        18 | 
##           |     0.647 |     0.353 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  32 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        19 |        13 | 
##           |     0.594 |     0.406 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  19 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        14 |         5 | 
##           |     0.737 |     0.263 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore240min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstCImore240min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 0.3727
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1187173 2.0687742
## sample estimates:
## odds ratio 
##  0.5285584
# Difference adjusting for covariates within the first 240 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=240,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 240  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                         Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -24.810   -69.836    20.216 0.280
## RMST (arm=1)/(arm=0)   0.853     0.639     1.138 0.280
## RMTL (arm=1)/(arm=0)   1.357     0.747     2.463 0.316
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          182.039   30.490  5.970 0.000   122.280   241.799
## arm                -24.810   22.973 -1.080 0.280   -69.836    20.216
## TYPESTATUSnumeric   -3.740   21.876 -0.171 0.864   -46.615    39.136
## day                -24.992   23.305 -1.072 0.284   -70.669    20.686
## earlyacademicyear    7.286   21.852  0.333 0.739   -35.542    50.114
## white              -16.266   23.180 -0.702 0.483   -61.698    29.167
## structuraletiology   3.716   25.839  0.144 0.886   -46.927    54.359
## priorepilepsy      -11.197   30.601 -0.366 0.714   -71.174    48.779
## status              -9.737   29.021 -0.336 0.737   -66.617    47.143
## ageyears             2.953    1.700  1.738 0.082    -0.378     6.285
## SEXnumeric           0.608   22.852  0.027 0.979   -44.182    45.397
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           5.203    0.186 28.029 0.000   181.853   126.389
## arm                -0.159    0.147 -1.080 0.280     0.853     0.639
## TYPESTATUSnumeric  -0.016    0.143 -0.113 0.910     0.984     0.744
## day                -0.155    0.146 -1.065 0.287     0.856     0.644
## earlyacademicyear   0.048    0.134  0.360 0.719     1.049     0.807
## white              -0.098    0.139 -0.702 0.482     0.907     0.690
## structuraletiology  0.023    0.160  0.146 0.884     1.024     0.748
## priorepilepsy      -0.076    0.190 -0.401 0.689     0.927     0.638
## status             -0.052    0.186 -0.278 0.781     0.950     0.660
## ageyears            0.017    0.010  1.715 0.086     1.018     0.998
## SEXnumeric          0.006    0.138  0.047 0.962     1.007     0.768
##                    upper .95
## intercept            261.657
## arm                    1.138
## TYPESTATUSnumeric      1.301
## day                    1.139
## earlyacademicyear      1.364
## white                  1.192
## structuraletiology     1.402
## priorepilepsy          1.345
## status                 1.367
## ageyears               1.038
## SEXnumeric             1.319
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.051    0.415  9.754 0.000    57.436    25.451
## arm                 0.305    0.304  1.002 0.316     1.357     0.747
## TYPESTATUSnumeric   0.082    0.262  0.313 0.755     1.085     0.649
## day                 0.332    0.315  1.054 0.292     1.394     0.752
## earlyacademicyear  -0.080    0.305 -0.264 0.792     0.923     0.508
## white               0.225    0.334  0.674 0.500     1.253     0.651
## structuraletiology -0.042    0.337 -0.126 0.900     0.958     0.495
## priorepilepsy       0.120    0.405  0.296 0.768     1.127     0.509
## status              0.162    0.367  0.443 0.658     1.176     0.573
## ageyears           -0.044    0.027 -1.622 0.105     0.957     0.908
## SEXnumeric          0.005    0.322  0.017 0.987     1.005     0.535
##                    upper .95
## intercept            129.617
## arm                    2.463
## TYPESTATUSnumeric      1.815
## day                    2.583
## earlyacademicyear      1.676
## white                  2.412
## structuraletiology     1.854
## priorepilepsy          2.494
## status                 2.413
## ageyears               1.009
## SEXnumeric             1.891

Time to treatment sensitivity analysis 2: Only initial centers

# Reduce the database to only centers already in pSERG during 2011-2013
pSERG$center[grepl("Baylor", pSERG$PATIENT_LABEL)] <- "Bay"
pSERG$center[grepl("BCCH", pSERG$PATIENT_LABEL)] <- "BCCH"
pSERG$center[grepl("CCHMC", pSERG$PATIENT_LABEL)] <- "CCHMC"
pSERG$center[grepl("CHB", pSERG$PATIENT_LABEL)] <- "CHB"
pSERG$center[grepl("Chicago", pSERG$PATIENT_LABEL)] <- "Chicago"
pSERG$center[grepl("CHOP", pSERG$PATIENT_LABEL)] <- "CHOP"
pSERG$center[grepl("CNMC", pSERG$PATIENT_LABEL)] <- "CNMC"
pSERG$center[grepl("Colorado", pSERG$PATIENT_LABEL)] <- "Colorado"
pSERG$center[grepl("Duke", pSERG$PATIENT_LABEL)] <- "Duke"
pSERG$center[grepl("Mayo", pSERG$PATIENT_LABEL)] <- "Mayo"
pSERG$center[grepl("MCW", pSERG$PATIENT_LABEL)] <- "MCW"
pSERG$center[grepl("NCH", pSERG$PATIENT_LABEL)] <- "NCH"
pSERG$center[grepl("NYU", pSERG$PATIENT_LABEL)] <- "NYU"
pSERG$center[grepl("OHSU", pSERG$PATIENT_LABEL)] <- "OHSU"
pSERG$center[grepl("Phoenix", pSERG$PATIENT_LABEL)] <- "Phoenix"
pSERG$center[grepl("Seattle", pSERG$PATIENT_LABEL)] <- "Seattle"
pSERG$center[grepl("UVA", pSERG$PATIENT_LABEL)] <- "UVA"
pSERG$center[grepl("WUSTL", pSERG$PATIENT_LABEL)] <- "WUSTL"
pSERG <- pSERG[pSERG$center %in% unique(pSERG[pSERG$yearSE==2011 | pSERG$yearSE==2012 | pSERG$yearSE==2013, ]$center), ]

# Awareness in this new dataset
CrossTable(pSERG$awareness)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  268 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       150 |       118 | 
##           |     0.560 |     0.440 | 
##           |-----------|-----------|
## 
## 
## 
## 
## ALL PATIENTS




# Time to first BZD
summary(pSERG$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   20.00   56.67   45.00 1264.00
sd(pSERG$BZDTIME.0)
## [1] 134.0915
survfit(Surv(pSERG$BZDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG$BZDTIME.0) ~ 1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##     268     268      20      15      23
# Figure time to first BZD
plot(survfit(Surv(pSERG$BZDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")

# Time to first BZD depending on awareness
summary(pSERG[which(pSERG$awareness == 0), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   20.00   55.63   53.75  720.00
summary(pSERG[which(pSERG$awareness == 1), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   19.00   57.99   38.00 1264.00
survdiff(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho = 1)
## 
##                     N Observed Expected (O-E)^2/E (O-E)^2/V
## pSERG$awareness=0 150     76.5     80.6     0.207     0.763
## pSERG$awareness=1 118     63.2     59.1     0.283     0.763
## 
##  Chisq= 0.8  on 1 degrees of freedom, p= 0.4
pchisq(survdiff(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.3824629
# Figure time to first BZD by awareness
plot(survfit(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first BZD
summary(coxph(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + pSERG$HOSPITALONSET + 
                pSERG$day + pSERG$earlyacademicyear + pSERG$white +
                pSERG$structuraletiology + pSERG$priorepilepsy +
                pSERG$status + pSERG$ageyears + pSERG$SEX))
## Call:
## coxph(formula = Surv(pSERG$BZDTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + 
##     pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + 
##     pSERG$white + pSERG$structuraletiology + pSERG$priorepilepsy + 
##     pSERG$status + pSERG$ageyears + pSERG$SEX)
## 
##   n= 268, number of events= 268 
## 
##                                   coef exp(coef)  se(coef)      z Pr(>|z|)
## pSERG$awareness               0.071287  1.073889  0.126344  0.564 0.572596
## pSERG$TYPESTATUSintermittent -0.386844  0.679197  0.139448 -2.774 0.005535
## pSERG$HOSPITALONSETyes        0.534269  1.706201  0.141619  3.773 0.000162
## pSERG$day                     0.068962  1.071396  0.127855  0.539 0.589626
## pSERG$earlyacademicyear       0.225338  1.252746  0.124845  1.805 0.071083
## pSERG$white                   0.088748  1.092805  0.132925  0.668 0.504354
## pSERG$structuraletiology      0.057031  1.058688  0.147905  0.386 0.699799
## pSERG$priorepilepsy           0.026083  1.026427  0.138248  0.189 0.850351
## pSERG$status                  0.373708  1.453113  0.173984  2.148 0.031718
## pSERG$ageyears               -0.003736  0.996271  0.012386 -0.302 0.762929
## pSERG$SEXmale                 0.066437  1.068694  0.127616  0.521 0.602644
##                                 
## pSERG$awareness                 
## pSERG$TYPESTATUSintermittent ** 
## pSERG$HOSPITALONSETyes       ***
## pSERG$day                       
## pSERG$earlyacademicyear      .  
## pSERG$white                     
## pSERG$structuraletiology        
## pSERG$priorepilepsy             
## pSERG$status                 *  
## pSERG$ageyears                  
## pSERG$SEXmale                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                              exp(coef) exp(-coef) lower .95 upper .95
## pSERG$awareness                 1.0739     0.9312    0.8383    1.3756
## pSERG$TYPESTATUSintermittent    0.6792     1.4723    0.5168    0.8927
## pSERG$HOSPITALONSETyes          1.7062     0.5861    1.2927    2.2520
## pSERG$day                       1.0714     0.9334    0.8339    1.3765
## pSERG$earlyacademicyear         1.2527     0.7982    0.9808    1.6000
## pSERG$white                     1.0928     0.9151    0.8422    1.4180
## pSERG$structuraletiology        1.0587     0.9446    0.7923    1.4147
## pSERG$priorepilepsy             1.0264     0.9743    0.7828    1.3459
## pSERG$status                    1.4531     0.6882    1.0332    2.0436
## pSERG$ageyears                  0.9963     1.0037    0.9724    1.0208
## pSERG$SEXmale                   1.0687     0.9357    0.8322    1.3724
## 
## Concordance= 0.618  (se = 0.022 )
## Rsquare= 0.117   (max possible= 1 )
## Likelihood ratio test= 33.22  on 11 df,   p=5e-04
## Wald test            = 34.76  on 11 df,   p=3e-04
## Score (logrank) test = 35.44  on 11 df,   p=2e-04
# Time to first non-BZD AED
summary(pSERG$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    35.0    65.5   153.2   150.8  1800.0
sd(pSERG$AEDTIME.0)
## [1] 246.9072
survfit(Surv(pSERG$AEDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG$AEDTIME.0) ~ 1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##   268.0   268.0    65.5    60.0    77.0
# Figure time to first non-BZD AED
plot(survfit(Surv(pSERG$AEDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")

# Time to first non-BZD AED depending on awareness
summary(pSERG[which(pSERG$awareness == 0), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    5.00   34.25   66.50  154.97  160.00 1800.00
summary(pSERG[which(pSERG$awareness == 1), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    38.5    65.5   151.0   149.8  1419.0
survdiff(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho = 1)
## 
##                     N Observed Expected (O-E)^2/E (O-E)^2/V
## pSERG$awareness=0 150     76.0     75.7   0.00127   0.00433
## pSERG$awareness=1 118     59.5     59.8   0.00160   0.00433
## 
##  Chisq= 0  on 1 degrees of freedom, p= 0.9
pchisq(survdiff(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.9475229
# Figure time to first non-BZD AED by awareness
plot(survfit(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first non-BZD AED
summary(coxph(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + pSERG$HOSPITALONSET + 
                pSERG$day + pSERG$earlyacademicyear + pSERG$white +
                pSERG$structuraletiology + pSERG$priorepilepsy +
                pSERG$status + pSERG$ageyears + pSERG$SEX))
## Call:
## coxph(formula = Surv(pSERG$AEDTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + 
##     pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + 
##     pSERG$white + pSERG$structuraletiology + pSERG$priorepilepsy + 
##     pSERG$status + pSERG$ageyears + pSERG$SEX)
## 
##   n= 268, number of events= 268 
## 
##                                  coef exp(coef) se(coef)      z Pr(>|z|)
## pSERG$awareness               0.01401   1.01411  0.12583  0.111   0.9113
## pSERG$TYPESTATUSintermittent -0.55876   0.57192  0.13948 -4.006 6.17e-05
## pSERG$HOSPITALONSETyes        0.86300   2.37026  0.14291  6.039 1.55e-09
## pSERG$day                     0.25802   1.29436  0.13054  1.977   0.0481
## pSERG$earlyacademicyear       0.11097   1.11736  0.12516  0.887   0.3753
## pSERG$white                   0.02929   1.02972  0.12918  0.227   0.8207
## pSERG$structuraletiology      0.18535   1.20364  0.14530  1.276   0.2021
## pSERG$priorepilepsy           0.09298   1.09744  0.14163  0.657   0.5115
## pSERG$status                  0.20088   1.22247  0.17296  1.161   0.2455
## pSERG$ageyears               -0.02759   0.97279  0.01223 -2.256   0.0241
## pSERG$SEXmale                 0.04745   1.04859  0.12977  0.366   0.7146
##                                 
## pSERG$awareness                 
## pSERG$TYPESTATUSintermittent ***
## pSERG$HOSPITALONSETyes       ***
## pSERG$day                    *  
## pSERG$earlyacademicyear         
## pSERG$white                     
## pSERG$structuraletiology        
## pSERG$priorepilepsy             
## pSERG$status                    
## pSERG$ageyears               *  
## pSERG$SEXmale                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                              exp(coef) exp(-coef) lower .95 upper .95
## pSERG$awareness                 1.0141     0.9861    0.7925    1.2978
## pSERG$TYPESTATUSintermittent    0.5719     1.7485    0.4351    0.7517
## pSERG$HOSPITALONSETyes          2.3703     0.4219    1.7912    3.1364
## pSERG$day                       1.2944     0.7726    1.0022    1.6718
## pSERG$earlyacademicyear         1.1174     0.8950    0.8743    1.4280
## pSERG$white                     1.0297     0.9711    0.7994    1.3264
## pSERG$structuraletiology        1.2036     0.8308    0.9054    1.6002
## pSERG$priorepilepsy             1.0974     0.9112    0.8314    1.4486
## pSERG$status                    1.2225     0.8180    0.8710    1.7158
## pSERG$ageyears                  0.9728     1.0280    0.9497    0.9964
## pSERG$SEXmale                   1.0486     0.9537    0.8131    1.3523
## 
## Concordance= 0.647  (se = 0.021 )
## Rsquare= 0.191   (max possible= 1 )
## Likelihood ratio test= 56.88  on 11 df,   p=4e-08
## Wald test            = 58.87  on 11 df,   p=2e-08
## Score (logrank) test = 60.39  on 11 df,   p=8e-09
# Time to first CI
summary(pSERG$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   122.0   206.0   523.7   612.5  7200.0     149
sd(pSERG$CONTTIME.0)
## [1] NA
survfit(Surv(pSERG$CONTTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG$CONTTIME.0) ~ 1)
## 
##    149 observations deleted due to missingness 
##       n  events  median 0.95LCL 0.95UCL 
##     119     119     206     165     300
# Figure time to first CI
plot(survfit(Surv(pSERG$CONTTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")

# Time to first CI depending on awareness
summary(pSERG[which(pSERG$awareness == 0), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   123.5   180.0   496.2   539.0  4320.0      83
summary(pSERG[which(pSERG$awareness == 1), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    45.0   122.0   212.0   559.1   660.5  7200.0      66
survdiff(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, 
##     rho = 1)
## 
## n=119, 149 observations deleted due to missingness.
## 
##                    N Observed Expected (O-E)^2/E (O-E)^2/V
## pSERG$awareness=0 67     34.5     33.3    0.0440     0.148
## pSERG$awareness=1 52     25.7     26.9    0.0544     0.148
## 
##  Chisq= 0.1  on 1 degrees of freedom, p= 0.7
pchisq(survdiff(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.7006702
# Figure time to first CI by awareness
plot(survfit(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first CI
summary(coxph(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + pSERG$HOSPITALONSET + 
                pSERG$day + pSERG$earlyacademicyear + pSERG$white +
                pSERG$structuraletiology + pSERG$priorepilepsy +
                pSERG$status + pSERG$ageyears + pSERG$SEX))
## Call:
## coxph(formula = Surv(pSERG$CONTTIME.0) ~ pSERG$awareness + pSERG$TYPESTATUS + 
##     pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + 
##     pSERG$white + pSERG$structuraletiology + pSERG$priorepilepsy + 
##     pSERG$status + pSERG$ageyears + pSERG$SEX)
## 
##   n= 119, number of events= 119 
##    (149 observations deleted due to missingness)
## 
##                                   coef exp(coef)  se(coef)      z Pr(>|z|)
## pSERG$awareness              -0.026718  0.973636  0.197159 -0.136   0.8922
## pSERG$TYPESTATUSintermittent -0.221570  0.801260  0.226611 -0.978   0.3282
## pSERG$HOSPITALONSETyes        0.089413  1.093533  0.224921  0.398   0.6910
## pSERG$day                     0.016079  1.016209  0.195058  0.082   0.9343
## pSERG$earlyacademicyear       0.477221  1.611589  0.203899  2.340   0.0193
## pSERG$white                  -0.484381  0.616078  0.216217 -2.240   0.0251
## pSERG$structuraletiology      0.161824  1.175653  0.238960  0.677   0.4983
## pSERG$priorepilepsy           0.198720  1.219841  0.242792  0.818   0.4131
## pSERG$status                  0.095529  1.100241  0.274854  0.348   0.7282
## pSERG$ageyears               -0.001423  0.998578  0.019819 -0.072   0.9427
## pSERG$SEXmale                 0.360315  1.433781  0.201243  1.790   0.0734
##                               
## pSERG$awareness               
## pSERG$TYPESTATUSintermittent  
## pSERG$HOSPITALONSETyes        
## pSERG$day                     
## pSERG$earlyacademicyear      *
## pSERG$white                  *
## pSERG$structuraletiology      
## pSERG$priorepilepsy           
## pSERG$status                  
## pSERG$ageyears                
## pSERG$SEXmale                .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                              exp(coef) exp(-coef) lower .95 upper .95
## pSERG$awareness                 0.9736     1.0271    0.6616    1.4329
## pSERG$TYPESTATUSintermittent    0.8013     1.2480    0.5139    1.2493
## pSERG$HOSPITALONSETyes          1.0935     0.9145    0.7037    1.6994
## pSERG$day                       1.0162     0.9841    0.6933    1.4894
## pSERG$earlyacademicyear         1.6116     0.6205    1.0807    2.4033
## pSERG$white                     0.6161     1.6232    0.4033    0.9412
## pSERG$structuraletiology        1.1757     0.8506    0.7360    1.8779
## pSERG$priorepilepsy             1.2198     0.8198    0.7579    1.9632
## pSERG$status                    1.1002     0.9089    0.6420    1.8856
## pSERG$ageyears                  0.9986     1.0014    0.9605    1.0381
## pSERG$SEXmale                   1.4338     0.6975    0.9665    2.1271
## 
## Concordance= 0.586  (se = 0.031 )
## Rsquare= 0.115   (max possible= 1 )
## Likelihood ratio test= 14.5  on 11 df,   p=0.2
## Wald test            = 14.42  on 11 df,   p=0.2
## Score (logrank) test = 14.53  on 11 df,   p=0.2
# First BZD later than 20 minutes
CrossTable(pSERG$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  268 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       149 |       119 | 
##           |     0.556 |     0.444 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  150 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        81 |        69 | 
##           |     0.540 |     0.460 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  118 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        68 |        50 | 
##           |     0.576 |     0.424 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstBZDmore20min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstBZDmore20min and pSERG$awareness
## p-value = 0.6206
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.5152177 1.4441696
## sample estimates:
## odds ratio 
##  0.8636474
# Difference adjusting for covariates within the first 20 minutes
rmst2(time=pSERG$BZDTIME.0, status=pSERG$event, arm=pSERG$awareness, tau=20,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 20  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.016    -1.692     1.723 0.986
## RMST (arm=1)/(arm=0) 1.003     0.884     1.137 0.968
## RMTL (arm=1)/(arm=0) 1.004     0.767     1.313 0.979
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            16.337    1.375 11.879 0.000    13.642    19.033
## arm                   0.016    0.871  0.018 0.986    -1.692     1.723
## TYPESTATUSnumeric    -0.473    0.902 -0.524 0.600    -2.242     1.296
## HOSPITALONSETnumeric -3.496    0.982 -3.560 0.000    -5.420    -1.571
## day                  -0.628    0.855 -0.734 0.463    -2.304     1.048
## earlyacademicyear    -0.951    0.864 -1.101 0.271    -2.644     0.742
## white                -0.248    0.874 -0.283 0.777    -1.960     1.465
## structuraletiology   -0.499    1.015 -0.492 0.623    -2.488     1.490
## priorepilepsy        -0.412    0.896 -0.459 0.646    -2.169     1.345
## status               -2.789    1.271 -2.195 0.028    -5.280    -0.299
## ageyears              0.010    0.089  0.108 0.914    -0.164     0.183
## SEXnumeric            0.553    0.874  0.633 0.527    -1.160     2.267
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             2.809    0.100 27.986 0.000    16.589    13.627
## arm                   0.003    0.064  0.040 0.968     1.003     0.884
## TYPESTATUSnumeric    -0.032    0.067 -0.480 0.631     0.968     0.849
## HOSPITALONSETnumeric -0.275    0.082 -3.343 0.001     0.760     0.646
## day                  -0.049    0.062 -0.789 0.430     0.952     0.842
## earlyacademicyear    -0.071    0.063 -1.116 0.264     0.932     0.823
## white                -0.020    0.064 -0.313 0.755     0.980     0.864
## structuraletiology   -0.037    0.076 -0.492 0.623     0.963     0.830
## priorepilepsy        -0.034    0.064 -0.531 0.595     0.967     0.853
## status               -0.225    0.108 -2.084 0.037     0.798     0.646
## ageyears              0.001    0.006  0.131 0.895     1.001     0.988
## SEXnumeric            0.041    0.064  0.643 0.520     1.042     0.919
##                      upper .95
## intercept               20.196
## arm                      1.137
## TYPESTATUSnumeric        1.104
## HOSPITALONSETnumeric     0.892
## day                      1.076
## earlyacademicyear        1.055
## white                    1.111
## structuraletiology       1.118
## priorepilepsy            1.096
## status                   0.987
## ageyears                 1.014
## SEXnumeric               1.182
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             1.411    0.226  6.254 0.000     4.099     2.634
## arm                   0.004    0.137  0.026 0.979     1.004     0.767
## TYPESTATUSnumeric     0.089    0.140  0.632 0.528     1.093     0.830
## HOSPITALONSETnumeric  0.499    0.139  3.588 0.000     1.647     1.254
## day                   0.085    0.138  0.612 0.540     1.088     0.830
## earlyacademicyear     0.146    0.139  1.057 0.290     1.158     0.882
## white                 0.031    0.138  0.225 0.822     1.032     0.786
## structuraletiology    0.075    0.155  0.487 0.627     1.078     0.796
## priorepilepsy         0.048    0.153  0.312 0.755     1.049     0.777
## status                0.379    0.170  2.222 0.026     1.461     1.046
## ageyears             -0.001    0.014 -0.056 0.955     0.999     0.972
## SEXnumeric           -0.085    0.140 -0.607 0.544     0.918     0.698
##                      upper .95
## intercept                6.378
## arm                      1.313
## TYPESTATUSnumeric        1.439
## HOSPITALONSETnumeric     2.164
## day                      1.427
## earlyacademicyear        1.519
## white                    1.353
## structuraletiology       1.459
## priorepilepsy            1.417
## status                   2.040
## ageyears                 1.027
## SEXnumeric               1.209
# First BZD later than 40 minutes
CrossTable(pSERG$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  268 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       192 |        76 | 
##           |     0.716 |     0.284 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  150 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       103 |        47 | 
##           |     0.687 |     0.313 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  118 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        89 |        29 | 
##           |     0.754 |     0.246 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstBZDmore40min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstBZDmore40min and pSERG$awareness
## p-value = 0.2748
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3982146 1.2693869
## sample estimates:
## odds ratio 
##  0.7149781
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG$BZDTIME.0, status=pSERG$event, arm=pSERG$awareness, tau=40,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -1.243    -4.736     2.250 0.486
## RMST (arm=1)/(arm=0)  0.947     0.799     1.124 0.535
## RMTL (arm=1)/(arm=0)  1.074     0.897     1.286 0.437
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            26.287    2.750  9.560 0.000    20.898    31.677
## arm                  -1.243    1.782 -0.697 0.486    -4.736     2.250
## TYPESTATUSnumeric    -3.584    1.749 -2.049 0.040    -7.013    -0.155
## HOSPITALONSETnumeric -7.759    1.851 -4.193 0.000   -11.386    -4.132
## day                  -0.530    1.778 -0.298 0.766    -4.014     2.954
## earlyacademicyear    -1.998    1.753 -1.140 0.254    -5.434     1.437
## white                 0.511    1.797  0.285 0.776    -3.011     4.033
## structuraletiology    0.484    2.095  0.231 0.817    -3.623     4.590
## priorepilepsy         0.713    1.874  0.380 0.704    -2.961     4.386
## status               -5.873    2.455 -2.392 0.017   -10.685    -1.061
## ageyears              0.052    0.177  0.294 0.769    -0.295     0.399
## SEXnumeric           -0.163    1.772 -0.092 0.927    -3.636     3.310
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.287    0.131 25.126 0.000    26.757    20.706
## arm                  -0.054    0.087 -0.620 0.535     0.947     0.799
## TYPESTATUSnumeric    -0.171    0.089 -1.921 0.055     0.843     0.709
## HOSPITALONSETnumeric -0.404    0.107 -3.795 0.000     0.667     0.542
## day                  -0.030    0.085 -0.349 0.727     0.971     0.822
## earlyacademicyear    -0.097    0.085 -1.142 0.253     0.908     0.769
## white                 0.023    0.087  0.264 0.792     1.023     0.862
## structuraletiology    0.024    0.100  0.243 0.808     1.025     0.842
## priorepilepsy         0.025    0.086  0.295 0.768     1.026     0.866
## status               -0.310    0.143 -2.160 0.031     0.734     0.554
## ageyears              0.003    0.008  0.305 0.760     1.003     0.986
## SEXnumeric           -0.004    0.085 -0.048 0.962     0.996     0.844
##                      upper .95
## intercept               34.577
## arm                      1.124
## TYPESTATUSnumeric        1.003
## HOSPITALONSETnumeric     0.822
## day                      1.146
## earlyacademicyear        1.072
## white                    1.214
## structuraletiology       1.247
## priorepilepsy            1.215
## status                   0.972
## ageyears                 1.019
## SEXnumeric               1.176
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             2.652    0.149 17.754 0.000    14.180    10.581
## arm                   0.071    0.092  0.777 0.437     1.074     0.897
## TYPESTATUSnumeric     0.191    0.089  2.148 0.032     1.210     1.017
## HOSPITALONSETnumeric  0.384    0.091  4.235 0.000     1.468     1.229
## day                   0.023    0.095  0.246 0.806     1.024     0.850
## earlyacademicyear     0.104    0.092  1.129 0.259     1.110     0.926
## white                -0.029    0.094 -0.310 0.756     0.971     0.808
## structuraletiology   -0.024    0.111 -0.221 0.825     0.976     0.786
## priorepilepsy        -0.048    0.105 -0.459 0.646     0.953     0.777
## status                0.289    0.116  2.499 0.012     1.336     1.064
## ageyears             -0.003    0.009 -0.281 0.779     0.997     0.979
## SEXnumeric            0.011    0.094  0.121 0.903     1.011     0.842
##                      upper .95
## intercept               19.003
## arm                      1.286
## TYPESTATUSnumeric        1.441
## HOSPITALONSETnumeric     1.753
## day                      1.233
## earlyacademicyear        1.330
## white                    1.167
## structuraletiology       1.212
## priorepilepsy            1.170
## status                   1.676
## ageyears                 1.016
## SEXnumeric               1.215
# First BZD later than 60 minutes
CrossTable(pSERG$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  268 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       217 |        51 | 
##           |     0.810 |     0.190 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  150 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       116 |        34 | 
##           |     0.773 |     0.227 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  118 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       101 |        17 | 
##           |     0.856 |     0.144 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstBZDmore60min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstBZDmore60min and pSERG$awareness
## p-value = 0.1165
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.2833536 1.1330544
## sample estimates:
## odds ratio 
##  0.5754247
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG$BZDTIME.0, status=pSERG$event, arm=pSERG$awareness, tau=60,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -2.652    -7.679     2.376 0.301
## RMST (arm=1)/(arm=0)  0.910     0.743     1.114 0.361
## RMTL (arm=1)/(arm=0)  1.086     0.939     1.255 0.265
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept             34.954    4.016  8.703 0.000    27.082    42.826
## arm                   -2.652    2.565 -1.034 0.301    -7.679     2.376
## TYPESTATUSnumeric     -6.440    2.506 -2.570 0.010   -11.352    -1.528
## HOSPITALONSETnumeric -10.710    2.613 -4.100 0.000   -15.831    -5.590
## day                   -0.646    2.599 -0.249 0.804    -5.740     4.448
## earlyacademicyear     -3.445    2.542 -1.355 0.175    -8.426     1.537
## white                  0.064    2.648  0.024 0.981    -5.126     5.254
## structuraletiology     0.762    3.002  0.254 0.800    -5.122     6.646
## priorepilepsy          2.432    2.745  0.886 0.376    -2.948     7.812
## status                -9.665    3.267 -2.958 0.003   -16.068    -3.262
## ageyears               0.045    0.253  0.177 0.859    -0.451     0.541
## SEXnumeric            -1.249    2.566 -0.487 0.627    -6.279     3.781
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.588    0.152 23.580 0.000    36.166    26.840
## arm                  -0.094    0.103 -0.913 0.361     0.910     0.743
## TYPESTATUSnumeric    -0.253    0.106 -2.381 0.017     0.776     0.631
## HOSPITALONSETnumeric -0.457    0.125 -3.663 0.000     0.633     0.496
## day                  -0.032    0.100 -0.314 0.754     0.969     0.796
## earlyacademicyear    -0.134    0.100 -1.342 0.180     0.874     0.719
## white                 0.002    0.104  0.015 0.988     1.002     0.817
## structuraletiology    0.030    0.116  0.256 0.798     1.030     0.821
## priorepilepsy         0.081    0.102  0.795 0.427     1.084     0.888
## status               -0.421    0.163 -2.589 0.010     0.656     0.477
## ageyears              0.002    0.010  0.164 0.870     1.002     0.983
## SEXnumeric           -0.043    0.099 -0.430 0.667     0.958     0.789
##                      upper .95
## intercept               48.734
## arm                      1.114
## TYPESTATUSnumeric        0.956
## HOSPITALONSETnumeric     0.809
## day                      1.180
## earlyacademicyear        1.064
## white                    1.228
## structuraletiology       1.292
## priorepilepsy            1.323
## status                   0.903
## ageyears                 1.021
## SEXnumeric               1.164
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.253    0.123 26.439 0.000    25.857    20.317
## arm                   0.082    0.074  1.115 0.265     1.086     0.939
## TYPESTATUSnumeric     0.189    0.071  2.641 0.008     1.208     1.050
## HOSPITALONSETnumeric  0.300    0.073  4.128 0.000     1.350     1.171
## day                   0.016    0.077  0.202 0.840     1.016     0.873
## earlyacademicyear     0.101    0.075  1.354 0.176     1.106     0.956
## white                -0.003    0.077 -0.037 0.970     0.997     0.857
## structuraletiology   -0.022    0.089 -0.253 0.800     0.978     0.822
## priorepilepsy        -0.079    0.085 -0.935 0.350     0.924     0.782
## status                0.270    0.089  3.035 0.002     1.310     1.100
## ageyears             -0.001    0.008 -0.184 0.854     0.999     0.984
## SEXnumeric            0.039    0.076  0.509 0.611     1.039     0.896
##                      upper .95
## intercept               32.907
## arm                      1.255
## TYPESTATUSnumeric        1.389
## HOSPITALONSETnumeric     1.556
## day                      1.182
## earlyacademicyear        1.281
## white                    1.161
## structuraletiology       1.164
## priorepilepsy            1.091
## status                   1.560
## ageyears                 1.013
## SEXnumeric               1.206
# First non-BZD ASM later than 40 minutes
CrossTable(pSERG$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  268 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        76 |       192 | 
##           |     0.284 |     0.716 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  150 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        45 |       105 | 
##           |     0.300 |     0.700 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  118 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        31 |        87 | 
##           |     0.263 |     0.737 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstASMmore40min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstASMmore40min and pSERG$awareness
## p-value = 0.5853
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.6792881 2.1444062
## sample estimates:
## odds ratio 
##   1.201938
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG$AEDTIME.0, status=pSERG$event, arm=pSERG$awareness, tau=40,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.661    -2.779     1.457 0.541
## RMST (arm=1)/(arm=0)  0.982     0.924     1.043 0.558
## RMTL (arm=1)/(arm=0)  1.199     0.772     1.861 0.419
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            35.105    1.871 18.764 0.000    31.438    38.772
## arm                  -0.661    1.081 -0.612 0.541    -2.779     1.457
## TYPESTATUSnumeric    -0.081    1.117 -0.073 0.942    -2.270     2.107
## HOSPITALONSETnumeric -6.909    1.394 -4.955 0.000    -9.642    -4.176
## day                  -1.442    1.114 -1.294 0.196    -3.626     0.742
## earlyacademicyear     0.864    1.076  0.803 0.422    -1.244     2.972
## white                 1.814    1.097  1.653 0.098    -0.336     3.964
## structuraletiology   -0.302    1.186 -0.255 0.799    -2.626     2.022
## priorepilepsy         1.262    1.111  1.136 0.256    -0.915     3.439
## status               -0.599    1.361 -0.441 0.659    -3.266     2.067
## ageyears              0.169    0.111  1.519 0.129    -0.049     0.387
## SEXnumeric            0.844    1.136  0.743 0.458    -1.383     3.070
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.555    0.054 65.491 0.000    34.985    31.454
## arm                  -0.018    0.031 -0.586 0.558     0.982     0.924
## TYPESTATUSnumeric    -0.002    0.032 -0.057 0.955     0.998     0.938
## HOSPITALONSETnumeric -0.204    0.044 -4.603 0.000     0.815     0.747
## day                  -0.040    0.032 -1.255 0.209     0.961     0.903
## earlyacademicyear     0.024    0.031  0.781 0.435     1.024     0.964
## white                 0.051    0.032  1.613 0.107     1.053     0.989
## structuraletiology   -0.008    0.034 -0.231 0.817     0.992     0.927
## priorepilepsy         0.035    0.031  1.124 0.261     1.036     0.974
## status               -0.016    0.039 -0.416 0.678     0.984     0.912
## ageyears              0.005    0.003  1.517 0.129     1.005     0.999
## SEXnumeric            0.024    0.032  0.734 0.463     1.024     0.961
##                      upper .95
## intercept               38.913
## arm                      1.043
## TYPESTATUSnumeric        1.062
## HOSPITALONSETnumeric     0.889
## day                      1.023
## earlyacademicyear        1.088
## white                    1.120
## structuraletiology       1.061
## priorepilepsy            1.102
## status                   1.062
## ageyears                 1.011
## SEXnumeric               1.091
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             1.373    0.385  3.564 0.000     3.948     1.855
## arm                   0.181    0.224  0.808 0.419     1.199     0.772
## TYPESTATUSnumeric     0.056    0.253  0.220 0.826     1.057     0.643
## HOSPITALONSETnumeric  1.309    0.248  5.281 0.000     3.704     2.278
## day                   0.376    0.250  1.499 0.134     1.456     0.891
## earlyacademicyear    -0.216    0.225 -0.958 0.338     0.806     0.519
## white                -0.417    0.217 -1.922 0.055     0.659     0.431
## structuraletiology    0.094    0.223  0.422 0.673     1.099     0.709
## priorepilepsy        -0.313    0.276 -1.136 0.256     0.731     0.426
## status                0.181    0.308  0.587 0.557     1.198     0.655
## ageyears             -0.040    0.027 -1.489 0.136     0.961     0.911
## SEXnumeric           -0.225    0.249 -0.904 0.366     0.799     0.491
##                      upper .95
## intercept                8.403
## arm                      1.861
## TYPESTATUSnumeric        1.737
## HOSPITALONSETnumeric     6.022
## day                      2.379
## earlyacademicyear        1.253
## white                    1.008
## structuraletiology       1.703
## priorepilepsy            1.255
## status                   2.193
## ageyears                 1.013
## SEXnumeric               1.300
# First non-BZD ASM later than 60 minutes
CrossTable(pSERG$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  268 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       120 |       148 | 
##           |     0.448 |     0.552 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  150 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        70 |        80 | 
##           |     0.467 |     0.533 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  118 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        50 |        68 | 
##           |     0.424 |     0.576 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstASMmore60min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstASMmore60min and pSERG$awareness
## p-value = 0.5366
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.7114192 1.9931234
## sample estimates:
## odds ratio 
##   1.189223
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG$AEDTIME.0, status=pSERG$event, arm=pSERG$awareness, tau=60,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.253    -3.504     4.009 0.895
## RMST (arm=1)/(arm=0) 1.007     0.931     1.089 0.863
## RMTL (arm=1)/(arm=0) 1.007     0.728     1.394 0.966
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept             48.381    3.350 14.441 0.000    41.814    54.947
## arm                    0.253    1.917  0.132 0.895    -3.504     4.009
## TYPESTATUSnumeric     -1.715    2.009 -0.853 0.393    -5.652     2.223
## HOSPITALONSETnumeric -13.584    2.409 -5.638 0.000   -18.306    -8.862
## day                   -3.253    1.966 -1.654 0.098    -7.107     0.602
## earlyacademicyear      2.209    1.925  1.147 0.251    -1.565     5.983
## white                  2.464    1.986  1.241 0.215    -1.428     6.355
## structuraletiology    -1.778    2.163 -0.822 0.411    -6.018     2.462
## priorepilepsy          2.555    2.008  1.272 0.203    -1.381     6.490
## status                -0.993    2.353 -0.422 0.673    -5.604     3.618
## ageyears               0.327    0.197  1.662 0.097    -0.059     0.713
## SEXnumeric             2.367    1.995  1.186 0.235    -1.543     6.277
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.873    0.072 54.079 0.000    48.092    41.794
## arm                   0.007    0.040  0.173 0.863     1.007     0.931
## TYPESTATUSnumeric    -0.035    0.042 -0.836 0.403     0.966     0.889
## HOSPITALONSETnumeric -0.299    0.059 -5.090 0.000     0.741     0.661
## day                  -0.066    0.041 -1.614 0.106     0.936     0.864
## earlyacademicyear     0.044    0.040  1.098 0.272     1.045     0.966
## white                 0.050    0.042  1.183 0.237     1.051     0.968
## structuraletiology   -0.036    0.047 -0.769 0.442     0.965     0.880
## priorepilepsy         0.052    0.041  1.261 0.207     1.054     0.972
## status               -0.019    0.049 -0.382 0.703     0.982     0.892
## ageyears              0.007    0.004  1.669 0.095     1.007     0.999
## SEXnumeric            0.048    0.042  1.156 0.248     1.049     0.967
##                      upper .95
## intercept               55.340
## arm                      1.089
## TYPESTATUSnumeric        1.048
## HOSPITALONSETnumeric     0.832
## day                      1.014
## earlyacademicyear        1.131
## white                    1.142
## structuraletiology       1.057
## priorepilepsy            1.142
## status                   1.080
## ageyears                 1.015
## SEXnumeric               1.138
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             2.337    0.275  8.505 0.000    10.349     6.040
## arm                   0.007    0.166  0.043 0.966     1.007     0.728
## TYPESTATUSnumeric     0.161    0.175  0.917 0.359     1.175     0.833
## HOSPITALONSETnumeric  1.043    0.175  5.960 0.000     2.838     2.014
## day                   0.313    0.180  1.741 0.082     1.367     0.961
## earlyacademicyear    -0.220    0.166 -1.324 0.186     0.802     0.579
## white                -0.244    0.162 -1.511 0.131     0.783     0.571
## structuraletiology    0.168    0.164  1.024 0.306     1.183     0.857
## priorepilepsy        -0.245    0.194 -1.265 0.206     0.783     0.535
## status                0.122    0.216  0.565 0.572     1.130     0.740
## ageyears             -0.030    0.019 -1.578 0.115     0.970     0.935
## SEXnumeric           -0.237    0.176 -1.345 0.179     0.789     0.558
##                      upper .95
## intercept               17.732
## arm                      1.394
## TYPESTATUSnumeric        1.657
## HOSPITALONSETnumeric     4.000
## day                      1.944
## earlyacademicyear        1.112
## white                    1.075
## structuraletiology       1.633
## priorepilepsy            1.144
## status                   1.725
## ageyears                 1.007
## SEXnumeric               1.115
# First non-BZD ASM later than 120 minutes
CrossTable(pSERG$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  268 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       187 |        81 | 
##           |     0.698 |     0.302 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  150 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       105 |        45 | 
##           |     0.700 |     0.300 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  118 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        82 |        36 | 
##           |     0.695 |     0.305 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstASMmore120min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstASMmore120min and pSERG$awareness
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.5845118 1.7884137
## sample estimates:
## odds ratio 
##   1.024307
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG$AEDTIME.0, status=pSERG$event, arm=pSERG$awareness, tau=120,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.151    -8.971     8.669 0.973
## RMST (arm=1)/(arm=0)  1.005     0.890     1.135 0.934
## RMTL (arm=1)/(arm=0)  1.021     0.844     1.236 0.829
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept             82.622    7.379 11.196 0.000    68.159    97.085
## arm                   -0.151    4.500 -0.034 0.973    -8.971     8.669
## TYPESTATUSnumeric    -18.281    4.434 -4.123 0.000   -26.972    -9.590
## HOSPITALONSETnumeric -31.704    5.036 -6.295 0.000   -41.575   -21.833
## day                   -6.303    4.542 -1.388 0.165   -15.206     2.600
## earlyacademicyear      1.668    4.474  0.373 0.709    -7.101    10.436
## white                  2.728    4.612  0.592 0.554    -6.311    11.767
## structuraletiology    -6.339    5.141 -1.233 0.218   -16.415     3.736
## priorepilepsy          5.673    4.766  1.190 0.234    -3.668    15.014
## status                -4.867    5.607 -0.868 0.385   -15.857     6.123
## ageyears               0.809    0.439  1.842 0.065    -0.052     1.670
## SEXnumeric             4.809    4.559  1.055 0.291    -4.126    13.744
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             4.411    0.103 42.711 0.000    82.370    67.275
## arm                   0.005    0.062  0.083 0.934     1.005     0.890
## TYPESTATUSnumeric    -0.260    0.065 -3.977 0.000     0.771     0.678
## HOSPITALONSETnumeric -0.477    0.085 -5.599 0.000     0.621     0.525
## day                  -0.086    0.062 -1.396 0.163     0.917     0.813
## earlyacademicyear     0.017    0.061  0.281 0.779     1.017     0.902
## white                 0.029    0.064  0.453 0.650     1.030     0.907
## structuraletiology   -0.085    0.076 -1.129 0.259     0.918     0.791
## priorepilepsy         0.074    0.064  1.161 0.246     1.077     0.950
## status               -0.057    0.079 -0.727 0.467     0.944     0.809
## ageyears              0.011    0.006  1.859 0.063     1.011     0.999
## SEXnumeric            0.065    0.063  1.041 0.298     1.068     0.944
##                      upper .95
## intercept              100.852
## arm                      1.135
## TYPESTATUSnumeric        0.876
## HOSPITALONSETnumeric     0.733
## day                      1.035
## earlyacademicyear        1.147
## white                    1.168
## structuraletiology       1.065
## priorepilepsy            1.220
## status                   1.102
## ageyears                 1.022
## SEXnumeric               1.208
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.614    0.159 22.680 0.000    37.118    27.161
## arm                   0.021    0.097  0.215 0.829     1.021     0.844
## TYPESTATUSnumeric     0.377    0.094  4.026 0.000     1.458     1.213
## HOSPITALONSETnumeric  0.626    0.101  6.174 0.000     1.871     1.534
## day                   0.135    0.102  1.325 0.185     1.145     0.937
## earlyacademicyear    -0.049    0.098 -0.500 0.617     0.952     0.786
## white                -0.081    0.097 -0.831 0.406     0.922     0.762
## structuraletiology    0.140    0.102  1.369 0.171     1.150     0.941
## priorepilepsy        -0.134    0.111 -1.214 0.225     0.874     0.704
## status                0.129    0.121  1.067 0.286     1.138     0.898
## ageyears             -0.018    0.011 -1.735 0.083     0.982     0.962
## SEXnumeric           -0.110    0.101 -1.099 0.272     0.895     0.735
##                      upper .95
## intercept               50.726
## arm                      1.236
## TYPESTATUSnumeric        1.751
## HOSPITALONSETnumeric     2.283
## day                      1.398
## earlyacademicyear        1.153
## white                    1.116
## structuraletiology       1.406
## priorepilepsy            1.086
## status                   1.442
## ageyears                 1.002
## SEXnumeric               1.090
# First CI later than 60 minutes
CrossTable(pSERG$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  119 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         9 |       110 | 
##           |     0.076 |     0.924 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  67 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         6 |        61 | 
##           |     0.090 |     0.910 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  52 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         3 |        49 | 
##           |     0.058 |     0.942 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstCImore60min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstCImore60min and pSERG$awareness
## p-value = 0.7297
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.3220185 10.3939712
## sample estimates:
## odds ratio 
##   1.600393
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0), ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0), ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0), ]$awareness, tau=60,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 2.045    -0.117     4.207 0.064
## RMST (arm=1)/(arm=0) 1.036     0.997     1.075 0.069
## RMTL (arm=1)/(arm=0) 0.136     0.029     0.641 0.012
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            59.038    1.645 35.895 0.000    55.814    62.262
## arm                   2.045    1.103  1.854 0.064    -0.117     4.207
## TYPESTATUSnumeric     0.624    1.268  0.492 0.623    -1.862     3.109
## HOSPITALONSETnumeric -2.003    1.971 -1.016 0.310    -5.867     1.861
## day                  -1.289    1.111 -1.161 0.246    -3.466     0.888
## earlyacademicyear    -1.200    1.562 -0.768 0.443    -4.261     1.862
## white                -0.643    1.115 -0.576 0.564    -2.828     1.542
## structuraletiology    1.131    1.682  0.672 0.501    -2.166     4.427
## priorepilepsy        -0.125    1.150 -0.109 0.914    -2.379     2.129
## status                1.975    1.019  1.939 0.053    -0.022     3.971
## ageyears              0.019    0.118  0.160 0.873    -0.212     0.249
## SEXnumeric           -0.379    1.497 -0.254 0.800    -3.313     2.554
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)       z     p exp(coef) lower .95
## intercept             4.078    0.028 143.411 0.000    59.004    55.806
## arm                   0.035    0.019   1.820 0.069     1.036     0.997
## TYPESTATUSnumeric     0.010    0.022   0.468 0.640     1.010     0.968
## HOSPITALONSETnumeric -0.035    0.035  -1.001 0.317     0.966     0.903
## day                  -0.022    0.019  -1.149 0.251     0.978     0.942
## earlyacademicyear    -0.020    0.027  -0.761 0.447     0.980     0.930
## white                -0.011    0.019  -0.565 0.572     0.989     0.953
## structuraletiology    0.020    0.029   0.678 0.498     1.020     0.963
## priorepilepsy        -0.002    0.020  -0.101 0.920     0.998     0.960
## status                0.033    0.017   1.921 0.055     1.034     0.999
## ageyears              0.000    0.002   0.162 0.871     1.000     0.996
## SEXnumeric           -0.006    0.026  -0.243 0.808     0.994     0.945
##                      upper .95
## intercept               62.386
## arm                      1.075
## TYPESTATUSnumeric        1.054
## HOSPITALONSETnumeric     1.034
## day                      1.016
## earlyacademicyear        1.033
## white                    1.027
## structuraletiology       1.080
## priorepilepsy            1.037
## status                   1.070
## ageyears                 1.004
## SEXnumeric               1.045
## 
## 
## Model summary (ratio of time-lost) 
##                         coef se(coef)       z     p exp(coef) lower .95
## intercept             -1.638    1.696  -0.966 0.334     0.194     0.007
## arm                   -1.994    0.790  -2.523 0.012     0.136     0.029
## TYPESTATUSnumeric     -1.318    1.023  -1.289 0.197     0.268     0.036
## HOSPITALONSETnumeric   1.419    1.017   1.395 0.163     4.133     0.563
## day                    0.932    0.836   1.115 0.265     2.539     0.493
## earlyacademicyear      1.310    0.781   1.677 0.094     3.707     0.801
## white                  0.960    0.682   1.408 0.159     2.611     0.686
## structuraletiology    -0.603    0.981  -0.615 0.539     0.547     0.080
## priorepilepsy         -0.001    0.850  -0.002 0.999     0.999     0.189
## status               -17.991    0.863 -20.848 0.000     0.000     0.000
## ageyears               0.010    0.063   0.162 0.872     1.010     0.894
## SEXnumeric             0.784    0.899   0.872 0.383     2.190     0.376
##                      upper .95
## intercept                5.398
## arm                      0.641
## TYPESTATUSnumeric        1.987
## HOSPITALONSETnumeric    30.364
## day                     13.065
## earlyacademicyear       17.145
## white                    9.930
## structuraletiology       3.743
## priorepilepsy            5.285
## status                   0.000
## ageyears                 1.142
## SEXnumeric              12.748
# First CI later than 120 minutes
CrossTable(pSERG$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  119 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        28 |        91 | 
##           |     0.235 |     0.765 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  67 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        16 |        51 | 
##           |     0.239 |     0.761 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  52 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        12 |        40 | 
##           |     0.231 |     0.769 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstCImore120min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstCImore120min and pSERG$awareness
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4100271 2.7213761
## sample estimates:
## odds ratio 
##   1.045373
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0), ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0), ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0), ]$awareness, tau=120,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 3.038    -4.854    10.930 0.451
## RMST (arm=1)/(arm=0) 1.027     0.955     1.104 0.468
## RMTL (arm=1)/(arm=0) 0.642     0.285     1.445 0.284
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept            111.363    6.653 16.738 0.000    98.323   124.404
## arm                    3.038    4.026  0.755 0.451    -4.854    10.930
## TYPESTATUSnumeric      1.698    4.637  0.366 0.714    -7.391    10.786
## HOSPITALONSETnumeric   1.582    5.099  0.310 0.756    -8.412    11.575
## day                   -6.270    4.031 -1.556 0.120   -14.170     1.629
## earlyacademicyear     -6.810    4.839 -1.407 0.159   -16.295     2.675
## white                  4.298    4.376  0.982 0.326    -4.278    12.874
## structuraletiology     1.510    5.509  0.274 0.784    -9.288    12.308
## priorepilepsy         -2.934    4.747 -0.618 0.537   -12.238     6.370
## status                10.355    4.022  2.574 0.010     2.471    18.239
## ageyears               0.153    0.384  0.397 0.691    -0.601     0.906
## SEXnumeric            -2.369    4.530 -0.523 0.601   -11.248     6.510
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             4.711    0.060 78.323 0.000   111.189    98.823
## arm                   0.027    0.037  0.726 0.468     1.027     0.955
## TYPESTATUSnumeric     0.016    0.042  0.371 0.711     1.016     0.935
## HOSPITALONSETnumeric  0.014    0.046  0.312 0.755     1.014     0.927
## day                  -0.057    0.037 -1.546 0.122     0.944     0.878
## earlyacademicyear    -0.061    0.044 -1.393 0.164     0.940     0.862
## white                 0.039    0.040  0.979 0.328     1.040     0.961
## structuraletiology    0.014    0.050  0.273 0.785     1.014     0.919
## priorepilepsy        -0.027    0.043 -0.611 0.541     0.974     0.894
## status                0.092    0.037  2.528 0.011     1.097     1.021
## ageyears              0.001    0.003  0.406 0.685     1.001     0.995
## SEXnumeric           -0.021    0.041 -0.518 0.604     0.979     0.903
##                      upper .95
## intercept              125.101
## arm                      1.104
## TYPESTATUSnumeric        1.103
## HOSPITALONSETnumeric     1.110
## day                      1.015
## earlyacademicyear        1.025
## white                    1.125
## structuraletiology       1.119
## priorepilepsy            1.060
## status                   1.178
## ageyears                 1.008
## SEXnumeric               1.061
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             1.885    0.846  2.229 0.026     6.585     1.255
## arm                  -0.444    0.414 -1.071 0.284     0.642     0.285
## TYPESTATUSnumeric    -0.151    0.519 -0.292 0.771     0.859     0.311
## HOSPITALONSETnumeric -0.175    0.594 -0.295 0.768     0.839     0.262
## day                   0.648    0.445  1.455 0.146     1.911     0.798
## earlyacademicyear     0.807    0.584  1.382 0.167     2.242     0.713
## white                -0.412    0.457 -0.902 0.367     0.662     0.271
## structuraletiology   -0.155    0.580 -0.267 0.789     0.856     0.275
## priorepilepsy         0.340    0.481  0.707 0.480     1.405     0.547
## status               -1.652    0.756 -2.184 0.029     0.192     0.044
## ageyears             -0.010    0.042 -0.247 0.805     0.990     0.911
## SEXnumeric            0.294    0.454  0.647 0.518     1.341     0.551
##                      upper .95
## intercept               34.545
## arm                      1.445
## TYPESTATUSnumeric        2.379
## HOSPITALONSETnumeric     2.689
## day                      4.576
## earlyacademicyear        7.046
## white                    1.621
## structuraletiology       2.671
## priorepilepsy            3.610
## status                   0.844
## ageyears                 1.075
## SEXnumeric               3.264
# First CI later than 240 minutes
CrossTable(pSERG$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  119 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        68 |        51 | 
##           |     0.571 |     0.429 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  67 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        39 |        28 | 
##           |     0.582 |     0.418 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  52 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        29 |        23 | 
##           |     0.558 |     0.442 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstCImore240min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstCImore240min and pSERG$awareness
## p-value = 0.8528
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.497905 2.444640
## sample estimates:
## odds ratio 
##   1.103753
# Difference adjusting for covariates within the first 240 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0), ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0), ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0), ]$awareness, tau=240,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 240  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 9.024   -14.478    32.525 0.452
## RMST (arm=1)/(arm=0) 1.052     0.921     1.201 0.456
## RMTL (arm=1)/(arm=0) 0.863     0.590     1.260 0.445
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept            187.930   20.849  9.014 0.000   147.067   228.794
## arm                    9.024   11.991  0.753 0.452   -14.478    32.525
## TYPESTATUSnumeric    -19.455   13.594 -1.431 0.152   -46.100     7.189
## HOSPITALONSETnumeric   5.171   13.543  0.382 0.703   -21.373    31.716
## day                  -11.285   12.418 -0.909 0.363   -35.624    13.053
## earlyacademicyear    -20.409   13.269 -1.538 0.124   -46.415     5.597
## white                 13.185   13.067  1.009 0.313   -12.426    38.797
## structuraletiology     1.866   15.551  0.120 0.904   -28.613    32.346
## priorepilepsy          2.507   14.270  0.176 0.861   -25.462    30.475
## status                10.862   14.508  0.749 0.454   -17.574    39.297
## ageyears               0.148    1.197  0.124 0.901    -2.198     2.495
## SEXnumeric           -12.159   12.430 -0.978 0.328   -36.520    12.203
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             5.232    0.115 45.488 0.000   187.115   149.352
## arm                   0.051    0.068  0.746 0.456     1.052     0.921
## TYPESTATUSnumeric    -0.113    0.081 -1.399 0.162     0.893     0.762
## HOSPITALONSETnumeric  0.027    0.075  0.358 0.720     1.027     0.887
## day                  -0.062    0.070 -0.889 0.374     0.940     0.820
## earlyacademicyear    -0.114    0.075 -1.521 0.128     0.893     0.771
## white                 0.075    0.075  0.990 0.322     1.077     0.930
## structuraletiology    0.010    0.087  0.115 0.908     1.010     0.852
## priorepilepsy         0.015    0.079  0.188 0.851     1.015     0.870
## status                0.063    0.080  0.785 0.433     1.065     0.910
## ageyears              0.001    0.007  0.135 0.893     1.001     0.988
## SEXnumeric           -0.068    0.070 -0.974 0.330     0.934     0.814
##                      upper .95
## intercept              234.427
## arm                      1.201
## TYPESTATUSnumeric        1.047
## HOSPITALONSETnumeric     1.190
## day                      1.077
## earlyacademicyear        1.033
## white                    1.249
## structuraletiology       1.197
## priorepilepsy            1.184
## status                   1.246
## ageyears                 1.014
## SEXnumeric               1.072
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.914    0.367 10.657 0.000    50.100    24.390
## arm                  -0.148    0.193 -0.764 0.445     0.863     0.590
## TYPESTATUSnumeric     0.290    0.196  1.484 0.138     1.337     0.911
## HOSPITALONSETnumeric -0.104    0.230 -0.454 0.650     0.901     0.574
## day                   0.201    0.210  0.955 0.339     1.223     0.809
## earlyacademicyear     0.345    0.226  1.528 0.126     1.412     0.907
## white                -0.212    0.203 -1.045 0.296     0.809     0.544
## structuraletiology   -0.037    0.260 -0.142 0.887     0.964     0.579
## priorepilepsy        -0.035    0.243 -0.143 0.886     0.966     0.600
## status               -0.162    0.252 -0.644 0.520     0.850     0.519
## ageyears             -0.002    0.021 -0.100 0.920     0.998     0.958
## SEXnumeric            0.196    0.202  0.973 0.330     1.217     0.820
##                      upper .95
## intercept              102.911
## arm                      1.260
## TYPESTATUSnumeric        1.961
## HOSPITALONSETnumeric     1.414
## day                      1.847
## earlyacademicyear        2.198
## white                    1.204
## structuraletiology       1.604
## priorepilepsy            1.555
## status                   1.393
## ageyears                 1.039
## SEXnumeric               1.807
## OUT OF THE HOSPITAL

# At least one benzodiazepine before hospital arrival
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  134 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        51 |        83 | 
##           |     0.381 |     0.619 | 
##           |-----------|-----------|
## 
## 
## 
## 
# At least one benzodiazepine before hospital arrival depending on awareness
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  80 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        40 |        40 | 
##           |     0.500 |     0.500 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  54 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        11 |        43 | 
##           |     0.204 |     0.796 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDbeforehospital, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness)
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$AEDbeforehospital and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.0005647
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  1.669347 9.555395
## sample estimates:
## odds ratio 
##    3.86888
# Logistic regression adjusting for potential confounders
logistic_out_of_hospital_BZD <- glm(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDbeforehospital ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX, family="binomial")

cbind(exp(cbind("Odds ratio" = coef(logistic_out_of_hospital_BZD), confint(logistic_out_of_hospital_BZD, level = 0.95))), "p-value" = coef(summary(logistic_out_of_hospital_BZD))[ , 4])
## Waiting for profiling to be done...
##                                                             Odds ratio
## (Intercept)                                                  2.5767264
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               5.2155487
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.3395691
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     1.0249173
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.0065879
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.5510430
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.9892032
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.7128893
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  6.7955604
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                1.0353313
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.7043755
##                                                                 2.5 %
## (Intercept)                                                 0.6500875
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness              2.1555797
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent 0.1285737
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    0.4331861
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear      0.4430720
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  0.2215725
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     0.3871155
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          0.3049884
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 1.8961407
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               0.9571298
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                0.3042759
##                                                                 97.5 %
## (Intercept)                                                 10.9981289
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness              13.8314421
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.8390637
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     2.4254447
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       2.2823621
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   1.3148194
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      2.5645971
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           1.6351045
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 33.5950948
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                1.1244470
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.5975539
##                                                                 p-value
## (Intercept)                                                 0.186019439
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness              0.000452268
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent 0.022952796
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    0.955054417
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear      0.987403978
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  0.186920250
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     0.981922387
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          0.426990492
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 0.007340804
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               0.393901759
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                0.404673944
# At least one benzodiazepine before hospital arrival among those with prior epilepsy
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  74 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        28 |        46 | 
##           |     0.378 |     0.622 | 
##           |-----------|-----------|
## 
## 
## 
## 
# At least one benzodiazepine before hospital arrival depending on awareness
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$awareness == 0), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  42 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        20 |        22 | 
##           |     0.476 |     0.524 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$awareness == 1), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  32 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         8 |        24 | 
##           |     0.250 |     0.750 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$AEDbeforehospital, pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$awareness)
## 
##  Fisher's Exact Test for Count Data
## 
## data:  
## p-value = 0.05623
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.9071835 8.5977877
## sample estimates:
## odds ratio 
##   2.690113
# Logistic regression adjusting for potential confounders among those with prior epilepsy
logistic_out_of_hospital_BZD_prior_epilepsy <- glm(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$AEDbeforehospital ~ pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$awareness + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$day + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$white +
                pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$structuraletiology + 
                pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$status + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$SEX, family="binomial")

cbind(exp(cbind("Odds ratio" = coef(logistic_out_of_hospital_BZD_prior_epilepsy), confint(logistic_out_of_hospital_BZD_prior_epilepsy, level = 0.95))), "p-value" = coef(summary(logistic_out_of_hospital_BZD_prior_epilepsy))[ , 4])
## Waiting for profiling to be done...
##                                                                                        Odds ratio
## (Intercept)                                                                             1.2905531
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness               3.0666397
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent  0.3771600
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                     1.4111264
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear       0.5229581
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                   0.5331197
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology      1.4467025
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                  9.7553032
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears                1.0980402
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                 0.8746648
##                                                                                             2.5 %
## (Intercept)                                                                            0.16833418
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness              0.92332500
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent 0.09430744
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                    0.41364016
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear      0.14710972
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                  0.14354171
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology     0.39412258
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                 1.93487008
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears               0.97526688
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                0.25369653
##                                                                                           97.5 %
## (Intercept)                                                                            10.678022
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness              11.594062
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent  1.338641
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                     4.917801
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear       1.770650
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                   1.818515
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology      5.688126
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                 79.841701
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears                1.253809
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                 2.977911
##                                                                                           p-value
## (Intercept)                                                                            0.80683707
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness              0.07827142
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent 0.14347324
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                    0.58073011
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear      0.30138350
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                  0.32449375
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology     0.58298347
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                 0.01304221
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears               0.13788370
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                0.82891284
# Patients in each category
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$awareness)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  184 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       104 |        80 | 
##           |     0.565 |     0.435 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Time to first BZD
summary(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    7.00   21.50   68.46   55.00 1264.00
sd(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0)
## [1] 154.9925
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$BZDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##   184.0   184.0    21.5    20.0    30.0
# Figure time to first BZD
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")

# Time to first BZD depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    9.25   26.50   63.71   62.50  720.00
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.00    7.00   20.00   74.64   48.50 1264.00
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness, rho = 1)
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0 104     52.8     56.6
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1  80     43.7     39.9
##                                                  (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0     0.253      0.96
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1     0.360      0.96
## 
##  Chisq= 1  on 1 degrees of freedom, p= 0.3
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.3272417
# Figure time to first BZD by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first BZD
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "no", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$status + pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$SEX)
## 
##   n= 184, number of events= 184 
## 
##                                                                  coef
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.022029
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -0.426614
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.022968
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.126234
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.150251
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.137807
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.065893
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.532780
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.006216
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.090589
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               1.022273
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.652715
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     1.023234
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.134548
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   1.162126
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      1.147754
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           1.068113
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  1.703662
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                1.006236
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.094819
##                                                              se(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.156733
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.169027
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.155971
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.154541
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.161143
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.188267
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.161141
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.213016
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.016130
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.154384
##                                                                  z
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.141
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -2.524
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.147
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.817
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.932
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.732
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.409
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  2.501
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.385
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.587
##                                                             Pr(>|z|)  
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                0.8882  
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent   0.0116 *
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                      0.8829  
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear        0.4140  
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                    0.3511  
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology       0.4642  
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy            0.6826  
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                   0.0124 *
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                 0.7000  
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                  0.5574  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 1.0223
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.6527
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.0232
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.1345
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     1.1621
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.1478
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.0681
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.7037
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  1.0062
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.0948
##                                                             exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                  0.9782
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     1.5321
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        0.9773
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          0.8814
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      0.8605
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         0.8713
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              0.9362
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     0.5870
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   0.9938
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    0.9134
##                                                             lower .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 0.7519
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.4686
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.7537
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.8381
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.8474
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.7936
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.7788
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.1222
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9749
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.8090
##                                                             upper .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 1.3899
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.9091
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.3891
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.5359
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     1.5937
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.6600
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.4648
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    2.5864
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  1.0386
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.4817
## 
## Concordance= 0.593  (se = 0.027 )
## Rsquare= 0.088   (max possible= 1 )
## Likelihood ratio test= 16.89  on 10 df,   p=0.08
## Wald test            = 17.79  on 10 df,   p=0.06
## Score (logrank) test = 18.34  on 10 df,   p=0.05
# Time to first non-BZD AED
summary(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    50.0    86.0   184.3   175.2  1800.0
sd(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0)
## [1] 269.1477
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$AEDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##     184     184      86      69     115
# Figure time to first non-BZD AED
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")

# Time to first non-BZD AED depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    10.0    45.0    81.0   188.3   182.5  1800.0
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    59.0    89.5   179.2   162.8  1276.0
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness, rho = 1)
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0 104     53.8     51.5
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1  80     39.4     41.6
##                                                  (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0    0.0987     0.333
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1    0.1221     0.333
## 
##  Chisq= 0.3  on 1 degrees of freedom, p= 0.6
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.5638338
# Figure time to first non-BZD AED by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first non-BZD AED
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "no", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$status + pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$SEX)
## 
##   n= 184, number of events= 184 
## 
##                                                                 coef
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness              -0.08319
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -0.70406
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.10697
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.02363
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -0.07190
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     -0.05010
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          -0.08553
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.06886
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               -0.02066
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.11682
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                0.92017
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent   0.49457
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                      1.11291
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear        1.02392
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                    0.93063
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology       0.95113
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy            0.91802
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                   1.07128
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                 0.97955
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                  1.12392
##                                                             se(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.15620
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.16931
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.15950
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.15528
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.15684
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.18474
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.16735
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.21557
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.01547
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.16076
##                                                                  z
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness              -0.533
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -4.159
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.671
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.152
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -0.458
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     -0.271
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          -0.511
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.319
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               -1.336
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.727
##                                                             Pr(>|z|)    
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 0.594    
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  3.2e-05 ***
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.502    
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.879    
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.647    
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.786    
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.609    
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.749    
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.182    
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.467    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 0.9202
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.4946
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.1129
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.0239
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.9306
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.9511
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.9180
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.0713
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9796
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.1239
##                                                             exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                  1.0868
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     2.0219
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        0.8985
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          0.9766
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      1.0745
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         1.0514
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              1.0893
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     0.9335
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   1.0209
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    0.8897
##                                                             lower .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 0.6775
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.3549
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.8141
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.7552
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.6843
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.6622
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.6613
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.7021
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9503
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.8202
##                                                             upper .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 1.2498
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.6892
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.5213
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.3882
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     1.2656
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.3661
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.2744
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.6345
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  1.0097
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.5402
## 
## Concordance= 0.605  (se = 0.025 )
## Rsquare= 0.118   (max possible= 1 )
## Likelihood ratio test= 23.12  on 10 df,   p=0.01
## Wald test            = 23.71  on 10 df,   p=0.008
## Score (logrank) test = 24.56  on 10 df,   p=0.006
# Time to first CI
summary(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    20.0   124.2   193.0   504.4   657.0  4320.0     100
sd(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0)
## [1] NA
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$CONTTIME.0) ~ 
##     1)
## 
##    100 observations deleted due to missingness 
##       n  events  median 0.95LCL 0.95UCL 
##      84      84     193     155     330
# Figure time to first CI
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")

# Time to first CI depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    20.0   134.0   175.0   553.5   634.5  4320.0      60
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    45.0   121.5   212.0   450.4   660.5  1803.0      40
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness, rho = 1)
## 
## n=84, 100 observations deleted due to missingness.
## 
##                                                   N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0 44     22.3     22.3
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1 40     20.3     20.3
##                                                  (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0  5.71e-05   0.00018
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1  6.29e-05   0.00018
## 
##  Chisq= 0  on 1 degrees of freedom, p= 1
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.9893053
# Figure time to first CI by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first CI
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS + 
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "no", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$status + pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$SEX)
## 
##   n= 84, number of events= 84 
##    (100 observations deleted due to missingness)
## 
##                                                                  coef
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.174357
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.070192
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    -0.134197
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.698169
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -0.545110
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.468040
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.107528
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.181609
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.004185
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.226488
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               1.190481
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  1.072714
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.874418
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       2.010069
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.579778
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      1.596861
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           1.113522
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  1.199145
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                1.004194
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.254188
##                                                              se(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.245256
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.283565
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.233913
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.263791
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.280230
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.301080
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.281619
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.321661
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.024576
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.259774
##                                                                  z
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.711
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.248
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    -0.574
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       2.647
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -1.945
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      1.555
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.382
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.565
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.170
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.872
##                                                             Pr(>|z|)   
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness               0.47713   
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.80449   
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.56617   
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.00813 **
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.05175 . 
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.12006   
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.70259   
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.57235   
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.86479   
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.38328   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 1.1905
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    1.0727
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.8744
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         2.0101
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.5798
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.5969
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.1135
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.1991
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  1.0042
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.2542
##                                                             exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                  0.8400
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     0.9322
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        1.1436
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          0.4975
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      1.7248
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         0.6262
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              0.8981
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     0.8339
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   0.9958
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    0.7973
##                                                             lower .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                 0.7361
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.6153
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.5529
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.1986
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.3348
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.8851
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.6412
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.6384
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9570
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.7538
##                                                             upper .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness                  1.925
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     1.870
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        1.383
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          3.371
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      1.004
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         2.881
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              1.934
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     2.253
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   1.054
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    2.087
## 
## Concordance= 0.611  (se = 0.037 )
## Rsquare= 0.139   (max possible= 0.999 )
## Likelihood ratio test= 12.61  on 10 df,   p=0.2
## Wald test            = 12.47  on 10 df,   p=0.3
## Score (logrank) test = 12.65  on 10 df,   p=0.2
#### Recommendations and outliers out of the hospital

# First BZD later than 20 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  184 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        92 |        92 | 
##           |     0.500 |     0.500 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  104 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        49 |        55 | 
##           |     0.471 |     0.529 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  80 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        43 |        37 | 
##           |     0.537 |     0.463 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore20min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstBZDmore20min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.4572
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4098178 1.4326910
## sample estimates:
## odds ratio 
##  0.7677165
# Difference adjusting for covariates within the first 20 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, tau=20,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 20  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.200    -2.137     1.737 0.840
## RMST (arm=1)/(arm=0)  0.986     0.863     1.126 0.832
## RMTL (arm=1)/(arm=0)  1.033     0.710     1.502 0.866
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          18.166    1.686 10.775 0.000    14.862    21.470
## arm                -0.200    0.988 -0.202 0.840    -2.137     1.737
## TYPESTATUSnumeric   0.028    1.018  0.028 0.978    -1.967     2.023
## day                -0.614    0.989 -0.621 0.535    -2.551     1.324
## earlyacademicyear  -0.058    0.965 -0.060 0.952    -1.951     1.834
## white              -1.005    1.001 -1.004 0.316    -2.967     0.957
## structuraletiology -0.933    1.172 -0.796 0.426    -3.230     1.364
## priorepilepsy      -1.890    0.991 -1.908 0.056    -3.832     0.051
## status             -4.782    1.493 -3.202 0.001    -7.710    -1.855
## ageyears           -0.079    0.102 -0.775 0.438    -0.279     0.121
## SEXnumeric          0.219    0.985  0.222 0.824    -1.712     2.150
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.917    0.111 26.394 0.000    18.493    14.891
## arm                -0.014    0.068 -0.213 0.832     0.986     0.863
## TYPESTATUSnumeric   0.001    0.069  0.018 0.986     1.001     0.875
## day                -0.043    0.067 -0.645 0.519     0.957     0.839
## earlyacademicyear  -0.003    0.065 -0.045 0.964     0.997     0.877
## white              -0.068    0.068 -1.000 0.317     0.935     0.819
## structuraletiology -0.063    0.080 -0.782 0.434     0.939     0.803
## priorepilepsy      -0.126    0.068 -1.857 0.063     0.881     0.772
## status             -0.374    0.134 -2.787 0.005     0.688     0.529
## ageyears           -0.006    0.007 -0.796 0.426     0.994     0.981
## SEXnumeric          0.017    0.068  0.246 0.806     1.017     0.891
##                    upper .95
## intercept             22.966
## arm                    1.126
## TYPESTATUSnumeric      1.146
## day                    1.093
## earlyacademicyear      1.133
## white                  1.067
## structuraletiology     1.099
## priorepilepsy          1.007
## status                 0.895
## ageyears               1.008
## SEXnumeric             1.161
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           0.946    0.378  2.507 0.012     2.577     1.229
## arm                 0.032    0.191  0.168 0.866     1.033     0.710
## TYPESTATUSnumeric  -0.007    0.200 -0.036 0.972     0.993     0.671
## day                 0.106    0.190  0.560 0.575     1.112     0.767
## earlyacademicyear   0.018    0.191  0.096 0.923     1.019     0.700
## white               0.195    0.200  0.975 0.330     1.216     0.821
## structuraletiology  0.181    0.223  0.814 0.416     1.199     0.775
## priorepilepsy       0.393    0.205  1.919 0.055     1.482     0.992
## status              0.709    0.200  3.554 0.000     2.032     1.374
## ageyears            0.013    0.019  0.686 0.493     1.013     0.976
## SEXnumeric         -0.028    0.189 -0.150 0.881     0.972     0.671
##                    upper .95
## intercept              5.400
## arm                    1.502
## TYPESTATUSnumeric      1.470
## day                    1.614
## earlyacademicyear      1.482
## white                  1.800
## structuraletiology     1.855
## priorepilepsy          2.215
## status                 3.005
## ageyears               1.052
## SEXnumeric             1.408
# First BZD later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  184 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       123 |        61 | 
##           |     0.668 |     0.332 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  104 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        67 |        37 | 
##           |     0.644 |     0.356 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  80 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        56 |        24 | 
##           |     0.700 |     0.300 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore40min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstBZDmore40min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.4354
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3944499 1.5136049
## sample estimates:
## odds ratio 
##  0.7771317
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -1.169    -5.442     3.104 0.592
## RMST (arm=1)/(arm=0)  0.949     0.786     1.147 0.591
## RMTL (arm=1)/(arm=0)  1.071     0.834     1.375 0.592
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          28.607    3.467  8.250 0.000    21.811    35.403
## arm                -1.169    2.180 -0.536 0.592    -5.442     3.104
## TYPESTATUSnumeric  -2.849    2.163 -1.318 0.188    -7.088     1.389
## day                -0.639    2.168 -0.295 0.768    -4.889     3.610
## earlyacademicyear  -0.677    2.085 -0.325 0.745    -4.765     3.410
## white              -0.465    2.187 -0.213 0.832    -4.751     3.820
## structuraletiology  0.202    2.601  0.077 0.938    -4.895     5.298
## priorepilepsy      -0.914    2.184 -0.418 0.676    -5.195     3.367
## status             -8.573    3.058 -2.803 0.005   -14.566    -2.579
## ageyears           -0.178    0.215 -0.827 0.408    -0.600     0.244
## SEXnumeric         -0.112    2.168 -0.052 0.959    -4.361     4.136
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.371    0.145 23.286 0.000    29.100    21.912
## arm                -0.052    0.096 -0.538 0.591     0.949     0.786
## TYPESTATUSnumeric  -0.125    0.096 -1.302 0.193     0.882     0.730
## day                -0.032    0.094 -0.336 0.737     0.969     0.805
## earlyacademicyear  -0.026    0.090 -0.288 0.774     0.974     0.817
## white              -0.017    0.095 -0.176 0.860     0.983     0.816
## structuraletiology  0.011    0.109  0.099 0.921     1.011     0.817
## priorepilepsy      -0.042    0.093 -0.455 0.649     0.958     0.798
## status             -0.442    0.182 -2.421 0.015     0.643     0.450
## ageyears           -0.008    0.010 -0.819 0.413     0.992     0.974
## SEXnumeric          0.000    0.094  0.000 1.000     1.000     0.832
##                    upper .95
## intercept             38.646
## arm                    1.147
## TYPESTATUSnumeric      1.065
## day                    1.165
## earlyacademicyear      1.162
## white                  1.186
## structuraletiology     1.251
## priorepilepsy          1.151
## status                 0.919
## ageyears               1.011
## SEXnumeric             1.202
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.485    0.221 11.224 0.000    12.000     7.776
## arm                 0.068    0.128  0.536 0.592     1.071     0.834
## TYPESTATUSnumeric   0.168    0.127  1.321 0.187     1.182     0.922
## day                 0.031    0.129  0.240 0.810     1.032     0.800
## earlyacademicyear   0.046    0.125  0.370 0.711     1.047     0.820
## white               0.034    0.129  0.260 0.795     1.034     0.803
## structuraletiology -0.009    0.163 -0.056 0.956     0.991     0.720
## priorepilepsy       0.050    0.134  0.372 0.710     1.051     0.808
## status              0.433    0.146  2.970 0.003     1.542     1.159
## ageyears            0.010    0.013  0.830 0.407     1.010     0.986
## SEXnumeric          0.015    0.130  0.116 0.908     1.015     0.787
##                    upper .95
## intercept             18.519
## arm                    1.375
## TYPESTATUSnumeric      1.516
## day                    1.329
## earlyacademicyear      1.338
## white                  1.332
## structuraletiology     1.364
## priorepilepsy          1.367
## status                 2.052
## ageyears               1.036
## SEXnumeric             1.309
# First BZD later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  184 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       144 |        40 | 
##           |     0.783 |     0.217 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  104 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        78 |        26 | 
##           |     0.750 |     0.250 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  80 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        66 |        14 | 
##           |     0.825 |     0.175 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore60min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstBZDmore60min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.2799
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.2831795 1.3884282
## sample estimates:
## odds ratio 
##  0.6379075
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -2.000    -8.311     4.312 0.535
## RMST (arm=1)/(arm=0)  0.932     0.743     1.169 0.543
## RMTL (arm=1)/(arm=0)  1.066     0.874     1.301 0.526
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept           37.020    5.138  7.205 0.000    26.950    47.091
## arm                 -2.000    3.220 -0.621 0.535    -8.311     4.312
## TYPESTATUSnumeric   -5.881    3.163 -1.859 0.063   -12.080     0.319
## day                 -0.980    3.213 -0.305 0.760    -7.277     5.316
## earlyacademicyear   -1.408    3.092 -0.455 0.649    -7.467     4.651
## white               -0.941    3.250 -0.290 0.772    -7.312     5.429
## structuraletiology   0.746    3.846  0.194 0.846    -6.793     8.284
## priorepilepsy        1.503    3.264  0.460 0.645    -4.895     7.900
## status             -12.914    4.083 -3.163 0.002   -20.916    -4.911
## ageyears            -0.292    0.311 -0.940 0.347    -0.902     0.317
## SEXnumeric          -0.966    3.216 -0.301 0.764    -7.269     5.336
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.633    0.171 21.206 0.000    37.814    27.030
## arm                -0.070    0.116 -0.608 0.543     0.932     0.743
## TYPESTATUSnumeric  -0.209    0.116 -1.806 0.071     0.811     0.646
## day                -0.038    0.112 -0.338 0.735     0.963     0.773
## earlyacademicyear  -0.043    0.107 -0.402 0.688     0.958     0.776
## white              -0.027    0.114 -0.240 0.810     0.973     0.777
## structuraletiology  0.027    0.127  0.213 0.831     1.028     0.801
## priorepilepsy       0.045    0.111  0.411 0.681     1.046     0.843
## status             -0.548    0.206 -2.666 0.008     0.578     0.386
## ageyears           -0.010    0.011 -0.923 0.356     0.990     0.969
## SEXnumeric         -0.026    0.112 -0.236 0.813     0.974     0.783
##                    upper .95
## intercept             52.901
## arm                    1.169
## TYPESTATUSnumeric      1.018
## day                    1.199
## earlyacademicyear      1.182
## white                  1.218
## structuraletiology     1.319
## priorepilepsy          1.300
## status                 0.865
## ageyears               1.012
## SEXnumeric             1.212
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.164    0.175 18.055 0.000    23.659    16.782
## arm                 0.064    0.102  0.633 0.526     1.066     0.874
## TYPESTATUSnumeric   0.187    0.100  1.864 0.062     1.205     0.990
## day                 0.029    0.104  0.276 0.783     1.029     0.839
## earlyacademicyear   0.050    0.100  0.502 0.615     1.051     0.865
## white               0.034    0.104  0.331 0.740     1.035     0.844
## structuraletiology -0.024    0.130 -0.181 0.856     0.977     0.756
## priorepilepsy      -0.054    0.108 -0.497 0.619     0.948     0.767
## status              0.368    0.112  3.272 0.001     1.445     1.159
## ageyears            0.009    0.010  0.945 0.345     1.009     0.990
## SEXnumeric          0.037    0.105  0.351 0.726     1.037     0.845
##                    upper .95
## intercept             33.353
## arm                    1.301
## TYPESTATUSnumeric      1.467
## day                    1.261
## earlyacademicyear      1.278
## white                  1.269
## structuraletiology     1.261
## priorepilepsy          1.171
## status                 1.801
## ageyears               1.029
## SEXnumeric             1.273
# First non-BZD ASM later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  184 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        33 |       151 | 
##           |     0.179 |     0.821 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  104 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        23 |        81 | 
##           |     0.221 |     0.779 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  80 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        10 |        70 | 
##           |     0.125 |     0.875 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore40min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstASMmore40min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.1208
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.8375416 4.9984480
## sample estimates:
## odds ratio 
##   1.980487
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.030    -2.201     2.141 0.978
## RMST (arm=1)/(arm=0)  0.999     0.943     1.059 0.985
## RMTL (arm=1)/(arm=0)  1.056     0.468     2.386 0.895
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          34.368    2.061 16.671 0.000    30.327    38.408
## arm                -0.030    1.108 -0.027 0.978    -2.201     2.141
## TYPESTATUSnumeric  -0.866    1.023 -0.846 0.397    -2.872     1.140
## day                -0.397    1.140 -0.348 0.728    -2.631     1.837
## earlyacademicyear   1.519    1.057  1.438 0.151    -0.552     3.591
## white               0.819    1.101  0.744 0.457    -1.339     2.976
## structuraletiology  0.740    1.226  0.603 0.546    -1.664     3.143
## priorepilepsy       1.625    1.159  1.403 0.161    -0.646     3.896
## status              0.889    1.195  0.744 0.457    -1.453     3.231
## ageyears            0.069    0.112  0.617 0.537    -0.151     0.289
## SEXnumeric          1.344    1.104  1.217 0.224    -0.820     3.508
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.539    0.057 62.268 0.000    34.437    30.806
## arm                -0.001    0.030 -0.019 0.985     0.999     0.943
## TYPESTATUSnumeric  -0.023    0.028 -0.838 0.402     0.977     0.926
## day                -0.011    0.031 -0.350 0.726     0.989     0.932
## earlyacademicyear   0.041    0.029  1.422 0.155     1.041     0.985
## white               0.022    0.030  0.747 0.455     1.022     0.965
## structuraletiology  0.020    0.033  0.607 0.544     1.020     0.957
## priorepilepsy       0.044    0.031  1.395 0.163     1.045     0.982
## status              0.023    0.032  0.739 0.460     1.024     0.962
## ageyears            0.002    0.003  0.629 0.529     1.002     0.996
## SEXnumeric          0.036    0.030  1.205 0.228     1.037     0.978
##                    upper .95
## intercept             38.495
## arm                    1.059
## TYPESTATUSnumeric      1.031
## day                    1.050
## earlyacademicyear      1.101
## white                  1.084
## structuraletiology     1.088
## priorepilepsy          1.111
## status                 1.089
## ageyears               1.008
## SEXnumeric             1.099
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           1.884    0.582  3.236 0.001     6.581     2.102
## arm                 0.055    0.416  0.132 0.895     1.056     0.468
## TYPESTATUSnumeric   0.347    0.381  0.911 0.362     1.415     0.671
## day                 0.144    0.441  0.326 0.744     1.155     0.487
## earlyacademicyear  -0.632    0.420 -1.506 0.132     0.531     0.233
## white              -0.254    0.392 -0.648 0.517     0.776     0.359
## structuraletiology -0.274    0.479 -0.573 0.567     0.760     0.297
## priorepilepsy      -0.640    0.467 -1.371 0.170     0.527     0.211
## status             -0.448    0.605 -0.741 0.459     0.639     0.195
## ageyears           -0.021    0.048 -0.434 0.664     0.979     0.891
## SEXnumeric         -0.526    0.408 -1.287 0.198     0.591     0.266
##                    upper .95
## intercept             20.600
## arm                    2.386
## TYPESTATUSnumeric      2.987
## day                    2.740
## earlyacademicyear      1.210
## white                  1.673
## structuraletiology     1.944
## priorepilepsy          1.316
## status                 2.092
## ageyears               1.077
## SEXnumeric             1.316
# First non-BZD ASM later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  184 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        64 |       120 | 
##           |     0.348 |     0.652 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  104 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        40 |        64 | 
##           |     0.385 |     0.615 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  80 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        24 |        56 | 
##           |     0.300 |     0.700 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore60min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstASMmore60min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.2752
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.751433 2.855896
## sample estimates:
## odds ratio 
##   1.455339
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 2.272    -1.688     6.232 0.261
## RMST (arm=1)/(arm=0) 1.045     0.969     1.127 0.253
## RMTL (arm=1)/(arm=0) 0.754     0.428     1.329 0.329
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          45.873    3.766 12.180 0.000    38.491    53.255
## arm                 2.272    2.021  1.125 0.261    -1.688     6.232
## TYPESTATUSnumeric  -2.625    1.988 -1.320 0.187    -6.522     1.272
## day                -1.368    2.096 -0.653 0.514    -5.475     2.740
## earlyacademicyear   3.026    2.008  1.507 0.132    -0.910     6.962
## white               1.090    2.093  0.521 0.602    -3.012     5.191
## structuraletiology  0.818    2.430  0.336 0.737    -3.946     5.581
## priorepilepsy       4.116    2.139  1.925 0.054    -0.076     8.307
## status              1.694    2.253  0.752 0.452    -2.721     6.109
## ageyears            0.177    0.208  0.848 0.396    -0.232     0.585
## SEXnumeric          2.804    2.063  1.359 0.174    -1.240     6.848
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.830    0.075 50.957 0.000    46.077    39.765
## arm                 0.044    0.038  1.142 0.253     1.045     0.969
## TYPESTATUSnumeric  -0.050    0.039 -1.290 0.197     0.951     0.882
## day                -0.027    0.040 -0.665 0.506     0.974     0.900
## earlyacademicyear   0.058    0.039  1.495 0.135     1.059     0.982
## white               0.022    0.041  0.534 0.593     1.022     0.944
## structuraletiology  0.016    0.047  0.345 0.730     1.016     0.927
## priorepilepsy       0.079    0.041  1.916 0.055     1.082     0.998
## status              0.031    0.042  0.745 0.456     1.032     0.950
## ageyears            0.003    0.004  0.873 0.383     1.003     0.996
## SEXnumeric          0.054    0.040  1.339 0.181     1.055     0.975
##                    upper .95
## intercept             53.391
## arm                    1.127
## TYPESTATUSnumeric      1.026
## day                    1.053
## earlyacademicyear      1.143
## white                  1.106
## structuraletiology     1.114
## priorepilepsy          1.174
## status                 1.120
## ageyears               1.011
## SEXnumeric             1.141
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.739    0.407  6.737 0.000    15.475     6.975
## arm                -0.282    0.289 -0.977 0.329     0.754     0.428
## TYPESTATUSnumeric   0.358    0.249  1.437 0.151     1.431     0.878
## day                 0.163    0.287  0.569 0.570     1.177     0.671
## earlyacademicyear  -0.420    0.281 -1.493 0.135     0.657     0.379
## white              -0.112    0.260 -0.430 0.667     0.894     0.537
## structuraletiology -0.091    0.309 -0.293 0.770     0.913     0.498
## priorepilepsy      -0.545    0.304 -1.791 0.073     0.580     0.320
## status             -0.268    0.375 -0.715 0.475     0.765     0.367
## ageyears           -0.021    0.032 -0.656 0.512     0.979     0.920
## SEXnumeric         -0.382    0.266 -1.437 0.151     0.683     0.406
##                    upper .95
## intercept             34.332
## arm                    1.329
## TYPESTATUSnumeric      2.331
## day                    2.067
## earlyacademicyear      1.140
## white                  1.489
## structuraletiology     1.674
## priorepilepsy          1.053
## status                 1.595
## ageyears               1.043
## SEXnumeric             1.149
# First non-BZD ASM later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  184 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       115 |        69 | 
##           |     0.625 |     0.375 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  104 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        66 |        38 | 
##           |     0.635 |     0.365 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  80 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        49 |        31 | 
##           |     0.613 |     0.388 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore120min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstASMmore120min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.7614
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.575250 2.092045
## sample estimates:
## odds ratio 
##   1.098254
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, tau=120,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 4.405    -6.157    14.967 0.414
## RMST (arm=1)/(arm=0) 1.055     0.928     1.199 0.414
## RMTL (arm=1)/(arm=0) 0.889     0.668     1.182 0.417
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept           78.960    8.712  9.063 0.000    61.884    96.036
## arm                  4.405    5.389  0.817 0.414    -6.157    14.967
## TYPESTATUSnumeric  -21.119    5.338 -3.956 0.000   -31.581   -10.656
## day                 -3.537    5.352 -0.661 0.509   -14.027     6.954
## earlyacademicyear    3.312    5.308  0.624 0.533    -7.090    13.715
## white                1.138    5.538  0.205 0.837    -9.717    11.992
## structuraletiology  -2.087    6.705 -0.311 0.756   -15.229    11.055
## priorepilepsy        9.024    5.564  1.622 0.105    -1.882    19.931
## status              -1.581    6.676 -0.237 0.813   -14.666    11.504
## ageyears             0.514    0.533  0.963 0.335    -0.532     1.559
## SEXnumeric           4.154    5.427  0.765 0.444    -6.484    14.792
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.361    0.109 39.871 0.000    78.305    63.197
## arm                 0.053    0.065  0.818 0.414     1.055     0.928
## TYPESTATUSnumeric  -0.267    0.071 -3.778 0.000     0.765     0.666
## day                -0.043    0.065 -0.656 0.512     0.958     0.843
## earlyacademicyear   0.042    0.065  0.647 0.518     1.043     0.919
## white               0.014    0.069  0.199 0.842     1.014     0.886
## structuraletiology -0.024    0.083 -0.286 0.775     0.977     0.830
## priorepilepsy       0.109    0.068  1.607 0.108     1.115     0.976
## status             -0.019    0.082 -0.226 0.821     0.982     0.836
## ageyears            0.006    0.006  1.011 0.312     1.006     0.994
## SEXnumeric          0.051    0.067  0.760 0.447     1.052     0.923
##                    upper .95
## intercept             97.025
## arm                    1.199
## TYPESTATUSnumeric      0.879
## day                    1.089
## earlyacademicyear      1.183
## white                  1.160
## structuraletiology     1.149
## priorepilepsy          1.274
## status                 1.152
## ageyears               1.018
## SEXnumeric             1.199
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.672    0.227 16.185 0.000    39.338    25.217
## arm                -0.118    0.145 -0.812 0.417     0.889     0.668
## TYPESTATUSnumeric   0.535    0.139  3.841 0.000     1.707     1.299
## day                 0.096    0.145  0.657 0.511     1.100     0.827
## earlyacademicyear  -0.081    0.146 -0.556 0.579     0.922     0.693
## white              -0.031    0.143 -0.219 0.827     0.969     0.732
## structuraletiology  0.063    0.172  0.365 0.715     1.065     0.759
## priorepilepsy      -0.245    0.153 -1.606 0.108     0.782     0.580
## status              0.050    0.177  0.281 0.778     1.051     0.742
## ageyears           -0.014    0.017 -0.847 0.397     0.986     0.954
## SEXnumeric         -0.110    0.145 -0.760 0.447     0.896     0.675
##                    upper .95
## intercept             61.367
## arm                    1.182
## TYPESTATUSnumeric      2.242
## day                    1.463
## earlyacademicyear      1.227
## white                  1.282
## structuraletiology     1.493
## priorepilepsy          1.056
## status                 1.488
## ageyears               1.019
## SEXnumeric             1.189
# First CI later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         6 |        78 | 
##           |     0.071 |     0.929 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  44 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         3 |        41 | 
##           |     0.068 |     0.932 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  40 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         3 |        37 | 
##           |     0.075 |     0.925 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore60min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstCImore60min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1138188 7.1711526
## sample estimates:
## odds ratio 
##  0.9035448
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$awareness, tau=60,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.868    -1.037     2.773 0.372
## RMST (arm=1)/(arm=0) 1.015     0.982     1.049 0.378
## RMTL (arm=1)/(arm=0) 0.349     0.039     3.116 0.346
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          59.711    1.067 55.977 0.000    57.620    61.801
## arm                 0.868    0.972  0.893 0.372    -1.037     2.773
## TYPESTATUSnumeric   0.345    0.621  0.555 0.579    -0.872     1.562
## day                -0.143    1.036 -0.138 0.890    -2.173     1.888
## earlyacademicyear  -1.947    1.111 -1.753 0.080    -4.125     0.230
## white              -1.000    1.070 -0.934 0.350    -3.096     1.097
## structuraletiology  0.554    0.558  0.994 0.320    -0.539     1.648
## priorepilepsy      -0.950    1.170 -0.812 0.417    -3.242     1.342
## status              1.426    0.924  1.544 0.123    -0.384     3.236
## ageyears           -0.061    0.066 -0.923 0.356    -0.190     0.068
## SEXnumeric          1.619    1.399  1.157 0.247    -1.123     4.361
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)       z     p exp(coef) lower .95
## intercept           4.089    0.018 222.750 0.000    59.686    57.577
## arm                 0.015    0.017   0.882 0.378     1.015     0.982
## TYPESTATUSnumeric   0.006    0.010   0.544 0.586     1.006     0.985
## day                -0.002    0.018  -0.125 0.900     0.998     0.964
## earlyacademicyear  -0.033    0.019  -1.725 0.084     0.968     0.932
## white              -0.017    0.018  -0.924 0.356     0.983     0.948
## structuraletiology  0.009    0.010   0.979 0.327     1.009     0.991
## priorepilepsy      -0.016    0.020  -0.804 0.422     0.984     0.946
## status              0.024    0.016   1.529 0.126     1.024     0.993
## ageyears           -0.001    0.001  -0.916 0.360     0.999     0.997
## SEXnumeric          0.028    0.024   1.139 0.255     1.028     0.980
##                    upper .95
## intercept             61.873
## arm                    1.049
## TYPESTATUSnumeric      1.027
## day                    1.033
## earlyacademicyear      1.004
## white                  1.019
## structuraletiology     1.029
## priorepilepsy          1.023
## status                 1.056
## ageyears               1.001
## SEXnumeric             1.078
## 
## 
## Model summary (ratio of time-lost) 
##                       coef se(coef)       z     p exp(coef) lower .95
## intercept           -4.309    3.369  -1.279 0.201     0.013     0.000
## arm                 -1.052    1.117  -0.942 0.346     0.349     0.039
## TYPESTATUSnumeric   -1.227    1.663  -0.738 0.461     0.293     0.011
## day                  1.768    1.968   0.899 0.369     5.860     0.124
## earlyacademicyear    3.244    1.241   2.613 0.009    25.631     2.249
## white                1.487    1.799   0.827 0.408     4.426     0.130
## structuraletiology  -1.817    1.414  -1.285 0.199     0.163     0.010
## priorepilepsy        1.820    1.258   1.447 0.148     6.172     0.524
## status             -18.014    1.171 -15.389 0.000     0.000     0.000
## ageyears             0.020    0.068   0.292 0.770     1.020     0.892
## SEXnumeric          -1.859    1.232  -1.509 0.131     0.156     0.014
##                    upper .95
## intercept              9.905
## arm                    3.116
## TYPESTATUSnumeric      7.630
## day                  277.142
## earlyacademicyear    292.038
## white                150.436
## structuraletiology     2.596
## priorepilepsy         72.654
## status                 0.000
## ageyears               1.166
## SEXnumeric             1.743
# First CI later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        20 |        64 | 
##           |     0.238 |     0.762 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  44 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        10 |        34 | 
##           |     0.227 |     0.773 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  40 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        10 |        30 | 
##           |     0.250 |     0.750 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore120min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstCImore120min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.2855764 2.7315767
## sample estimates:
## odds ratio 
##  0.8836722
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$awareness, tau=120,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.539   -10.107     9.028 0.912
## RMST (arm=1)/(arm=0)  0.994     0.910     1.086 0.899
## RMTL (arm=1)/(arm=0)  0.948     0.378     2.375 0.909
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          111.102    8.640 12.859 0.000    94.167   128.037
## arm                 -0.539    4.882 -0.111 0.912   -10.107     9.028
## TYPESTATUSnumeric    2.442    4.783  0.510 0.610    -6.933    11.817
## day                 -4.092    5.048 -0.811 0.418   -13.986     5.802
## earlyacademicyear   -8.922    5.315 -1.678 0.093   -19.339     1.496
## white                6.470    5.312  1.218 0.223    -3.942    16.881
## structuraletiology   1.333    5.935  0.225 0.822   -10.300    12.966
## priorepilepsy       -5.198    5.520 -0.942 0.346   -16.017     5.621
## status               9.993    4.750  2.104 0.035     0.683    19.304
## ageyears             0.080    0.436  0.182 0.855    -0.775     0.935
## SEXnumeric           1.098    5.093  0.216 0.829    -8.884    11.080
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.709    0.079 59.673 0.000   110.989    95.083
## arm                -0.006    0.045 -0.128 0.899     0.994     0.910
## TYPESTATUSnumeric   0.023    0.044  0.532 0.595     1.023     0.940
## day                -0.038    0.046 -0.819 0.413     0.963     0.880
## earlyacademicyear  -0.082    0.049 -1.658 0.097     0.922     0.837
## white               0.059    0.049  1.217 0.223     1.061     0.964
## structuraletiology  0.011    0.055  0.200 0.841     1.011     0.908
## priorepilepsy      -0.047    0.051 -0.926 0.354     0.954     0.863
## status              0.089    0.043  2.083 0.037     1.093     1.005
## ageyears            0.001    0.004  0.177 0.860     1.001     0.993
## SEXnumeric          0.010    0.046  0.220 0.825     1.010     0.922
##                    upper .95
## intercept            129.556
## arm                    1.086
## TYPESTATUSnumeric      1.115
## day                    1.054
## earlyacademicyear      1.015
## white                  1.168
## structuraletiology     1.126
## priorepilepsy          1.054
## status                 1.189
## ageyears               1.009
## SEXnumeric             1.107
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.005    0.984  2.037 0.042     7.424     1.079
## arm                -0.054    0.469 -0.115 0.909     0.948     0.378
## TYPESTATUSnumeric  -0.148    0.520 -0.285 0.775     0.862     0.311
## day                 0.374    0.529  0.707 0.480     1.453     0.515
## earlyacademicyear   0.944    0.619  1.524 0.127     2.571     0.763
## white              -0.613    0.553 -1.109 0.267     0.541     0.183
## structuraletiology -0.216    0.600 -0.360 0.719     0.806     0.248
## priorepilepsy       0.540    0.518  1.043 0.297     1.716     0.622
## status             -1.411    0.786 -1.796 0.073     0.244     0.052
## ageyears           -0.009    0.045 -0.210 0.834     0.991     0.907
## SEXnumeric         -0.078    0.524 -0.148 0.882     0.925     0.332
##                    upper .95
## intercept             51.081
## arm                    2.375
## TYPESTATUSnumeric      2.387
## day                    4.097
## earlyacademicyear      8.658
## white                  1.601
## structuraletiology     2.612
## priorepilepsy          4.738
## status                 1.138
## ageyears               1.082
## SEXnumeric             2.582
# First CI later than 240 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        48 |        36 | 
##           |     0.571 |     0.429 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 0, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  44 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        26 |        18 | 
##           |     0.591 |     0.409 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness == 1, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  40 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        22 |        18 | 
##           |     0.550 |     0.450 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore240min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstCImore240min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness
## p-value = 0.8258
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4553598 3.0670885
## sample estimates:
## odds ratio 
##   1.179461
# Difference adjusting for covariates within the first 240 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$awareness, tau=240,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 240  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 7.108   -21.777    35.993 0.630
## RMST (arm=1)/(arm=0) 1.038     0.880     1.225 0.655
## RMTL (arm=1)/(arm=0) 0.879     0.560     1.379 0.575
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          186.160   26.456  7.037 0.000   134.306   238.013
## arm                  7.108   14.738  0.482 0.630   -21.777    35.993
## TYPESTATUSnumeric  -18.507   16.350 -1.132 0.258   -50.553    13.539
## day                 -7.458   15.821 -0.471 0.637   -38.467    23.551
## earlyacademicyear  -28.063   15.408 -1.821 0.069   -58.262     2.136
## white               22.826   16.055  1.422 0.155    -8.641    54.292
## structuraletiology  -5.083   18.279 -0.278 0.781   -40.910    30.743
## priorepilepsy        7.979   16.867  0.473 0.636   -25.079    41.037
## status              11.422   16.611  0.688 0.492   -21.135    43.978
## ageyears            -0.619    1.408 -0.440 0.660    -3.378     2.140
## SEXnumeric          -8.264   14.425 -0.573 0.567   -36.536    20.009
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           5.218    0.148 35.216 0.000   184.504   138.004
## arm                 0.038    0.084  0.446 0.655     1.038     0.880
## TYPESTATUSnumeric  -0.108    0.097 -1.113 0.266     0.898     0.742
## day                -0.038    0.088 -0.431 0.667     0.963     0.809
## earlyacademicyear  -0.158    0.088 -1.802 0.072     0.854     0.719
## white               0.132    0.095  1.386 0.166     1.141     0.947
## structuraletiology -0.029    0.106 -0.275 0.784     0.971     0.790
## priorepilepsy       0.046    0.094  0.492 0.623     1.047     0.872
## status              0.069    0.092  0.750 0.454     1.072     0.894
## ageyears           -0.004    0.008 -0.447 0.655     0.996     0.981
## SEXnumeric         -0.046    0.082 -0.564 0.573     0.955     0.813
##                    upper .95
## intercept            246.673
## arm                    1.225
## TYPESTATUSnumeric      1.086
## day                    1.145
## earlyacademicyear      1.014
## white                  1.374
## structuraletiology     1.195
## priorepilepsy          1.258
## status                 1.284
## ageyears               1.012
## SEXnumeric             1.121
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.908    0.459  8.512 0.000    49.821    20.256
## arm                -0.129    0.230 -0.561 0.575     0.879     0.560
## TYPESTATUSnumeric   0.275    0.240  1.144 0.253     1.316     0.822
## day                 0.154    0.268  0.574 0.566     1.166     0.689
## earlyacademicyear   0.465    0.266  1.749 0.080     1.593     0.945
## white              -0.347    0.242 -1.436 0.151     0.707     0.440
## structuraletiology  0.084    0.279  0.299 0.765     1.087     0.629
## priorepilepsy      -0.116    0.287 -0.405 0.686     0.890     0.508
## status             -0.152    0.288 -0.529 0.597     0.859     0.489
## ageyears            0.009    0.023  0.410 0.682     1.010     0.965
## SEXnumeric          0.137    0.234  0.584 0.559     1.147     0.724
##                    upper .95
## intercept            122.540
## arm                    1.379
## TYPESTATUSnumeric      2.107
## day                    1.973
## earlyacademicyear      2.683
## white                  1.135
## structuraletiology     1.880
## priorepilepsy          1.562
## status                 1.510
## ageyears               1.056
## SEXnumeric             1.816
## IN THE HOSPITAL

# Patients in each group
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        46 |        38 | 
##           |     0.548 |     0.452 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Time to first BZD
summary(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    4.00   10.00   30.83   24.25  360.00
sd(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0)
## [1] 62.38161
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$BZDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##      84      84      10       5      16
# Figure time to first BZD
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")

# Time to first BZD depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    4.25    8.00   37.35   25.75  360.00
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    4.00   11.00   22.95   23.75  205.00
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness, rho = 1)
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0 46     24.4     24.2
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1 38     19.6     19.8
##                                                   (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0   0.00150   0.00518
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1   0.00183   0.00518
## 
##  Chisq= 0  on 1 degrees of freedom, p= 0.9
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.9426513
# Figure time to first BZD by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first BZD
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness + pSERG[pSERG$HOSPITALONSET=="yes", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="yes", ]$day + pSERG[pSERG$HOSPITALONSET=="yes", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="yes", ]$white +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="yes", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$status + pSERG[pSERG$HOSPITALONSET=="yes", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="yes", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "yes", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$status + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$ageyears + pSERG[pSERG$HOSPITALONSET == "yes", ]$SEX)
## 
##   n= 84, number of events= 84 
## 
##                                                                  coef
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.20359
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.09299
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.27563
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.44339
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.01725
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology     -0.03145
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.04092
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.04204
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.02085
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.07752
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                1.22579
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent   0.91120
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                      1.31736
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear        1.55798
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                    0.98290
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology       0.96904
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy            1.04176
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                   1.04294
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                 0.97937
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                  1.08060
##                                                              se(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.24045
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.30879
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.27596
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.25452
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.24402
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.26061
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.30875
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.34202
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.02320
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.25721
##                                                                   z
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.847
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.301
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.999
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       1.742
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.071
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology     -0.121
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.133
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.123
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.899
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.301
##                                                              Pr(>|z|)  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                0.3972  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent   0.7633  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                      0.3179  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear        0.0815 .
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                    0.9436  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology       0.9039  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy            0.8946  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                   0.9022  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                 0.3689  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                  0.7631  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                 1.2258
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.9112
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       1.3174
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         1.5580
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.9829
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.9690
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             1.0418
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    1.0429
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9794
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   1.0806
##                                                              exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                  0.8158
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.0975
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        0.7591
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          0.6419
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.0174
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.0320
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              0.9599
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     0.9588
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.0211
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    0.9254
##                                                              lower .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                 0.7652
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.4975
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.7670
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.9460
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.6093
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.5814
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.5688
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.5335
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9358
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.6527
##                                                              upper .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                  1.964
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.669
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        2.263
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          2.566
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.586
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.615
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              1.908
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     2.039
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.025
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    1.789
## 
## Concordance= 0.599  (se = 0.04 )
## Rsquare= 0.096   (max possible= 0.999 )
## Likelihood ratio test= 8.44  on 10 df,   p=0.6
## Wald test            = 8.44  on 10 df,   p=0.6
## Score (logrank) test = 8.6  on 10 df,   p=0.6
# Time to first non-BZD AED
summary(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    3.00   21.75   39.00   85.01   76.25 1419.00
sd(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0)
## [1] 171.8644
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$AEDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##      84      84      39      29      58
# Figure time to first non-BZD AED
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")

# Time to first non-BZD AED depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    5.00   20.25   44.50   79.70   86.75  503.00
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    3.00   23.00   32.00   91.45   73.25 1419.00
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness, rho = 1)
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0 46     22.9     24.2
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1 38     20.1     18.8
##                                                   (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0    0.0709     0.244
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1    0.0912     0.244
## 
##  Chisq= 0.2  on 1 degrees of freedom, p= 0.6
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.6209923
# Figure time to first non-BZD AED by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first non-BZD AED
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness + pSERG[pSERG$HOSPITALONSET=="yes", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="yes", ]$day + pSERG[pSERG$HOSPITALONSET=="yes", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="yes", ]$white +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="yes", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$status + pSERG[pSERG$HOSPITALONSET=="yes", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="yes", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "yes", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$status + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$ageyears + pSERG[pSERG$HOSPITALONSET == "yes", ]$SEX)
## 
##   n= 84, number of events= 84 
## 
##                                                                  coef
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.17987
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.25701
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.47509
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.24427
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.09484
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.47641
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.29502
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.20221
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.04027
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                -0.11923
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                1.19706
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent   0.77336
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                      1.60817
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear        1.27668
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                    0.90952
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology       1.61028
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy            1.34315
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                   1.22411
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                 0.96053
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                  0.88760
##                                                              se(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.23451
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.29931
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.26435
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.24968
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.25907
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.26620
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.29510
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.34282
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.02291
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.26059
##                                                                   z
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.767
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.859
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     1.797
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.978
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.366
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      1.790
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           1.000
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.590
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -1.758
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                -0.458
##                                                              Pr(>|z|)  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                0.4431  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent   0.3905  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                      0.0723 .
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear        0.3279  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                    0.7143  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology       0.0735 .
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy            0.3175  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                   0.5553  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                 0.0788 .
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                  0.6473  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                 1.1971
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.7734
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       1.6082
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         1.2767
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.9095
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        1.6103
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             1.3431
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    1.2241
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9605
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.8876
##                                                              exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                  0.8354
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.2931
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        0.6218
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          0.7833
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.0995
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         0.6210
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              0.7445
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     0.8169
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.0411
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    1.1266
##                                                              lower .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                 0.7560
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.4301
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.9579
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.7826
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.5474
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.9557
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.7532
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.6252
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9184
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.5326
##                                                              upper .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                  1.896
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.390
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        2.700
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          2.083
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.511
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         2.713
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              2.395
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     2.397
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.005
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    1.479
## 
## Concordance= 0.603  (se = 0.038 )
## Rsquare= 0.165   (max possible= 0.999 )
## Likelihood ratio test= 15.19  on 10 df,   p=0.1
## Wald test            = 15.06  on 10 df,   p=0.1
## Score (logrank) test = 15.39  on 10 df,   p=0.1
# Time to first CI
summary(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   122.0   210.0   569.9   495.0  7200.0      49
sd(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0)
## [1] NA
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$CONTTIME.0) ~ 
##     1)
## 
##    49 observations deleted due to missingness 
##       n  events  median 0.95LCL 0.95UCL 
##      35      35     210     165     420
# Figure time to first CI
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")

# Time to first CI depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   121.0   210.0   386.6   462.0  2520.0      23
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##   112.0   131.8   205.0   921.2   535.5  7200.0      26
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness, rho = 1)
## 
## n=35, 49 observations deleted due to missingness.
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0 23    12.43    11.46
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1 12     5.74     6.71
##                                                   (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0    0.0824     0.337
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1    0.1405     0.337
## 
##  Chisq= 0.3  on 1 degrees of freedom, p= 0.6
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.5615184
# Figure time to first CI by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")
legend("topleft", legend=c("2011-2014", "2015-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first CI
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness + pSERG[pSERG$HOSPITALONSET=="yes", ]$TYPESTATUS + 
                pSERG[pSERG$HOSPITALONSET=="yes", ]$day + pSERG[pSERG$HOSPITALONSET=="yes", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="yes", ]$white +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="yes", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$status + pSERG[pSERG$HOSPITALONSET=="yes", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="yes", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "yes", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$status + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$ageyears + pSERG[pSERG$HOSPITALONSET == "yes", ]$SEX)
## 
##   n= 35, number of events= 35 
##    (49 observations deleted due to missingness)
## 
##                                                                  coef
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness              -0.13006
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.48181
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.12130
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.49313
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.13659
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology     -0.68336
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.87712
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                 -0.35798
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.04150
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.91148
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                0.87804
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent   0.61766
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                      1.12896
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear        1.63743
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                    1.14636
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology       0.50492
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy            2.40397
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                   0.69908
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                 0.95935
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                  2.48801
##                                                              se(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness               0.42653
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.53007
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.43882
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.43057
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.45245
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.49232
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.60658
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.78838
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.04388
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.47372
##                                                                   z
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness              -0.305
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.909
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.276
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       1.145
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.302
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology     -1.388
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           1.446
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                 -0.454
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.946
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 1.924
##                                                              Pr(>|z|)  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                0.7604  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent   0.3634  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                      0.7822  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear        0.2521  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                    0.7627  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology       0.1651  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy            0.1482  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                   0.6498  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                 0.3443  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                  0.0543 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                 0.8780
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.6177
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       1.1290
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         1.6374
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     1.1464
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.5049
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             2.4040
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.6991
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9594
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   2.4880
##                                                              exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                  1.1389
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.6190
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        0.8858
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          0.6107
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      0.8723
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.9805
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              0.4160
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     1.4304
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.0424
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    0.4019
##                                                              lower .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                 0.3806
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.2186
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.4777
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.7041
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.4723
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.1924
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.7322
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.1491
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.8803
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.9832
##                                                              upper .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness                  2.026
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.746
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        2.668
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          3.808
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      2.783
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.325
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              7.893
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     3.278
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.046
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    6.296
## 
## Concordance= 0.645  (se = 0.06 )
## Rsquare= 0.284   (max possible= 0.995 )
## Likelihood ratio test= 11.68  on 10 df,   p=0.3
## Wald test            = 10.51  on 10 df,   p=0.4
## Score (logrank) test = 11.63  on 10 df,   p=0.3
#### Recommendations and outliers in the hospital

# First BZD later than 20 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        57 |        27 | 
##           |     0.679 |     0.321 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  46 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        32 |        14 | 
##           |     0.696 |     0.304 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  38 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        25 |        13 | 
##           |     0.658 |     0.342 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore20min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstBZDmore20min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 0.8155
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4275735 3.2848535
## sample estimates:
## odds ratio 
##   1.186115
# Difference adjusting for covariates within the first 20 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, tau=20,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 20  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.215    -2.895     3.325 0.892
## RMST (arm=1)/(arm=0) 1.030     0.777     1.366 0.836
## RMTL (arm=1)/(arm=0) 0.990     0.692     1.418 0.958
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          10.006    2.362  4.237 0.000     5.377    14.635
## arm                 0.215    1.587  0.136 0.892    -2.895     3.325
## TYPESTATUSnumeric  -0.098    1.850 -0.053 0.958    -3.724     3.529
## day                -2.159    1.600 -1.350 0.177    -5.294     0.976
## earlyacademicyear  -2.253    1.686 -1.336 0.181    -5.557     1.051
## white               0.983    1.708  0.575 0.565    -2.366     4.331
## structuraletiology -0.263    1.747 -0.150 0.880    -3.686     3.161
## priorepilepsy       1.780    1.877  0.948 0.343    -1.899     5.460
## status              0.317    2.037  0.156 0.876    -3.676     4.310
## ageyears            0.249    0.159  1.566 0.117    -0.063     0.561
## SEXnumeric          0.845    1.779  0.475 0.635    -2.641     4.331
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.293    0.222 10.319 0.000     9.901     6.406
## arm                 0.030    0.144  0.207 0.836     1.030     0.777
## TYPESTATUSnumeric  -0.018    0.172 -0.105 0.916     0.982     0.700
## day                -0.182    0.144 -1.261 0.207     0.834     0.629
## earlyacademicyear  -0.202    0.157 -1.285 0.199     0.817     0.600
## white               0.079    0.162  0.486 0.627     1.082     0.787
## structuraletiology -0.018    0.161 -0.113 0.910     0.982     0.716
## priorepilepsy       0.151    0.167  0.904 0.366     1.163     0.838
## status              0.043    0.166  0.261 0.794     1.044     0.754
## ageyears            0.021    0.014  1.545 0.122     1.021     0.994
## SEXnumeric          0.062    0.165  0.377 0.706     1.064     0.770
##                    upper .95
## intercept             15.304
## arm                    1.366
## TYPESTATUSnumeric      1.377
## day                    1.106
## earlyacademicyear      1.112
## white                  1.488
## structuraletiology     1.346
## priorepilepsy          1.613
## status                 1.447
## ageyears               1.049
## SEXnumeric             1.471
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.286    0.265  8.616 0.000     9.832     5.846
## arm                -0.010    0.183 -0.052 0.958     0.990     0.692
## TYPESTATUSnumeric  -0.003    0.209 -0.012 0.990     0.997     0.662
## day                 0.270    0.188  1.435 0.151     1.310     0.906
## earlyacademicyear   0.262    0.193  1.361 0.174     1.300     0.891
## white              -0.131    0.189 -0.696 0.486     0.877     0.606
## structuraletiology  0.040    0.197  0.203 0.839     1.041     0.707
## priorepilepsy      -0.223    0.234 -0.954 0.340     0.800     0.506
## status             -0.011    0.275 -0.041 0.967     0.989     0.576
## ageyears           -0.031    0.020 -1.520 0.129     0.970     0.932
## SEXnumeric         -0.125    0.201 -0.621 0.534     0.882     0.595
##                    upper .95
## intercept             16.538
## arm                    1.418
## TYPESTATUSnumeric      1.504
## day                    1.894
## earlyacademicyear      1.895
## white                  1.269
## structuraletiology     1.532
## priorepilepsy          1.265
## status                 1.696
## ageyears               1.009
## SEXnumeric             1.309
# First BZD later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        69 |        15 | 
##           |     0.821 |     0.179 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  46 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        36 |        10 | 
##           |     0.783 |     0.217 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  38 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        33 |         5 | 
##           |     0.868 |     0.132 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore40min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstBZDmore40min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 0.3956
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1328788 1.9896477
## sample estimates:
## odds ratio 
##  0.5493172
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -1.965    -7.604     3.673 0.495
## RMST (arm=1)/(arm=0)  0.884     0.619     1.263 0.499
## RMTL (arm=1)/(arm=0)  1.085     0.855     1.376 0.503
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          15.388    4.701  3.273 0.001     6.175    24.601
## arm                -1.965    2.877 -0.683 0.495    -7.604     3.673
## TYPESTATUSnumeric  -3.274    3.031 -1.080 0.280    -9.214     2.666
## day                -2.768    3.070 -0.902 0.367    -8.785     3.249
## earlyacademicyear  -4.548    3.053 -1.490 0.136   -10.531     1.435
## white               2.015    3.316  0.608 0.543    -4.485     8.514
## structuraletiology  0.512    3.257  0.157 0.875    -5.871     6.895
## priorepilepsy       2.170    3.645  0.595 0.552    -4.975     9.315
## status             -0.598    3.974 -0.150 0.880    -8.386     7.191
## ageyears            0.638    0.291  2.190 0.029     0.067     1.209
## SEXnumeric         -1.607    3.093 -0.520 0.603    -7.670     4.455
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.702    0.315  8.590 0.000    14.909     8.048
## arm                -0.123    0.182 -0.677 0.499     0.884     0.619
## TYPESTATUSnumeric  -0.239    0.220 -1.090 0.276     0.787     0.512
## day                -0.164    0.192 -0.858 0.391     0.848     0.583
## earlyacademicyear  -0.296    0.200 -1.479 0.139     0.743     0.502
## white               0.123    0.215  0.572 0.568     1.131     0.742
## structuraletiology  0.055    0.208  0.266 0.791     1.057     0.702
## priorepilepsy       0.130    0.218  0.593 0.553     1.138     0.742
## status             -0.005    0.231 -0.023 0.982     0.995     0.632
## ageyears            0.039    0.017  2.309 0.021     1.040     1.006
## SEXnumeric         -0.136    0.202 -0.675 0.500     0.873     0.588
##                    upper .95
## intercept             27.619
## arm                    1.263
## TYPESTATUSnumeric      1.210
## day                    1.235
## earlyacademicyear      1.101
## white                  1.723
## structuraletiology     1.590
## priorepilepsy          1.746
## status                 1.565
## ageyears               1.074
## SEXnumeric             1.296
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.192    0.196 16.321 0.000    24.330    16.584
## arm                 0.081    0.121  0.670 0.503     1.085     0.855
## TYPESTATUSnumeric   0.127    0.122  1.040 0.298     1.135     0.894
## day                 0.120    0.132  0.910 0.363     1.127     0.871
## earlyacademicyear   0.187    0.129  1.447 0.148     1.205     0.936
## white              -0.087    0.139 -0.622 0.534     0.917     0.698
## structuraletiology -0.011    0.136 -0.080 0.936     0.989     0.758
## priorepilepsy      -0.094    0.163 -0.579 0.563     0.910     0.661
## status              0.037    0.180  0.205 0.837     1.038     0.729
## ageyears           -0.027    0.014 -2.003 0.045     0.973     0.947
## SEXnumeric          0.051    0.129  0.392 0.695     1.052     0.817
##                    upper .95
## intercept             35.694
## arm                    1.376
## TYPESTATUSnumeric      1.442
## day                    1.459
## earlyacademicyear      1.553
## white                  1.205
## structuraletiology     1.291
## priorepilepsy          1.252
## status                 1.478
## ageyears               0.999
## SEXnumeric             1.354
# First BZD later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        73 |        11 | 
##           |     0.869 |     0.131 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  46 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        38 |         8 | 
##           |     0.826 |     0.174 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  38 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        35 |         3 | 
##           |     0.921 |     0.079 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore60min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstBZDmore60min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 0.3304
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.06512687 1.88926369
## sample estimates:
## odds ratio 
##  0.4112813
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -4.601   -12.197     2.996 0.235
## RMST (arm=1)/(arm=0)  0.768     0.515     1.146 0.196
## RMTL (arm=1)/(arm=0)  1.114     0.922     1.345 0.263
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          22.958    6.788  3.382 0.001     9.653    36.263
## arm                -4.601    3.876 -1.187 0.235   -12.197     2.996
## TYPESTATUSnumeric  -5.003    3.956 -1.265 0.206   -12.756     2.750
## day                -3.051    4.262 -0.716 0.474   -11.405     5.303
## earlyacademicyear  -8.663    4.234 -2.046 0.041   -16.962    -0.364
## white               1.102    4.779  0.231 0.818    -8.265    10.470
## structuraletiology  0.538    4.425  0.122 0.903    -8.134     9.210
## priorepilepsy       0.733    4.944  0.148 0.882    -8.957    10.423
## status             -0.994    5.135 -0.194 0.847   -11.058     9.071
## ageyears            0.901    0.410  2.197 0.028     0.097     1.705
## SEXnumeric         -4.543    4.379 -1.038 0.299   -13.125     4.038
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.118    0.354  8.798 0.000    22.598    11.283
## arm                -0.263    0.204 -1.292 0.196     0.768     0.515
## TYPESTATUSnumeric  -0.305    0.258 -1.183 0.237     0.737     0.444
## day                -0.168    0.217 -0.773 0.439     0.845     0.552
## earlyacademicyear  -0.486    0.226 -2.152 0.031     0.615     0.395
## white               0.052    0.248  0.210 0.834     1.054     0.648
## structuraletiology  0.071    0.242  0.293 0.770     1.073     0.668
## priorepilepsy       0.035    0.240  0.147 0.883     1.036     0.647
## status             -0.022    0.264 -0.085 0.932     0.978     0.583
## ageyears            0.047    0.019  2.464 0.014     1.048     1.010
## SEXnumeric         -0.289    0.235 -1.233 0.217     0.749     0.473
##                    upper .95
## intercept             45.261
## arm                    1.146
## TYPESTATUSnumeric      1.222
## day                    1.294
## earlyacademicyear      0.957
## white                  1.714
## structuraletiology     1.723
## priorepilepsy          1.660
## status                 1.639
## ageyears               1.087
## SEXnumeric             1.186
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.609    0.172 20.945 0.000    36.919    26.339
## arm                 0.108    0.096  1.120 0.263     1.114     0.922
## TYPESTATUSnumeric   0.117    0.093  1.261 0.207     1.125     0.937
## day                 0.073    0.108  0.677 0.498     1.076     0.871
## earlyacademicyear   0.209    0.109  1.917 0.055     1.232     0.995
## white              -0.027    0.120 -0.226 0.821     0.973     0.770
## structuraletiology -0.004    0.108 -0.039 0.969     0.996     0.806
## priorepilepsy      -0.018    0.127 -0.145 0.885     0.982     0.765
## status              0.028    0.131  0.215 0.830     1.029     0.796
## ageyears           -0.022    0.011 -2.005 0.045     0.978     0.957
## SEXnumeric          0.101    0.109  0.928 0.353     1.106     0.894
##                    upper .95
## intercept             51.750
## arm                    1.345
## TYPESTATUSnumeric      1.350
## day                    1.329
## earlyacademicyear      1.525
## white                  1.230
## structuraletiology     1.230
## priorepilepsy          1.260
## status                 1.329
## ageyears               1.000
## SEXnumeric             1.369
# First non-BZD ASM later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        43 |        41 | 
##           |     0.512 |     0.488 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  46 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        22 |        24 | 
##           |     0.478 |     0.522 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  38 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        21 |        17 | 
##           |     0.553 |     0.447 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore40min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstASMmore40min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 0.5192
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.2865956 1.9147086
## sample estimates:
## odds ratio 
##  0.7447229
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -2.301    -6.816     2.214 0.318
## RMST (arm=1)/(arm=0)  0.929     0.799     1.079 0.333
## RMTL (arm=1)/(arm=0)  1.301     0.808     2.092 0.279
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          29.471    3.554  8.291 0.000    22.505    36.438
## arm                -2.301    2.304 -0.999 0.318    -6.816     2.214
## TYPESTATUSnumeric   1.486    2.962  0.502 0.616    -4.320     7.292
## day                -4.597    2.600 -1.768 0.077    -9.694     0.499
## earlyacademicyear  -0.398    2.702 -0.147 0.883    -5.693     4.897
## white               4.431    2.479  1.787 0.074    -0.428     9.290
## structuraletiology -1.674    2.498 -0.670 0.503    -6.569     3.221
## priorepilepsy       0.184    2.722  0.068 0.946    -5.151     5.520
## status             -1.884    3.275 -0.575 0.565    -8.302     4.534
## ageyears            0.440    0.240  1.830 0.067    -0.031     0.912
## SEXnumeric         -0.549    2.908 -0.189 0.850    -6.248     5.150
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.380    0.119 28.453 0.000    29.383    23.279
## arm                -0.074    0.076 -0.968 0.333     0.929     0.799
## TYPESTATUSnumeric   0.051    0.098  0.521 0.602     1.052     0.869
## day                -0.151    0.087 -1.733 0.083     0.859     0.724
## earlyacademicyear  -0.011    0.091 -0.122 0.903     0.989     0.828
## white               0.146    0.085  1.712 0.087     1.157     0.979
## structuraletiology -0.056    0.085 -0.656 0.512     0.946     0.800
## priorepilepsy       0.004    0.086  0.042 0.967     1.004     0.848
## status             -0.063    0.108 -0.582 0.561     0.939     0.759
## ageyears            0.014    0.008  1.803 0.071     1.014     0.999
## SEXnumeric         -0.023    0.099 -0.231 0.817     0.977     0.806
##                    upper .95
## intercept             37.087
## arm                    1.079
## TYPESTATUSnumeric      1.274
## day                    1.020
## earlyacademicyear      1.182
## white                  1.368
## structuraletiology     1.118
## priorepilepsy          1.188
## status                 1.161
## ageyears               1.030
## SEXnumeric             1.186
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.337    0.381  6.135 0.000    10.347     4.905
## arm                 0.263    0.243  1.083 0.279     1.301     0.808
## TYPESTATUSnumeric  -0.138    0.322 -0.430 0.667     0.871     0.464
## day                 0.494    0.285  1.735 0.083     1.639     0.938
## earlyacademicyear   0.056    0.268  0.207 0.836     1.057     0.625
## white              -0.479    0.255 -1.873 0.061     0.620     0.376
## structuraletiology  0.177    0.242  0.728 0.466     1.193     0.742
## priorepilepsy      -0.036    0.351 -0.102 0.919     0.965     0.485
## status              0.183    0.371  0.493 0.622     1.200     0.580
## ageyears           -0.054    0.032 -1.680 0.093     0.948     0.891
## SEXnumeric         -0.003    0.290 -0.010 0.992     0.997     0.564
##                    upper .95
## intercept             21.826
## arm                    2.092
## TYPESTATUSnumeric      1.636
## day                    2.865
## earlyacademicyear      1.788
## white                  1.022
## structuraletiology     1.919
## priorepilepsy          1.919
## status                 2.483
## ageyears               1.009
## SEXnumeric             1.762
# First non-BZD ASM later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        56 |        28 | 
##           |     0.667 |     0.333 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  46 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        30 |        16 | 
##           |     0.652 |     0.348 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  38 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        26 |        12 | 
##           |     0.684 |     0.316 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore60min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstASMmore60min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 0.8188
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3115521 2.3697827
## sample estimates:
## odds ratio 
##  0.8668741
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -4.858   -12.620     2.905 0.220
## RMST (arm=1)/(arm=0)  0.883     0.723     1.079 0.225
## RMTL (arm=1)/(arm=0)  1.272     0.869     1.862 0.217
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          38.973    6.187  6.299 0.000    26.847    51.100
## arm                -4.858    3.961 -1.227 0.220   -12.620     2.905
## TYPESTATUSnumeric  -1.363    5.040 -0.270 0.787   -11.240     8.515
## day                -8.188    4.402 -1.860 0.063   -16.817     0.441
## earlyacademicyear   0.903    4.436  0.204 0.839    -7.790     9.597
## white               7.171    4.339  1.653 0.098    -1.333    15.675
## structuraletiology -5.841    4.077 -1.432 0.152   -13.832     2.151
## priorepilepsy      -1.230    4.728 -0.260 0.795   -10.496     8.036
## status             -3.019    5.345 -0.565 0.572   -13.494     7.457
## ageyears            0.732    0.392  1.867 0.062    -0.036     1.500
## SEXnumeric          1.358    4.655  0.292 0.771    -7.765    10.481
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.660    0.161 22.775 0.000    38.863    28.362
## arm                -0.124    0.102 -1.214 0.225     0.883     0.723
## TYPESTATUSnumeric  -0.035    0.133 -0.261 0.794     0.966     0.744
## day                -0.213    0.116 -1.835 0.066     0.808     0.644
## earlyacademicyear   0.030    0.117  0.260 0.795     1.031     0.820
## white               0.187    0.118  1.587 0.113     1.206     0.957
## structuraletiology -0.160    0.111 -1.451 0.147     0.852     0.686
## priorepilepsy      -0.037    0.118 -0.316 0.752     0.963     0.765
## status             -0.086    0.141 -0.609 0.543     0.918     0.696
## ageyears            0.018    0.010  1.838 0.066     1.018     0.999
## SEXnumeric          0.030    0.122  0.243 0.808     1.030     0.812
##                    upper .95
## intercept             53.251
## arm                    1.079
## TYPESTATUSnumeric      1.254
## day                    1.015
## earlyacademicyear      1.295
## white                  1.520
## structuraletiology     1.058
## priorepilepsy          1.214
## status                 1.210
## ageyears               1.037
## SEXnumeric             1.307
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.042    0.300 10.154 0.000    20.938    11.641
## arm                 0.240    0.195  1.236 0.217     1.272     0.869
## TYPESTATUSnumeric   0.067    0.233  0.289 0.772     1.070     0.677
## day                 0.395    0.219  1.801 0.072     1.485     0.966
## earlyacademicyear  -0.026    0.206 -0.127 0.899     0.974     0.651
## white              -0.345    0.202 -1.710 0.087     0.708     0.476
## structuraletiology  0.257    0.188  1.369 0.171     1.293     0.895
## priorepilepsy       0.051    0.252  0.204 0.838     1.053     0.643
## status              0.110    0.259  0.427 0.670     1.117     0.672
## ageyears           -0.041    0.023 -1.771 0.077     0.960     0.918
## SEXnumeric         -0.092    0.222 -0.413 0.679     0.912     0.591
##                    upper .95
## intercept             37.663
## arm                    1.862
## TYPESTATUSnumeric      1.689
## day                    2.283
## earlyacademicyear      1.458
## white                  1.052
## structuraletiology     1.869
## priorepilepsy          1.724
## status                 1.856
## ageyears               1.004
## SEXnumeric             1.409
# First non-BZD ASM later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        72 |        12 | 
##           |     0.857 |     0.143 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  46 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        39 |         7 | 
##           |     0.848 |     0.152 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  38 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        33 |         5 | 
##           |     0.868 |     0.132 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore120min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstASMmore120min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1924922 3.4343290
## sample estimates:
## odds ratio 
##  0.8458499
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, tau=120,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                         Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -10.200   -25.148     4.747 0.181
## RMST (arm=1)/(arm=0)   0.820     0.616     1.092 0.175
## RMTL (arm=1)/(arm=0)   1.164     0.925     1.463 0.195
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept           59.329   13.353  4.443 0.000    33.158    85.500
## arm                -10.200    7.627 -1.337 0.181   -25.148     4.747
## TYPESTATUSnumeric  -13.182    8.450 -1.560 0.119   -29.744     3.380
## day                -14.829    8.489 -1.747 0.081   -31.468     1.810
## earlyacademicyear   -2.747    8.331 -0.330 0.742   -19.076    13.582
## white                8.025    8.368  0.959 0.338    -8.375    24.425
## structuraletiology -13.232    7.606 -1.740 0.082   -28.140     1.676
## priorepilepsy       -3.639    9.653 -0.377 0.706   -22.559    15.281
## status              -2.954   10.507 -0.281 0.779   -23.548    17.641
## ageyears             1.573    0.761  2.067 0.039     0.081     3.064
## SEXnumeric           4.876    8.244  0.591 0.554   -11.282    21.033
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.089    0.250 16.363 0.000    59.654    36.556
## arm                -0.198    0.146 -1.356 0.175     0.820     0.616
## TYPESTATUSnumeric  -0.277    0.182 -1.523 0.128     0.758     0.530
## day                -0.279    0.162 -1.715 0.086     0.757     0.551
## earlyacademicyear  -0.039    0.164 -0.238 0.812     0.962     0.697
## white               0.153    0.167  0.913 0.361     1.165     0.839
## structuraletiology -0.276    0.159 -1.733 0.083     0.759     0.555
## priorepilepsy      -0.088    0.182 -0.481 0.630     0.916     0.641
## status             -0.062    0.205 -0.300 0.764     0.940     0.629
## ageyears            0.027    0.013  2.111 0.035     1.028     1.002
## SEXnumeric          0.080    0.155  0.518 0.604     1.084     0.800
##                    upper .95
## intercept             97.347
## arm                    1.092
## TYPESTATUSnumeric      1.083
## day                    1.041
## earlyacademicyear      1.326
## white                  1.617
## structuraletiology     1.037
## priorepilepsy          1.310
## status                 1.406
## ageyears               1.054
## SEXnumeric             1.468
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.110    0.204 20.172 0.000    60.956    40.887
## arm                 0.152    0.117  1.297 0.195     1.164     0.925
## TYPESTATUSnumeric   0.185    0.119  1.546 0.122     1.203     0.952
## day                 0.227    0.133  1.707 0.088     1.255     0.967
## earlyacademicyear   0.046    0.123  0.376 0.707     1.048     0.822
## white              -0.124    0.124 -1.001 0.317     0.884     0.693
## structuraletiology  0.188    0.111  1.686 0.092     1.207     0.970
## priorepilepsy       0.047    0.150  0.314 0.753     1.048     0.782
## status              0.038    0.159  0.240 0.810     1.039     0.760
## ageyears           -0.025    0.013 -1.940 0.052     0.975     0.950
## SEXnumeric         -0.083    0.127 -0.657 0.511     0.920     0.718
##                    upper .95
## intercept             90.875
## arm                    1.463
## TYPESTATUSnumeric      1.520
## day                    1.628
## earlyacademicyear      1.334
## white                  1.126
## structuraletiology     1.501
## priorepilepsy          1.406
## status                 1.420
## ageyears               1.000
## SEXnumeric             1.179
# First CI later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  35 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         3 |        32 | 
##           |     0.086 |     0.914 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  23 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         3 |        20 | 
##           |     0.130 |     0.870 | 
##           |-----------|-----------|
## 
## 
## 
## 
table(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstCImore60min)
## 
##  0  1 
##  0 12
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore60min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstCImore60min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 0.5361
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.2150344       Inf
## sample estimates:
## odds ratio 
##        Inf
# Difference adjusting for covariates within the first 500 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$awareness, tau=60,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## Warning in sqrt(diag(varbeta)): NaNs produced
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95    upper .95     p
## RMST (arm=1)-(arm=0) 4.352    -1.143 9.847000e+00 0.121
## RMST (arm=1)/(arm=0) 1.075     0.977 1.184000e+00 0.138
## RMTL (arm=1)/(arm=0) 0.000     0.000 4.298243e+20 0.481
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          57.378    3.764 15.243 0.000    50.000    64.756
## arm                 4.352    2.804  1.552 0.121    -1.143     9.847
## TYPESTATUSnumeric   5.105    5.762  0.886 0.376    -6.189    16.399
## day                -5.391    3.909 -1.379 0.168   -13.053     2.271
## earlyacademicyear  -0.963    3.113 -0.309 0.757    -7.065     5.140
## white              -3.018    4.000 -0.755 0.451   -10.857     4.821
## structuraletiology  1.900    4.455  0.426 0.670    -6.832    10.632
## priorepilepsy       2.839    3.624  0.783 0.433    -4.264     9.941
## status              3.638    4.845  0.751 0.453    -5.859    13.134
## ageyears            0.313    0.392  0.798 0.425    -0.456     1.082
## SEXnumeric         -5.273    4.003 -1.317 0.188   -13.118     2.572
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.044    0.072 56.278 0.000    57.061    49.565
## arm                 0.073    0.049  1.483 0.138     1.075     0.977
## TYPESTATUSnumeric   0.091    0.111  0.824 0.410     1.096     0.881
## day                -0.099    0.078 -1.268 0.205     0.906     0.778
## earlyacademicyear  -0.015    0.056 -0.270 0.787     0.985     0.882
## white              -0.049    0.071 -0.685 0.493     0.952     0.828
## structuraletiology  0.033    0.081  0.411 0.681     1.034     0.882
## priorepilepsy       0.044    0.065  0.689 0.491     1.045     0.921
## status              0.068    0.093  0.731 0.465     1.070     0.892
## ageyears            0.006    0.008  0.765 0.444     1.006     0.991
## SEXnumeric         -0.092    0.073 -1.251 0.211     0.913     0.791
##                    upper .95
## intercept             65.691
## arm                    1.184
## TYPESTATUSnumeric      1.362
## day                    1.055
## earlyacademicyear      1.100
## white                  1.095
## structuraletiology     1.211
## priorepilepsy          1.186
## status                 1.283
## ageyears               1.021
## SEXnumeric             1.053
## 
## 
## Model summary (ratio of time-lost) 
##                       coef se(coef)       z     p    exp(coef)
## intercept          -99.156      NaN     NaN   NaN 0.000000e+00
## arm                -26.649   37.837  -0.704 0.481 0.000000e+00
## TYPESTATUSnumeric  -18.133    1.285 -14.107 0.000 0.000000e+00
## day                 35.764      NaN     NaN   NaN 3.406322e+15
## earlyacademicyear   40.975    0.727  56.339 0.000 6.237754e+17
## white               40.774      NaN     NaN   NaN 5.102771e+17
## structuraletiology  -2.403      NaN     NaN   NaN 9.000000e-02
## priorepilepsy      -38.782    1.902 -20.389 0.000 0.000000e+00
## status             -28.478    4.008  -7.105 0.000 0.000000e+00
## ageyears             0.242    0.152   1.597 0.110 1.274000e+00
## SEXnumeric          26.080    2.263  11.525 0.000 2.120004e+11
##                       lower .95    upper .95
## intercept                   NaN          NaN
## arm                0.000000e+00 4.298243e+20
## TYPESTATUSnumeric  0.000000e+00 0.000000e+00
## day                         NaN          NaN
## earlyacademicyear  1.499545e+17 2.594758e+18
## white                       NaN          NaN
## structuraletiology          NaN          NaN
## priorepilepsy      0.000000e+00 0.000000e+00
## status             0.000000e+00 0.000000e+00
## ageyears           9.460000e-01 1.716000e+00
## SEXnumeric         2.512447e+09 1.788860e+13
# First CI later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  35 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         8 |        27 | 
##           |     0.229 |     0.771 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  23 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         6 |        17 | 
##           |     0.261 |     0.739 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  12 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         2 |        10 | 
##           |     0.167 |     0.833 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore120min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstCImore120min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 0.6855
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.2442521 20.8287560
## sample estimates:
## odds ratio 
##   1.737725
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$awareness, tau=120,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## Warning in sqrt(diag(varbeta)): NaNs produced
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 11.303    -2.555    25.161 0.110
## RMST (arm=1)/(arm=0)  1.102     0.970     1.252 0.134
## RMTL (arm=1)/(arm=0)  0.000     0.000     0.000 0.000
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          116.199    8.464 13.729 0.000    99.610   132.787
## arm                 11.303    7.071  1.599 0.110    -2.555    25.161
## TYPESTATUSnumeric    8.469   13.950  0.607 0.544   -18.872    35.811
## day                -12.787    9.042 -1.414 0.157   -30.510     4.936
## earlyacademicyear   -4.477    7.892 -0.567 0.571   -19.946    10.992
## white               -6.028    9.599 -0.628 0.530   -24.841    12.785
## structuraletiology   1.246   10.796  0.115 0.908   -19.913    22.405
## priorepilepsy        8.520    8.828  0.965 0.334    -8.782    25.822
## status               7.094   11.449  0.620 0.536   -15.346    29.534
## ageyears             0.495    0.865  0.573 0.567    -1.199     2.190
## SEXnumeric         -11.996    8.920 -1.345 0.179   -29.479     5.487
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.747    0.081 58.407 0.000   115.229    98.261
## arm                 0.097    0.065  1.497 0.134     1.102     0.970
## TYPESTATUSnumeric   0.075    0.136  0.551 0.582     1.078     0.825
## day                -0.118    0.091 -1.291 0.197     0.889     0.743
## earlyacademicyear  -0.038    0.073 -0.520 0.603     0.963     0.835
## white              -0.047    0.089 -0.525 0.600     0.954     0.801
## structuraletiology  0.010    0.100  0.105 0.917     1.011     0.831
## priorepilepsy       0.069    0.082  0.838 0.402     1.071     0.912
## status              0.068    0.114  0.596 0.551     1.070     0.856
## ageyears            0.005    0.008  0.568 0.570     1.005     0.988
## SEXnumeric         -0.106    0.084 -1.261 0.207     0.899     0.763
##                    upper .95
## intercept            135.127
## arm                    1.252
## TYPESTATUSnumeric      1.408
## day                    1.063
## earlyacademicyear      1.110
## white                  1.137
## structuraletiology     1.229
## priorepilepsy          1.259
## status                 1.339
## ageyears               1.022
## SEXnumeric             1.061
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)       z     p    exp(coef)
## intercept          -175.444      NaN     NaN   NaN 0.000000e+00
## arm                 -23.707    1.243 -19.072 0.000 0.000000e+00
## TYPESTATUSnumeric   -18.407      NaN     NaN   NaN 0.000000e+00
## day                  77.620   67.182   1.155 0.248 5.125761e+33
## earlyacademicyear    39.307      NaN     NaN   NaN 1.177384e+17
## white                78.609      NaN     NaN   NaN 1.378835e+34
## structuraletiology   37.720      NaN     NaN   NaN 2.407827e+16
## priorepilepsy       -40.544      NaN     NaN   NaN 0.000000e+00
## status              -24.277    3.588  -6.766 0.000 0.000000e+00
## ageyears              0.203    0.141   1.438 0.151 1.225000e+00
## SEXnumeric           23.504    1.773  13.259 0.000 1.612335e+10
##                       lower .95    upper .95
## intercept                   NaN          NaN
## arm                0.000000e+00 0.000000e+00
## TYPESTATUSnumeric           NaN          NaN
## day                0.000000e+00 7.854917e+90
## earlyacademicyear           NaN          NaN
## white                       NaN          NaN
## structuraletiology          NaN          NaN
## priorepilepsy               NaN          NaN
## status             0.000000e+00 0.000000e+00
## ageyears           9.290000e-01 1.616000e+00
## SEXnumeric         4.995373e+08 5.204063e+11
# First CI later than 240 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  35 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        20 |        15 | 
##           |     0.571 |     0.429 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 0, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  23 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        13 |        10 | 
##           |     0.565 |     0.435 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness == 1, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  12 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         7 |         5 | 
##           |     0.583 |     0.417 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore240min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstCImore240min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1751422 4.6851010
## sample estimates:
## odds ratio 
##  0.9305588
# Difference adjusting for covariates within the first 240 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$awareness, tau=240,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 240  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 1.591   -40.905    44.087 0.942
## RMST (arm=1)/(arm=0) 1.005     0.797     1.267 0.965
## RMTL (arm=1)/(arm=0) 0.944     0.422     2.113 0.889
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          210.704   30.449  6.920 0.000   151.024   270.383
## arm                  1.591   21.682  0.073 0.942   -40.905    44.087
## TYPESTATUSnumeric   -7.301   32.284 -0.226 0.821   -70.576    55.974
## day                -23.295   22.270 -1.046 0.296   -66.943    20.354
## earlyacademicyear  -19.248   24.487 -0.786 0.432   -67.242    28.746
## white              -20.292   26.931 -0.753 0.451   -73.077    32.493
## structuraletiology  25.386   28.189  0.901 0.368   -29.863    80.636
## priorepilepsy      -14.580   27.204 -0.536 0.592   -67.900    38.739
## status              17.075   37.019  0.461 0.645   -55.481    89.631
## ageyears             2.585    1.806  1.432 0.152    -0.954     6.125
## SEXnumeric         -39.318   24.585 -1.599 0.110   -87.504     8.867
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           5.346    0.169 31.692 0.000   209.810   150.742
## arm                 0.005    0.118  0.043 0.965     1.005     0.797
## TYPESTATUSnumeric  -0.036    0.201 -0.176 0.860     0.965     0.650
## day                -0.136    0.130 -1.049 0.294     0.873     0.677
## earlyacademicyear  -0.105    0.137 -0.768 0.443     0.900     0.688
## white              -0.104    0.151 -0.690 0.490     0.901     0.670
## structuraletiology  0.138    0.156  0.885 0.376     1.148     0.846
## priorepilepsy      -0.078    0.159 -0.493 0.622     0.925     0.677
## status              0.092    0.216  0.427 0.669     1.097     0.718
## ageyears            0.014    0.010  1.371 0.170     1.014     0.994
## SEXnumeric         -0.209    0.141 -1.479 0.139     0.811     0.615
##                    upper .95
## intercept            292.023
## arm                    1.267
## TYPESTATUSnumeric      1.432
## day                    1.125
## earlyacademicyear      1.178
## white                  1.212
## structuraletiology     1.557
## priorepilepsy          1.263
## status                 1.675
## ageyears               1.036
## SEXnumeric             1.070
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.317    0.609  5.444 0.000    27.576     8.354
## arm                -0.058    0.411 -0.140 0.889     0.944     0.422
## TYPESTATUSnumeric   0.204    0.442  0.460 0.645     1.226     0.515
## day                 0.346    0.438  0.791 0.429     1.414     0.599
## earlyacademicyear   0.368    0.438  0.842 0.400     1.445     0.613
## white               0.465    0.502  0.926 0.354     1.592     0.595
## structuraletiology -0.471    0.534 -0.881 0.378     0.625     0.219
## priorepilepsy       0.310    0.425  0.729 0.466     1.363     0.593
## status             -0.339    0.613 -0.553 0.581     0.713     0.215
## ageyears           -0.047    0.034 -1.383 0.167     0.954     0.892
## SEXnumeric          0.823    0.459  1.791 0.073     2.277     0.925
##                    upper .95
## intercept             91.024
## arm                    2.113
## TYPESTATUSnumeric      2.917
## day                    3.337
## earlyacademicyear      3.408
## white                  4.262
## structuraletiology     1.779
## priorepilepsy          3.137
## status                 2.369
## ageyears               1.020
## SEXnumeric             5.601

Time to treatment sensitivity analysis 3: Only initial centers and threshold in 2017

# Distribution of patients according to the threhold
CrossTable(pSERG$awareness2017)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  268 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       220 |        48 | 
##           |     0.821 |     0.179 | 
##           |-----------|-----------|
## 
## 
## 
## 
## ALL PATIENTS


# Time to first BZD
summary(pSERG$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   20.00   56.67   45.00 1264.00
sd(pSERG$BZDTIME.0)
## [1] 134.0915
survfit(Surv(pSERG$BZDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG$BZDTIME.0) ~ 1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##     268     268      20      15      23
# Figure time to first BZD
plot(survfit(Surv(pSERG$BZDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")

# Time to first BZD depending on awareness
summary(pSERG[which(pSERG$awareness2017 == 0), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    5.00   20.00   59.83   49.25 1264.00
summary(pSERG[which(pSERG$awareness2017 == 1), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.00    5.00   20.00   42.19   33.50  330.00
survdiff(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho = 1)
## 
##                     N Observed Expected (O-E)^2/E (O-E)^2/V
## pSERG$awareness=0 150     76.5     80.6     0.207     0.763
## pSERG$awareness=1 118     63.2     59.1     0.283     0.763
## 
##  Chisq= 0.8  on 1 degrees of freedom, p= 0.4
pchisq(survdiff(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.3824629
# Figure time to first BZD by awareness
plot(survfit(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first BZD
summary(coxph(Surv(pSERG$BZDTIME.0) ~ pSERG$awareness2017 + pSERG$TYPESTATUS + pSERG$HOSPITALONSET + 
                pSERG$day + pSERG$earlyacademicyear + pSERG$white +
                pSERG$structuraletiology + pSERG$priorepilepsy +
                pSERG$status + pSERG$ageyears + pSERG$SEX))
## Call:
## coxph(formula = Surv(pSERG$BZDTIME.0) ~ pSERG$awareness2017 + 
##     pSERG$TYPESTATUS + pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + 
##     pSERG$white + pSERG$structuraletiology + pSERG$priorepilepsy + 
##     pSERG$status + pSERG$ageyears + pSERG$SEX)
## 
##   n= 268, number of events= 268 
## 
##                                   coef exp(coef)  se(coef)      z Pr(>|z|)
## pSERG$awareness2017           0.075029  1.077915  0.163444  0.459 0.646200
## pSERG$TYPESTATUSintermittent -0.384395  0.680862  0.139573 -2.754 0.005886
## pSERG$HOSPITALONSETyes        0.529355  1.697836  0.141435  3.743 0.000182
## pSERG$day                     0.064426  1.066547  0.128450  0.502 0.615973
## pSERG$earlyacademicyear       0.226337  1.253999  0.125268  1.807 0.070790
## pSERG$white                   0.092024  1.096391  0.132697  0.693 0.488002
## pSERG$structuraletiology      0.059093  1.060874  0.148161  0.399 0.690008
## pSERG$priorepilepsy           0.021418  1.021649  0.138026  0.155 0.876686
## pSERG$status                  0.381622  1.464658  0.172735  2.209 0.027154
## pSERG$ageyears               -0.003457  0.996549  0.012385 -0.279 0.780151
## pSERG$SEXmale                 0.059181  1.060967  0.127526  0.464 0.642598
##                                 
## pSERG$awareness2017             
## pSERG$TYPESTATUSintermittent ** 
## pSERG$HOSPITALONSETyes       ***
## pSERG$day                       
## pSERG$earlyacademicyear      .  
## pSERG$white                     
## pSERG$structuraletiology        
## pSERG$priorepilepsy             
## pSERG$status                 *  
## pSERG$ageyears                  
## pSERG$SEXmale                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                              exp(coef) exp(-coef) lower .95 upper .95
## pSERG$awareness2017             1.0779     0.9277    0.7825    1.4849
## pSERG$TYPESTATUSintermittent    0.6809     1.4687    0.5179    0.8951
## pSERG$HOSPITALONSETyes          1.6978     0.5890    1.2868    2.2402
## pSERG$day                       1.0665     0.9376    0.8292    1.3719
## pSERG$earlyacademicyear         1.2540     0.7974    0.9810    1.6030
## pSERG$white                     1.0964     0.9121    0.8453    1.4221
## pSERG$structuraletiology        1.0609     0.9426    0.7935    1.4183
## pSERG$priorepilepsy             1.0216     0.9788    0.7795    1.3390
## pSERG$status                    1.4647     0.6828    1.0440    2.0548
## pSERG$ageyears                  0.9965     1.0035    0.9727    1.0210
## pSERG$SEXmale                   1.0610     0.9425    0.8263    1.3622
## 
## Concordance= 0.617  (se = 0.022 )
## Rsquare= 0.116   (max possible= 1 )
## Likelihood ratio test= 33.11  on 11 df,   p=5e-04
## Wald test            = 34.69  on 11 df,   p=3e-04
## Score (logrank) test = 35.35  on 11 df,   p=2e-04
# Time to first non-BZD AED
summary(pSERG$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    35.0    65.5   153.2   150.8  1800.0
sd(pSERG$AEDTIME.0)
## [1] 246.9072
survfit(Surv(pSERG$AEDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG$AEDTIME.0) ~ 1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##   268.0   268.0    65.5    60.0    77.0
# Figure time to first non-BZD AED
plot(survfit(Surv(pSERG$AEDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")

# Time to first non-BZD AED depending on awareness
summary(pSERG[which(pSERG$awareness2017 == 0), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   35.75   66.50  152.77  150.75 1800.00
summary(pSERG[which(pSERG$awareness2017 == 1), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   10.00   31.75   64.50  155.21  159.25 1419.00
survdiff(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho = 1)
## 
##                     N Observed Expected (O-E)^2/E (O-E)^2/V
## pSERG$awareness=0 150     76.0     75.7   0.00127   0.00433
## pSERG$awareness=1 118     59.5     59.8   0.00160   0.00433
## 
##  Chisq= 0  on 1 degrees of freedom, p= 0.9
pchisq(survdiff(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.9475229
# Figure time to first non-BZD AED by awareness
plot(survfit(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first non-BZD AED
summary(coxph(Surv(pSERG$AEDTIME.0) ~ pSERG$awareness2017 + pSERG$TYPESTATUS + pSERG$HOSPITALONSET + 
                pSERG$day + pSERG$earlyacademicyear + pSERG$white +
                pSERG$structuraletiology + pSERG$priorepilepsy +
                pSERG$status + pSERG$ageyears + pSERG$SEX))
## Call:
## coxph(formula = Surv(pSERG$AEDTIME.0) ~ pSERG$awareness2017 + 
##     pSERG$TYPESTATUS + pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + 
##     pSERG$white + pSERG$structuraletiology + pSERG$priorepilepsy + 
##     pSERG$status + pSERG$ageyears + pSERG$SEX)
## 
##   n= 268, number of events= 268 
## 
##                                  coef exp(coef) se(coef)      z Pr(>|z|)
## pSERG$awareness2017          -0.07470   0.92802  0.16235 -0.460   0.6454
## pSERG$TYPESTATUSintermittent -0.55762   0.57257  0.13938 -4.001 6.32e-05
## pSERG$HOSPITALONSETyes        0.86510   2.37524  0.14263  6.065 1.32e-09
## pSERG$day                     0.25788   1.29419  0.13050  1.976   0.0481
## pSERG$earlyacademicyear       0.10822   1.11429  0.12518  0.865   0.3873
## pSERG$white                   0.03414   1.03473  0.12865  0.265   0.7907
## pSERG$structuraletiology      0.18185   1.19943  0.14549  1.250   0.2113
## pSERG$priorepilepsy           0.08628   1.09012  0.14152  0.610   0.5421
## pSERG$status                  0.20246   1.22441  0.17271  1.172   0.2411
## pSERG$ageyears               -0.02791   0.97247  0.01225 -2.279   0.0227
## pSERG$SEXmale                 0.05115   1.05248  0.12971  0.394   0.6933
##                                 
## pSERG$awareness2017             
## pSERG$TYPESTATUSintermittent ***
## pSERG$HOSPITALONSETyes       ***
## pSERG$day                    *  
## pSERG$earlyacademicyear         
## pSERG$white                     
## pSERG$structuraletiology        
## pSERG$priorepilepsy             
## pSERG$status                    
## pSERG$ageyears               *  
## pSERG$SEXmale                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                              exp(coef) exp(-coef) lower .95 upper .95
## pSERG$awareness2017             0.9280     1.0776    0.6751    1.2757
## pSERG$TYPESTATUSintermittent    0.5726     1.7465    0.4357    0.7524
## pSERG$HOSPITALONSETyes          2.3752     0.4210    1.7960    3.1413
## pSERG$day                       1.2942     0.7727    1.0021    1.6714
## pSERG$earlyacademicyear         1.1143     0.8974    0.8719    1.4241
## pSERG$white                     1.0347     0.9664    0.8041    1.3315
## pSERG$structuraletiology        1.1994     0.8337    0.9018    1.5952
## pSERG$priorepilepsy             1.0901     0.9173    0.8261    1.4386
## pSERG$status                    1.2244     0.8167    0.8728    1.7177
## pSERG$ageyears                  0.9725     1.0283    0.9494    0.9961
## pSERG$SEXmale                   1.0525     0.9501    0.8162    1.3571
## 
## Concordance= 0.648  (se = 0.021 )
## Rsquare= 0.192   (max possible= 1 )
## Likelihood ratio test= 57.08  on 11 df,   p=3e-08
## Wald test            = 59.4  on 11 df,   p=1e-08
## Score (logrank) test = 60.96  on 11 df,   p=6e-09
# Time to first CI
summary(pSERG$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   122.0   206.0   523.7   612.5  7200.0     149
sd(pSERG$CONTTIME.0)
## [1] NA
survfit(Surv(pSERG$CONTTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG$CONTTIME.0) ~ 1)
## 
##    149 observations deleted due to missingness 
##       n  events  median 0.95LCL 0.95UCL 
##     119     119     206     165     300
# Figure time to first CI
plot(survfit(Surv(pSERG$CONTTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")

# Time to first CI depending on awareness
summary(pSERG[which(pSERG$awareness2017 == 0), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   122.0   186.0   518.0   574.8  7200.0     114
summary(pSERG[which(pSERG$awareness2017 == 1), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    75.0   135.0   420.0   569.5  1000.0  1435.0      35
survdiff(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, 
##     rho = 1)
## 
## n=119, 149 observations deleted due to missingness.
## 
##                    N Observed Expected (O-E)^2/E (O-E)^2/V
## pSERG$awareness=0 67     34.5     33.3    0.0440     0.148
## pSERG$awareness=1 52     25.7     26.9    0.0544     0.148
## 
##  Chisq= 0.1  on 1 degrees of freedom, p= 0.7
pchisq(survdiff(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.7006702
# Figure time to first CI by awareness
plot(survfit(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first CI
summary(coxph(Surv(pSERG$CONTTIME.0) ~ pSERG$awareness2017 + pSERG$TYPESTATUS + pSERG$HOSPITALONSET + 
                pSERG$day + pSERG$earlyacademicyear + pSERG$white +
                pSERG$structuraletiology + pSERG$priorepilepsy +
                pSERG$status + pSERG$ageyears + pSERG$SEX))
## Call:
## coxph(formula = Surv(pSERG$CONTTIME.0) ~ pSERG$awareness2017 + 
##     pSERG$TYPESTATUS + pSERG$HOSPITALONSET + pSERG$day + pSERG$earlyacademicyear + 
##     pSERG$white + pSERG$structuraletiology + pSERG$priorepilepsy + 
##     pSERG$status + pSERG$ageyears + pSERG$SEX)
## 
##   n= 119, number of events= 119 
##    (149 observations deleted due to missingness)
## 
##                                   coef exp(coef)  se(coef)      z Pr(>|z|)
## pSERG$awareness2017          -0.203146  0.816159  0.311332 -0.653   0.5141
## pSERG$TYPESTATUSintermittent -0.211139  0.809662  0.219835 -0.960   0.3368
## pSERG$HOSPITALONSETyes        0.098984  1.104049  0.223892  0.442   0.6584
## pSERG$day                     0.014998  1.015111  0.194558  0.077   0.9386
## pSERG$earlyacademicyear       0.478583  1.613787  0.203825  2.348   0.0189
## pSERG$white                  -0.492579  0.611049  0.214652 -2.295   0.0217
## pSERG$structuraletiology      0.141753  1.152292  0.239776  0.591   0.5544
## pSERG$priorepilepsy           0.162706  1.176691  0.247746  0.657   0.5113
## pSERG$status                  0.107867  1.113899  0.275936  0.391   0.6959
## pSERG$ageyears               -0.001253  0.998748  0.019789 -0.063   0.9495
## pSERG$SEXmale                 0.363517  1.438379  0.200184  1.816   0.0694
##                               
## pSERG$awareness2017           
## pSERG$TYPESTATUSintermittent  
## pSERG$HOSPITALONSETyes        
## pSERG$day                     
## pSERG$earlyacademicyear      *
## pSERG$white                  *
## pSERG$structuraletiology      
## pSERG$priorepilepsy           
## pSERG$status                  
## pSERG$ageyears                
## pSERG$SEXmale                .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                              exp(coef) exp(-coef) lower .95 upper .95
## pSERG$awareness2017             0.8162     1.2253    0.4434    1.5024
## pSERG$TYPESTATUSintermittent    0.8097     1.2351    0.5262    1.2457
## pSERG$HOSPITALONSETyes          1.1040     0.9058    0.7119    1.7122
## pSERG$day                       1.0151     0.9851    0.6933    1.4864
## pSERG$earlyacademicyear         1.6138     0.6197    1.0823    2.4063
## pSERG$white                     0.6110     1.6365    0.4012    0.9307
## pSERG$structuraletiology        1.1523     0.8678    0.7202    1.8436
## pSERG$priorepilepsy             1.1767     0.8498    0.7241    1.9122
## pSERG$status                    1.1139     0.8977    0.6486    1.9130
## pSERG$ageyears                  0.9987     1.0013    0.9608    1.0382
## pSERG$SEXmale                   1.4384     0.6952    0.9716    2.1295
## 
## Concordance= 0.592  (se = 0.031 )
## Rsquare= 0.118   (max possible= 1 )
## Likelihood ratio test= 14.93  on 11 df,   p=0.2
## Wald test            = 14.95  on 11 df,   p=0.2
## Score (logrank) test = 15.09  on 11 df,   p=0.2
# First BZD later than 20 minutes
CrossTable(pSERG$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  268 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       149 |       119 | 
##           |     0.556 |     0.444 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  220 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       121 |        99 | 
##           |     0.550 |     0.450 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 1, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  48 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        28 |        20 | 
##           |     0.583 |     0.417 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstBZDmore20min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstBZDmore20min and pSERG$awareness2017
## p-value = 0.7494
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4378284 1.7172603
## sample estimates:
## odds ratio 
##  0.8734567
# Difference adjusting for covariates within the first 20 minutes
rmst2(time=pSERG$BZDTIME.0, status=pSERG$event, arm=pSERG$awareness2017, tau=20,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 20  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.126    -2.137     2.388 0.913
## RMST (arm=1)/(arm=0) 1.013     0.857     1.196 0.883
## RMTL (arm=1)/(arm=0) 0.992     0.698     1.411 0.966
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            16.322    1.354 12.051 0.000    13.668    18.977
## arm                   0.126    1.154  0.109 0.913    -2.137     2.388
## TYPESTATUSnumeric    -0.473    0.902 -0.524 0.600    -2.242     1.296
## HOSPITALONSETnumeric -3.504    0.988 -3.545 0.000    -5.442    -1.567
## day                  -0.629    0.857 -0.734 0.463    -2.309     1.051
## earlyacademicyear    -0.944    0.865 -1.091 0.275    -2.640     0.752
## white                -0.252    0.861 -0.292 0.770    -1.939     1.436
## structuraletiology   -0.494    1.011 -0.489 0.625    -2.476     1.487
## priorepilepsy        -0.415    0.895 -0.464 0.643    -2.170     1.340
## status               -2.786    1.267 -2.198 0.028    -5.270    -0.302
## ageyears              0.010    0.088  0.115 0.908    -0.163     0.183
## SEXnumeric            0.550    0.874  0.630 0.529    -1.162     2.263
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             2.808    0.099 28.361 0.000    16.571    13.649
## arm                   0.013    0.085  0.147 0.883     1.013     0.857
## TYPESTATUSnumeric    -0.032    0.067 -0.481 0.630     0.968     0.849
## HOSPITALONSETnumeric -0.276    0.083 -3.330 0.001     0.759     0.645
## day                  -0.049    0.063 -0.788 0.431     0.952     0.842
## earlyacademicyear    -0.070    0.064 -1.103 0.270     0.932     0.823
## white                -0.020    0.063 -0.322 0.747     0.980     0.866
## structuraletiology   -0.037    0.076 -0.489 0.625     0.964     0.831
## priorepilepsy        -0.034    0.064 -0.536 0.592     0.966     0.853
## status               -0.225    0.108 -2.085 0.037     0.799     0.647
## ageyears              0.001    0.006  0.141 0.888     1.001     0.988
## SEXnumeric            0.041    0.064  0.638 0.524     1.042     0.919
##                      upper .95
## intercept               20.120
## arm                      1.196
## TYPESTATUSnumeric        1.104
## HOSPITALONSETnumeric     0.893
## day                      1.076
## earlyacademicyear        1.056
## white                    1.109
## structuraletiology       1.118
## priorepilepsy            1.095
## status                   0.987
## ageyears                 1.014
## SEXnumeric               1.181
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             1.413    0.221  6.396 0.000     4.109     2.665
## arm                  -0.008    0.180 -0.042 0.966     0.992     0.698
## TYPESTATUSnumeric     0.088    0.140  0.630 0.528     1.092     0.830
## HOSPITALONSETnumeric  0.499    0.140  3.574 0.000     1.648     1.253
## day                   0.085    0.139  0.614 0.539     1.089     0.830
## earlyacademicyear     0.146    0.138  1.053 0.293     1.157     0.882
## white                 0.032    0.137  0.234 0.815     1.033     0.790
## structuraletiology    0.075    0.154  0.485 0.627     1.078     0.797
## priorepilepsy         0.048    0.153  0.315 0.752     1.050     0.777
## status                0.379    0.170  2.233 0.026     1.461     1.047
## ageyears             -0.001    0.014 -0.058 0.954     0.999     0.972
## SEXnumeric           -0.085    0.140 -0.607 0.544     0.919     0.698
##                      upper .95
## intercept                6.336
## arm                      1.411
## TYPESTATUSnumeric        1.438
## HOSPITALONSETnumeric     2.167
## day                      1.428
## earlyacademicyear        1.518
## white                    1.350
## structuraletiology       1.457
## priorepilepsy            1.417
## status                   2.037
## ageyears                 1.027
## SEXnumeric               1.209
# First BZD later than 40 minutes
CrossTable(pSERG$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  268 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       192 |        76 | 
##           |     0.716 |     0.284 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  220 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       154 |        66 | 
##           |     0.700 |     0.300 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 1, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  48 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        38 |        10 | 
##           |     0.792 |     0.208 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstBZDmore40min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstBZDmore40min and pSERG$awareness2017
## p-value = 0.2213
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.2576377 1.3520217
## sample estimates:
## odds ratio 
##  0.6150764
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG$BZDTIME.0, status=pSERG$event, arm=pSERG$awareness2017, tau=40,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.838    -5.315     3.638 0.714
## RMST (arm=1)/(arm=0)  0.967     0.772     1.212 0.771
## RMTL (arm=1)/(arm=0)  1.052     0.842     1.315 0.656
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            26.049    2.728  9.549 0.000    20.703    31.396
## arm                  -0.838    2.284 -0.367 0.714    -5.315     3.638
## TYPESTATUSnumeric    -3.575    1.751 -2.042 0.041    -7.007    -0.143
## HOSPITALONSETnumeric -7.722    1.877 -4.115 0.000   -11.400    -4.044
## day                  -0.582    1.775 -0.328 0.743    -4.061     2.898
## earlyacademicyear    -2.010    1.752 -1.147 0.251    -5.443     1.424
## white                 0.356    1.765  0.202 0.840    -3.104     3.816
## structuraletiology    0.529    2.091  0.253 0.800    -3.569     4.627
## priorepilepsy         0.687    1.877  0.366 0.714    -2.991     4.365
## status               -5.972    2.463 -2.424 0.015   -10.800    -1.144
## ageyears              0.047    0.178  0.267 0.790    -0.302     0.397
## SEXnumeric           -0.158    1.776 -0.089 0.929    -3.638     3.323
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.277    0.130 25.164 0.000    26.508    20.536
## arm                  -0.034    0.115 -0.291 0.771     0.967     0.772
## TYPESTATUSnumeric    -0.171    0.089 -1.926 0.054     0.843     0.708
## HOSPITALONSETnumeric -0.403    0.108 -3.738 0.000     0.668     0.541
## day                  -0.032    0.085 -0.377 0.706     0.969     0.820
## earlyacademicyear    -0.098    0.085 -1.154 0.248     0.907     0.768
## white                 0.015    0.085  0.180 0.857     1.016     0.859
## structuraletiology    0.027    0.100  0.266 0.790     1.027     0.844
## priorepilepsy         0.024    0.086  0.284 0.777     1.025     0.865
## status               -0.314    0.144 -2.182 0.029     0.731     0.551
## ageyears              0.002    0.008  0.283 0.777     1.002     0.986
## SEXnumeric           -0.004    0.085 -0.050 0.960     0.996     0.843
##                      upper .95
## intercept               34.217
## arm                      1.212
## TYPESTATUSnumeric        1.003
## HOSPITALONSETnumeric     0.825
## day                      1.144
## earlyacademicyear        1.071
## white                    1.201
## structuraletiology       1.249
## priorepilepsy            1.213
## status                   0.969
## ageyears                 1.019
## SEXnumeric               1.176
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             2.667    0.147 18.171 0.000    14.402    10.802
## arm                   0.051    0.114  0.445 0.656     1.052     0.842
## TYPESTATUSnumeric     0.189    0.089  2.128 0.033     1.208     1.015
## HOSPITALONSETnumeric  0.381    0.092  4.158 0.000     1.463     1.223
## day                   0.026    0.095  0.276 0.782     1.026     0.853
## earlyacademicyear     0.104    0.092  1.132 0.258     1.110     0.926
## white                -0.021    0.092 -0.230 0.818     0.979     0.817
## structuraletiology   -0.027    0.110 -0.243 0.808     0.974     0.784
## priorepilepsy        -0.046    0.105 -0.442 0.659     0.955     0.778
## status                0.295    0.116  2.538 0.011     1.344     1.070
## ageyears             -0.002    0.010 -0.253 0.801     0.998     0.979
## SEXnumeric            0.011    0.094  0.114 0.909     1.011     0.841
##                      upper .95
## intercept               19.204
## arm                      1.315
## TYPESTATUSnumeric        1.437
## HOSPITALONSETnumeric     1.751
## day                      1.236
## earlyacademicyear        1.330
## white                    1.173
## structuraletiology       1.209
## priorepilepsy            1.172
## status                   1.688
## ageyears                 1.016
## SEXnumeric               1.215
# First BZD later than 60 minutes
CrossTable(pSERG$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  268 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       217 |        51 | 
##           |     0.810 |     0.190 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  220 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       175 |        45 | 
##           |     0.795 |     0.205 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 1, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  48 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        42 |         6 | 
##           |     0.875 |     0.125 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstBZDmore60min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstBZDmore60min and pSERG$awareness2017
## p-value = 0.2302
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1819544 1.4306439
## sample estimates:
## odds ratio 
##  0.5566328
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG$BZDTIME.0, status=pSERG$event, arm=pSERG$awareness2017, tau=60,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -2.503    -8.719     3.713 0.430
## RMST (arm=1)/(arm=0)  0.914     0.701     1.191 0.506
## RMTL (arm=1)/(arm=0)  1.080     0.909     1.282 0.381
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept             34.558    3.998  8.645 0.000    26.723    42.393
## arm                   -2.503    3.171 -0.789 0.430    -8.719     3.713
## TYPESTATUSnumeric     -6.420    2.508 -2.560 0.010   -11.336    -1.505
## HOSPITALONSETnumeric -10.580    2.648 -3.995 0.000   -15.771    -5.390
## day                   -0.746    2.590 -0.288 0.773    -5.822     4.330
## earlyacademicyear     -3.514    2.532 -1.388 0.165    -8.478     1.450
## white                 -0.230    2.604 -0.088 0.930    -5.333     4.873
## structuraletiology     0.827    2.990  0.277 0.782    -5.034     6.688
## priorepilepsy          2.400    2.749  0.873 0.383    -2.987     7.788
## status                -9.888    3.304 -2.993 0.003   -16.363    -3.413
## ageyears               0.032    0.255  0.125 0.900    -0.467     0.531
## SEXnumeric            -1.219    2.570 -0.474 0.635    -6.256     3.819
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.577    0.152 23.544 0.000    35.752    26.546
## arm                  -0.090    0.135 -0.665 0.506     0.914     0.701
## TYPESTATUSnumeric    -0.254    0.106 -2.387 0.017     0.776     0.630
## HOSPITALONSETnumeric -0.453    0.126 -3.589 0.000     0.636     0.496
## day                  -0.035    0.100 -0.354 0.724     0.965     0.793
## earlyacademicyear    -0.137    0.099 -1.379 0.168     0.872     0.717
## white                -0.010    0.102 -0.101 0.919     0.990     0.811
## structuraletiology    0.033    0.115  0.282 0.778     1.033     0.824
## priorepilepsy         0.080    0.101  0.787 0.431     1.083     0.888
## status               -0.428    0.164 -2.614 0.009     0.652     0.473
## ageyears              0.001    0.010  0.116 0.907     1.001     0.982
## SEXnumeric           -0.042    0.099 -0.422 0.673     0.959     0.789
##                      upper .95
## intercept               48.152
## arm                      1.191
## TYPESTATUSnumeric        0.956
## HOSPITALONSETnumeric     0.814
## day                      1.174
## earlyacademicyear        1.059
## white                    1.208
## structuraletiology       1.295
## priorepilepsy            1.321
## status                   0.898
## ageyears                 1.020
## SEXnumeric               1.165
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.267    0.121 26.910 0.000    26.232    20.677
## arm                   0.077    0.088  0.876 0.381     1.080     0.909
## TYPESTATUSnumeric     0.187    0.071  2.619 0.009     1.205     1.048
## HOSPITALONSETnumeric  0.295    0.073  4.022 0.000     1.343     1.163
## day                   0.019    0.077  0.241 0.810     1.019     0.876
## earlyacademicyear     0.103    0.075  1.383 0.167     1.109     0.958
## white                 0.005    0.076  0.070 0.944     1.005     0.866
## structuraletiology   -0.024    0.089 -0.275 0.783     0.976     0.821
## priorepilepsy        -0.078    0.085 -0.919 0.358     0.925     0.783
## status                0.277    0.090  3.071 0.002     1.320     1.106
## ageyears             -0.001    0.008 -0.134 0.893     0.999     0.984
## SEXnumeric            0.038    0.076  0.495 0.621     1.038     0.895
##                      upper .95
## intercept               33.279
## arm                      1.282
## TYPESTATUSnumeric        1.386
## HOSPITALONSETnumeric     1.551
## day                      1.185
## earlyacademicyear        1.283
## white                    1.168
## structuraletiology       1.161
## priorepilepsy            1.092
## status                   1.575
## ageyears                 1.014
## SEXnumeric               1.205
# First non-BZD ASM later than 40 minutes
CrossTable(pSERG$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  268 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        76 |       192 | 
##           |     0.284 |     0.716 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  150 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        45 |       105 | 
##           |     0.300 |     0.700 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  118 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        31 |        87 | 
##           |     0.263 |     0.737 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstASMmore40min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstASMmore40min and pSERG$awareness
## p-value = 0.5853
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.6792881 2.1444062
## sample estimates:
## odds ratio 
##   1.201938
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG$AEDTIME.0, status=pSERG$event, arm=pSERG$awareness2017, tau=40,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.885    -1.523     3.293 0.471
## RMST (arm=1)/(arm=0) 1.026     0.959     1.099 0.457
## RMTL (arm=1)/(arm=0) 0.872     0.517     1.471 0.607
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            34.770    1.897 18.330 0.000    31.052    38.488
## arm                   0.885    1.229  0.720 0.471    -1.523     3.293
## TYPESTATUSnumeric    -0.077    1.116 -0.069 0.945    -2.265     2.111
## HOSPITALONSETnumeric -6.983    1.415 -4.934 0.000    -9.757    -4.209
## day                  -1.489    1.110 -1.341 0.180    -3.665     0.688
## earlyacademicyear     0.940    1.083  0.869 0.385    -1.182     3.062
## white                 1.661    1.095  1.518 0.129    -0.484     3.807
## structuraletiology   -0.219    1.212 -0.181 0.856    -2.594     2.156
## priorepilepsy         1.204    1.116  1.079 0.281    -0.984     3.392
## status               -0.630    1.372 -0.459 0.646    -3.319     2.060
## ageyears              0.173    0.112  1.546 0.122    -0.046     0.391
## SEXnumeric            0.811    1.137  0.713 0.476    -1.418     3.040
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.546    0.055 64.398 0.000    34.657    31.112
## arm                   0.026    0.035  0.745 0.457     1.026     0.959
## TYPESTATUSnumeric    -0.002    0.032 -0.057 0.955     0.998     0.938
## HOSPITALONSETnumeric -0.206    0.045 -4.585 0.000     0.813     0.745
## day                  -0.041    0.032 -1.309 0.191     0.960     0.902
## earlyacademicyear     0.026    0.031  0.850 0.395     1.027     0.966
## white                 0.047    0.032  1.484 0.138     1.048     0.985
## structuraletiology   -0.006    0.035 -0.165 0.869     0.994     0.928
## priorepilepsy         0.034    0.032  1.075 0.282     1.034     0.973
## status               -0.017    0.039 -0.440 0.660     0.983     0.911
## ageyears              0.005    0.003  1.551 0.121     1.005     0.999
## SEXnumeric            0.023    0.032  0.703 0.482     1.023     0.960
##                      upper .95
## intercept               38.606
## arm                      1.099
## TYPESTATUSnumeric        1.062
## HOSPITALONSETnumeric     0.889
## day                      1.021
## earlyacademicyear        1.091
## white                    1.115
## structuraletiology       1.065
## priorepilepsy            1.100
## status                   1.061
## ageyears                 1.011
## SEXnumeric               1.090
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             1.452    0.393  3.697 0.000     4.271     1.978
## arm                  -0.137    0.267 -0.515 0.607     0.872     0.517
## TYPESTATUSnumeric     0.043    0.254  0.169 0.865     1.044     0.634
## HOSPITALONSETnumeric  1.313    0.247  5.322 0.000     3.718     2.292
## day                   0.379    0.252  1.504 0.133     1.461     0.892
## earlyacademicyear    -0.230    0.229 -1.005 0.315     0.795     0.508
## white                -0.375    0.219 -1.710 0.087     0.687     0.447
## structuraletiology    0.071    0.233  0.307 0.758     1.074     0.681
## priorepilepsy        -0.294    0.282 -1.043 0.297     0.745     0.428
## status                0.190    0.315  0.605 0.545     1.210     0.653
## ageyears             -0.039    0.027 -1.459 0.144     0.962     0.913
## SEXnumeric           -0.221    0.251 -0.880 0.379     0.802     0.490
##                      upper .95
## intercept                9.220
## arm                      1.471
## TYPESTATUSnumeric        1.718
## HOSPITALONSETnumeric     6.030
## day                      2.393
## earlyacademicyear        1.244
## white                    1.056
## structuraletiology       1.694
## priorepilepsy            1.296
## status                   2.242
## ageyears                 1.013
## SEXnumeric               1.311
# First non-BZD ASM later than 60 minutes
CrossTable(pSERG$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  268 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       120 |       148 | 
##           |     0.448 |     0.552 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  150 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        70 |        80 | 
##           |     0.467 |     0.533 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  118 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        50 |        68 | 
##           |     0.424 |     0.576 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstASMmore60min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstASMmore60min and pSERG$awareness
## p-value = 0.5366
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.7114192 1.9931234
## sample estimates:
## odds ratio 
##   1.189223
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG$AEDTIME.0, status=pSERG$event, arm=pSERG$awareness2017, tau=60,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 1.309    -3.193     5.811 0.569
## RMST (arm=1)/(arm=0) 1.030     0.938     1.131 0.540
## RMTL (arm=1)/(arm=0) 0.928     0.634     1.360 0.702
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept             48.251    3.338 14.455 0.000    41.708    54.793
## arm                    1.309    2.297  0.570 0.569    -3.193     5.811
## TYPESTATUSnumeric     -1.717    2.006 -0.856 0.392    -5.649     2.215
## HOSPITALONSETnumeric -13.672    2.431 -5.624 0.000   -18.437    -8.907
## day                   -3.259    1.967 -1.656 0.098    -7.115     0.597
## earlyacademicyear      2.282    1.935  1.179 0.238    -1.510     6.074
## white                  2.436    1.983  1.228 0.219    -1.451     6.322
## structuraletiology    -1.737    2.187 -0.794 0.427    -6.024     2.549
## priorepilepsy          2.523    2.014  1.253 0.210    -1.425     6.470
## status                -0.953    2.351 -0.406 0.685    -5.561     3.654
## ageyears               0.333    0.197  1.694 0.090    -0.052     0.719
## SEXnumeric             2.335    1.999  1.168 0.243    -1.583     6.253
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.871    0.071 54.246 0.000    47.971    41.710
## arm                   0.029    0.048  0.614 0.540     1.030     0.938
## TYPESTATUSnumeric    -0.035    0.042 -0.838 0.402     0.966     0.890
## HOSPITALONSETnumeric -0.301    0.059 -5.079 0.000     0.740     0.659
## day                  -0.066    0.041 -1.618 0.106     0.936     0.864
## earlyacademicyear     0.046    0.040  1.134 0.257     1.047     0.967
## white                 0.049    0.042  1.171 0.242     1.051     0.967
## structuraletiology   -0.036    0.047 -0.752 0.452     0.965     0.880
## priorepilepsy         0.052    0.041  1.244 0.213     1.053     0.971
## status               -0.018    0.049 -0.369 0.712     0.982     0.893
## ageyears              0.007    0.004  1.703 0.089     1.007     0.999
## SEXnumeric            0.047    0.042  1.137 0.255     1.049     0.966
##                      upper .95
## intercept               55.172
## arm                      1.131
## TYPESTATUSnumeric        1.048
## HOSPITALONSETnumeric     0.831
## day                      1.014
## earlyacademicyear        1.133
## white                    1.141
## structuraletiology       1.059
## priorepilepsy            1.142
## status                   1.081
## ageyears                 1.015
## SEXnumeric               1.138
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             2.351    0.275  8.543 0.000    10.496     6.121
## arm                  -0.074    0.195 -0.382 0.702     0.928     0.634
## TYPESTATUSnumeric     0.160    0.176  0.913 0.361     1.174     0.832
## HOSPITALONSETnumeric  1.047    0.175  5.978 0.000     2.849     2.021
## day                   0.313    0.180  1.736 0.083     1.367     0.960
## earlyacademicyear    -0.225    0.167 -1.347 0.178     0.799     0.576
## white                -0.239    0.161 -1.482 0.138     0.788     0.574
## structuraletiology    0.163    0.168  0.965 0.334     1.177     0.846
## priorepilepsy        -0.241    0.196 -1.231 0.218     0.786     0.536
## status                0.120    0.216  0.554 0.579     1.127     0.738
## ageyears             -0.030    0.019 -1.601 0.109     0.970     0.935
## SEXnumeric           -0.236    0.177 -1.333 0.182     0.790     0.558
##                      upper .95
## intercept               18.000
## arm                      1.360
## TYPESTATUSnumeric        1.656
## HOSPITALONSETnumeric     4.015
## day                      1.947
## earlyacademicyear        1.108
## white                    1.080
## structuraletiology       1.637
## priorepilepsy            1.153
## status                   1.723
## ageyears                 1.007
## SEXnumeric               1.117
# First non-BZD ASM later than 120 minutes
CrossTable(pSERG$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  268 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       187 |        81 | 
##           |     0.698 |     0.302 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 0, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  150 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       105 |        45 | 
##           |     0.700 |     0.300 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness == 1, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  118 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        82 |        36 | 
##           |     0.695 |     0.305 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG$firstASMmore120min, pSERG$awareness, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstASMmore120min and pSERG$awareness
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.5845118 1.7884137
## sample estimates:
## odds ratio 
##   1.024307
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG$AEDTIME.0, status=pSERG$event, arm=pSERG$awareness2017, tau=120,
      covariates= pSERG[ , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.501   -10.456    11.458 0.929
## RMST (arm=1)/(arm=0) 1.014     0.870     1.182 0.858
## RMTL (arm=1)/(arm=0) 1.005     0.799     1.265 0.965
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept             82.499    7.285 11.324 0.000    68.220    96.778
## arm                    0.501    5.591  0.090 0.929   -10.456    11.458
## TYPESTATUSnumeric    -18.280    4.432 -4.124 0.000   -26.967    -9.593
## HOSPITALONSETnumeric -31.742    5.061 -6.272 0.000   -41.660   -21.823
## day                   -6.318    4.542 -1.391 0.164   -15.221     2.584
## earlyacademicyear      1.704    4.501  0.379 0.705    -7.118    10.525
## white                  2.677    4.607  0.581 0.561    -6.353    11.708
## structuraletiology    -6.307    5.143 -1.226 0.220   -16.388     3.773
## priorepilepsy          5.650    4.779  1.182 0.237    -3.718    15.017
## status                -4.869    5.591 -0.871 0.384   -15.827     6.090
## ageyears               0.811    0.441  1.841 0.066    -0.053     1.676
## SEXnumeric             4.794    4.555  1.052 0.293    -4.135    13.722
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             4.411    0.102 43.238 0.000    82.318    67.401
## arm                   0.014    0.078  0.179 0.858     1.014     0.870
## TYPESTATUSnumeric    -0.260    0.065 -3.974 0.000     0.771     0.678
## HOSPITALONSETnumeric -0.478    0.086 -5.587 0.000     0.620     0.524
## day                  -0.086    0.062 -1.395 0.163     0.917     0.813
## earlyacademicyear     0.018    0.062  0.291 0.771     1.018     0.902
## white                 0.029    0.065  0.453 0.650     1.030     0.907
## structuraletiology   -0.085    0.075 -1.132 0.258     0.918     0.792
## priorepilepsy         0.074    0.064  1.155 0.248     1.076     0.950
## status               -0.057    0.078 -0.727 0.467     0.945     0.810
## ageyears              0.011    0.006  1.858 0.063     1.011     0.999
## SEXnumeric            0.065    0.063  1.037 0.300     1.067     0.944
##                      upper .95
## intercept              100.537
## arm                      1.182
## TYPESTATUSnumeric        0.876
## HOSPITALONSETnumeric     0.733
## day                      1.036
## earlyacademicyear        1.149
## white                    1.168
## structuraletiology       1.065
## priorepilepsy            1.220
## status                   1.102
## ageyears                 1.022
## SEXnumeric               1.207
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.620    0.157 23.021 0.000    37.324    27.425
## arm                   0.005    0.117  0.044 0.965     1.005     0.799
## TYPESTATUSnumeric     0.376    0.093  4.031 0.000     1.456     1.213
## HOSPITALONSETnumeric  0.626    0.101  6.166 0.000     1.870     1.533
## day                   0.136    0.102  1.335 0.182     1.146     0.938
## earlyacademicyear    -0.050    0.098 -0.505 0.614     0.952     0.785
## white                -0.078    0.097 -0.802 0.422     0.925     0.765
## structuraletiology    0.139    0.103  1.353 0.176     1.150     0.939
## priorepilepsy        -0.133    0.111 -1.198 0.231     0.875     0.704
## status                0.131    0.121  1.078 0.281     1.139     0.899
## ageyears             -0.018    0.011 -1.730 0.084     0.982     0.962
## SEXnumeric           -0.110    0.100 -1.098 0.272     0.896     0.736
##                      upper .95
## intercept               50.796
## arm                      1.265
## TYPESTATUSnumeric        1.749
## HOSPITALONSETnumeric     2.281
## day                      1.399
## earlyacademicyear        1.154
## white                    1.119
## structuraletiology       1.407
## priorepilepsy            1.088
## status                   1.445
## ageyears                 1.002
## SEXnumeric               1.090
# First CI later than 60 minutes
CrossTable(pSERG$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  119 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         9 |       110 | 
##           |     0.076 |     0.924 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         9 |        97 | 
##           |     0.085 |     0.915 | 
##           |-----------|-----------|
## 
## 
## 
## 
table(pSERG[pSERG$awareness2017 == 1, ]$firstCImore60min)
## 
##  0  1 
##  0 13
fisher.test(pSERG$firstCImore60min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstCImore60min and pSERG$awareness2017
## p-value = 0.5947
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.2320877       Inf
## sample estimates:
## odds ratio 
##        Inf
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0), ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0), ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0), ]$awareness2017, tau=60,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 2.813    -0.176     5.802 0.065
## RMST (arm=1)/(arm=0) 1.049     0.996     1.105 0.071
## RMTL (arm=1)/(arm=0) 0.000     0.000     0.000 0.000
## 
## 
## Model summary (difference of RMST) 
##                        coef se(coef)      z     p lower .95 upper .95
## intercept            59.323    1.597 37.146 0.000    56.193    62.453
## arm                   2.813    1.525  1.845 0.065    -0.176     5.802
## TYPESTATUSnumeric     0.936    1.323  0.707 0.479    -1.657     3.529
## HOSPITALONSETnumeric -2.570    2.186 -1.176 0.240    -6.855     1.715
## day                  -1.132    1.070 -1.058 0.290    -3.229     0.966
## earlyacademicyear    -1.182    1.575 -0.750 0.453    -4.269     1.906
## white                -0.650    1.129 -0.576 0.565    -2.862     1.562
## structuraletiology    1.326    1.773  0.748 0.455    -2.150     4.801
## priorepilepsy        -0.045    1.160 -0.039 0.969    -2.318     2.228
## status                2.192    1.063  2.063 0.039     0.109     4.274
## ageyears              0.042    0.122  0.342 0.732    -0.198     0.281
## SEXnumeric           -0.346    1.534 -0.226 0.822    -3.352     2.660
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)       z     p exp(coef) lower .95
## intercept             4.083    0.028 147.262 0.000    59.303    56.167
## arm                   0.048    0.027   1.803 0.071     1.049     0.996
## TYPESTATUSnumeric     0.016    0.023   0.685 0.493     1.016     0.972
## HOSPITALONSETnumeric -0.044    0.038  -1.153 0.249     0.957     0.887
## day                  -0.020    0.019  -1.058 0.290     0.981     0.946
## earlyacademicyear    -0.020    0.027  -0.742 0.458     0.980     0.929
## white                -0.011    0.019  -0.566 0.571     0.989     0.952
## structuraletiology    0.023    0.031   0.744 0.457     1.023     0.963
## priorepilepsy        -0.001    0.020  -0.031 0.976     0.999     0.961
## status                0.037    0.018   2.044 0.041     1.038     1.002
## ageyears              0.001    0.002   0.345 0.730     1.001     0.997
## SEXnumeric           -0.006    0.026  -0.219 0.827     0.994     0.944
##                      upper .95
## intercept               62.615
## arm                      1.105
## TYPESTATUSnumeric        1.062
## HOSPITALONSETnumeric     1.031
## day                      1.017
## earlyacademicyear        1.034
## white                    1.027
## structuraletiology       1.087
## priorepilepsy            1.039
## status                   1.075
## ageyears                 1.005
## SEXnumeric               1.047
## 
## 
## Model summary (ratio of time-lost) 
##                         coef se(coef)       z     p exp(coef) lower .95
## intercept             -1.684    1.618  -1.041 0.298     0.186     0.008
## arm                  -19.075    0.652 -29.238 0.000     0.000     0.000
## TYPESTATUSnumeric     -1.422    0.924  -1.539 0.124     0.241     0.039
## HOSPITALONSETnumeric   1.725    0.920   1.875 0.061     5.614     0.925
## day                    0.637    0.886   0.719 0.472     1.891     0.333
## earlyacademicyear      1.256    0.869   1.445 0.148     3.512     0.639
## white                  1.034    0.805   1.284 0.199     2.812     0.580
## structuraletiology    -0.747    0.985  -0.758 0.448     0.474     0.069
## priorepilepsy         -0.134    0.738  -0.182 0.855     0.874     0.206
## status               -18.576    0.746 -24.896 0.000     0.000     0.000
## ageyears               0.008    0.059   0.143 0.887     1.009     0.898
## SEXnumeric             0.538    0.916   0.587 0.557     1.712     0.284
##                      upper .95
## intercept                4.423
## arm                      0.000
## TYPESTATUSnumeric        1.476
## HOSPITALONSETnumeric    34.083
## day                     10.746
## earlyacademicyear       19.289
## white                   13.621
## structuraletiology       3.266
## priorepilepsy            3.713
## status                   0.000
## ageyears                 1.133
## SEXnumeric              10.306
# First CI later than 120 minutes
CrossTable(pSERG$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  119 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        28 |        91 | 
##           |     0.235 |     0.765 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        25 |        81 | 
##           |     0.236 |     0.764 | 
##           |-----------|-----------|
## 
## 
## 
## 
table(pSERG[pSERG$awareness2017 == 1, ]$firstCImore120min)
## 
##  0  1 
##  3 10
fisher.test(pSERG$firstCImore120min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstCImore120min and pSERG$awareness2017
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.2389733 6.2641599
## sample estimates:
## odds ratio 
##   1.028581
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0), ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0), ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0), ]$awareness2017, tau=120,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 8.311    -1.259    17.880 0.089
## RMST (arm=1)/(arm=0) 1.076     0.988     1.173 0.094
## RMTL (arm=1)/(arm=0) 0.267     0.041     1.740 0.168
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept            110.929    6.574 16.874 0.000    98.044   123.814
## arm                    8.311    4.882  1.702 0.089    -1.259    17.880
## TYPESTATUSnumeric      2.249    4.610  0.488 0.626    -6.786    11.284
## HOSPITALONSETnumeric   0.308    5.510  0.056 0.955   -10.492    11.108
## day                   -5.780    4.012 -1.441 0.150   -13.643     2.083
## earlyacademicyear     -6.705    4.825 -1.390 0.165   -16.162     2.752
## white                  4.376    4.376  1.000 0.317    -4.201    12.953
## structuraletiology     2.226    5.600  0.398 0.691    -8.749    13.202
## priorepilepsy         -2.544    4.777 -0.533 0.594   -11.907     6.819
## status                10.937    4.076  2.683 0.007     2.949    18.926
## ageyears               0.204    0.389  0.525 0.600    -0.558     0.967
## SEXnumeric            -2.537    4.612 -0.550 0.582   -11.576     6.501
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             4.707    0.059 79.134 0.000   110.748    98.561
## arm                   0.073    0.044  1.675 0.094     1.076     0.988
## TYPESTATUSnumeric     0.020    0.042  0.482 0.630     1.020     0.940
## HOSPITALONSETnumeric  0.003    0.050  0.059 0.953     1.003     0.909
## day                  -0.053    0.037 -1.440 0.150     0.948     0.882
## earlyacademicyear    -0.061    0.044 -1.374 0.169     0.941     0.863
## white                 0.040    0.040  0.996 0.319     1.041     0.962
## structuraletiology    0.020    0.051  0.391 0.696     1.020     0.923
## priorepilepsy        -0.023    0.044 -0.530 0.596     0.977     0.897
## status                0.098    0.037  2.634 0.008     1.103     1.025
## ageyears              0.002    0.004  0.535 0.593     1.002     0.995
## SEXnumeric           -0.023    0.042 -0.544 0.586     0.977     0.900
##                      upper .95
## intercept              124.443
## arm                      1.173
## TYPESTATUSnumeric        1.108
## HOSPITALONSETnumeric     1.106
## day                      1.019
## earlyacademicyear        1.026
## white                    1.126
## structuraletiology       1.128
## priorepilepsy            1.064
## status                   1.186
## ageyears                 1.009
## SEXnumeric               1.061
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             1.963    0.792  2.479 0.013     7.120     1.508
## arm                  -1.319    0.955 -1.380 0.168     0.267     0.041
## TYPESTATUSnumeric    -0.265    0.511 -0.519 0.604     0.767     0.282
## HOSPITALONSETnumeric -0.030    0.599 -0.050 0.960     0.970     0.300
## day                   0.549    0.440  1.247 0.212     1.731     0.731
## earlyacademicyear     0.767    0.548  1.398 0.162     2.152     0.735
## white                -0.397    0.446 -0.890 0.373     0.672     0.280
## structuraletiology   -0.248    0.548 -0.452 0.651     0.781     0.267
## priorepilepsy         0.251    0.477  0.526 0.599     1.285     0.505
## status               -1.672    0.745 -2.246 0.025     0.188     0.044
## ageyears             -0.016    0.040 -0.407 0.684     0.984     0.909
## SEXnumeric            0.299    0.465  0.644 0.519     1.349     0.543
##                      upper .95
## intercept               33.615
## arm                      1.740
## TYPESTATUSnumeric        2.087
## HOSPITALONSETnumeric     3.142
## day                      4.100
## earlyacademicyear        6.305
## white                    1.612
## structuraletiology       2.283
## priorepilepsy            3.270
## status                   0.808
## ageyears                 1.065
## SEXnumeric               3.355
# First CI later than 240 minutes
CrossTable(pSERG$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  119 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        68 |        51 | 
##           |     0.571 |     0.429 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$awareness2017 == 0, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  106 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        62 |        44 | 
##           |     0.585 |     0.415 | 
##           |-----------|-----------|
## 
## 
## 
## 
table(pSERG[pSERG$awareness2017 == 1, ]$firstCImore240min)
## 
## 0 1 
## 6 7
fisher.test(pSERG$firstCImore240min, pSERG$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG$firstCImore240min and pSERG$awareness2017
## p-value = 0.5541
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4374766 6.3369036
## sample estimates:
## odds ratio 
##    1.63691
# Difference adjusting for covariates within the first 240 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0), ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0), ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0), ]$awareness2017, tau=240,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) , c("TYPESTATUSnumeric", "HOSPITALONSETnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 240  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 22.471   -13.432    58.373 0.220
## RMST (arm=1)/(arm=0)  1.133     0.937     1.370 0.199
## RMTL (arm=1)/(arm=0)  0.676     0.318     1.435 0.308
## 
## 
## Model summary (difference of RMST) 
##                         coef se(coef)      z     p lower .95 upper .95
## intercept            187.100   20.827  8.983 0.000   146.279   227.921
## arm                   22.471   18.318  1.227 0.220   -13.432    58.373
## TYPESTATUSnumeric    -17.865   13.527 -1.321 0.187   -44.377     8.648
## HOSPITALONSETnumeric   1.619   14.172  0.114 0.909   -26.158    29.395
## day                   -9.967   12.636 -0.789 0.430   -34.733    14.799
## earlyacademicyear    -20.139   13.243 -1.521 0.128   -46.095     5.818
## white                 13.370   13.087  1.022 0.307   -12.280    39.021
## structuraletiology     3.765   15.631  0.241 0.810   -26.871    34.402
## priorepilepsy          3.519   14.531  0.242 0.809   -24.960    31.999
## status                12.451   14.329  0.869 0.385   -15.632    40.535
## ageyears               0.292    1.190  0.245 0.806    -2.040     2.624
## SEXnumeric           -12.543   12.496 -1.004 0.316   -37.035    11.950
## 
## 
## Model summary (ratio of RMST) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             5.228    0.115 45.471 0.000   186.341   148.748
## arm                   0.125    0.097  1.284 0.199     1.133     0.937
## TYPESTATUSnumeric    -0.106    0.081 -1.311 0.190     0.900     0.768
## HOSPITALONSETnumeric  0.006    0.079  0.081 0.936     1.006     0.861
## day                  -0.054    0.071 -0.767 0.443     0.947     0.824
## earlyacademicyear    -0.113    0.075 -1.511 0.131     0.893     0.772
## white                 0.076    0.075  1.002 0.317     1.079     0.930
## structuraletiology    0.021    0.088  0.234 0.815     1.021     0.859
## priorepilepsy         0.020    0.080  0.245 0.807     1.020     0.871
## status                0.074    0.080  0.922 0.356     1.076     0.921
## ageyears              0.002    0.007  0.266 0.790     1.002     0.989
## SEXnumeric           -0.071    0.071 -1.005 0.315     0.931     0.811
##                      upper .95
## intercept              233.436
## arm                      1.370
## TYPESTATUSnumeric        1.054
## HOSPITALONSETnumeric     1.176
## day                      1.088
## earlyacademicyear        1.034
## white                    1.251
## structuraletiology       1.212
## priorepilepsy            1.193
## status                   1.258
## ageyears                 1.015
## SEXnumeric               1.070
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)      z     p exp(coef) lower .95
## intercept             3.934    0.364 10.819 0.000    51.115    25.062
## arm                  -0.392    0.384 -1.020 0.308     0.676     0.318
## TYPESTATUSnumeric     0.256    0.196  1.310 0.190     1.292     0.881
## HOSPITALONSETnumeric -0.050    0.235 -0.213 0.832     0.951     0.601
## day                   0.180    0.213  0.845 0.398     1.198     0.788
## earlyacademicyear     0.335    0.223  1.504 0.133     1.397     0.903
## white                -0.215    0.202 -1.067 0.286     0.807     0.543
## structuraletiology   -0.069    0.255 -0.271 0.786     0.933     0.566
## priorepilepsy        -0.059    0.247 -0.237 0.813     0.943     0.581
## status               -0.176    0.248 -0.709 0.478     0.839     0.516
## ageyears             -0.004    0.020 -0.204 0.838     0.996     0.957
## SEXnumeric            0.199    0.202  0.986 0.324     1.220     0.822
##                      upper .95
## intercept              104.251
## arm                      1.435
## TYPESTATUSnumeric        1.896
## HOSPITALONSETnumeric     1.507
## day                      1.820
## earlyacademicyear        2.162
## white                    1.197
## structuraletiology       1.539
## priorepilepsy            1.532
## status                   1.363
## ageyears                 1.037
## SEXnumeric               1.811
## OUT OF THE HOSPITAL

# At least one benzodiazepine before hospital arrival
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  134 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        51 |        83 | 
##           |     0.381 |     0.619 | 
##           |-----------|-----------|
## 
## 
## 
## 
# At least one benzodiazepine before hospital arrival depending on awareness
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  119 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        49 |        70 | 
##           |     0.412 |     0.588 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  15 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         2 |        13 | 
##           |     0.133 |     0.867 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDbeforehospital, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017)
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$AEDbeforehospital and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.04742
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.9547557 42.8994588
## sample estimates:
## odds ratio 
##   4.508736
# Logistic regression adjusting for potential confounders
logistic_out_of_hospital_BZD <- glm(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDbeforehospital ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX, family="binomial")

cbind(exp(cbind("Odds ratio" = coef(logistic_out_of_hospital_BZD), confint(logistic_out_of_hospital_BZD, level = 0.95))), "p-value" = coef(summary(logistic_out_of_hospital_BZD))[ , 4])
## Waiting for profiling to be done...
##                                                             Odds ratio
## (Intercept)                                                  3.1529206
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           6.7018034
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.3606124
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.9623272
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.1789207
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.6933350
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.8537765
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.6867202
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  5.8802132
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                1.0454124
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.7127887
##                                                                 2.5 %
## (Intercept)                                                 0.8319403
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          1.4978445
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent 0.1422851
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    0.4225197
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear      0.5372640
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  0.2984167
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     0.3431411
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          0.3019876
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 1.7584253
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               0.9689084
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                0.3213066
##                                                                 97.5 %
## (Intercept)                                                 12.9783426
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          48.4799732
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.8596642
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     2.1887620
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       2.6063614
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   1.5731914
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      2.1518086
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           1.5309597
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 27.1792974
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                1.1323667
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.5602041
##                                                                p-value
## (Intercept)                                                 0.09879390
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          0.02518522
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent 0.02512855
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    0.92668859
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear      0.68146248
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  0.38513324
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     0.73392250
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          0.36180994
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                 0.00891462
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               0.25999331
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                0.39879097
# At least one benzodiazepine before hospital arrival among those with prior epilepsy
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  74 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        28 |        46 | 
##           |     0.378 |     0.622 | 
##           |-----------|-----------|
## 
## 
## 
## 
# At least one benzodiazepine before hospital arrival among those with prior epilepsy depending on awareness
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$awareness2017 == 0), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  63 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        27 |        36 | 
##           |     0.429 |     0.571 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1 & pSERG$awareness2017 == 1), ]$AEDbeforehospital)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  11 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         1 |        10 | 
##           |     0.091 |     0.909 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$AEDbeforehospital, pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$awareness2017)
## 
##  Fisher's Exact Test for Count Data
## 
## data:  
## p-value = 0.04365
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##    0.9420621 336.7607655
## sample estimates:
## odds ratio 
##   7.347579
# Logistic regression adjusting for potential confounders among those with prior epilepsy
logistic_out_of_hospital_BZD_prior_epilepsy <- glm(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$AEDbeforehospital ~ pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$day + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$white +
                pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$structuraletiology + 
                pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$status + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no" & pSERG$priorepilepsy==1, ]$SEX, family="binomial")

cbind(exp(cbind("Odds ratio" = coef(logistic_out_of_hospital_BZD_prior_epilepsy), confint(logistic_out_of_hospital_BZD_prior_epilepsy, level = 0.95))), "p-value" = coef(summary(logistic_out_of_hospital_BZD_prior_epilepsy))[ , 4])
## Waiting for profiling to be done...
##                                                                                        Odds ratio
## (Intercept)                                                                             1.5943765
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness2017          15.4364889
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent  0.3257898
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                     1.3960338
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear       0.5267898
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                   0.4876958
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology      1.4629884
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                  8.9357697
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears                1.1321480
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                 0.7770633
##                                                                                             2.5 %
## (Intercept)                                                                            0.20388938
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness2017          1.82958783
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent 0.07934376
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                    0.40448177
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear      0.14344334
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                  0.13080539
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology     0.37904198
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                 1.74042691
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears               0.99884865
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                0.22334930
##                                                                                            97.5 %
## (Intercept)                                                                             13.587188
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness2017          358.118449
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent   1.192805
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                      4.944381
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear        1.803797
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                    1.692243
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology       6.043288
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                  73.479634
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears                 1.307473
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                  2.623113
##                                                                                           p-value
## (Intercept)                                                                            0.65777764
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$awareness2017          0.02881430
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$TYPESTATUSintermittent 0.10013803
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$day                    0.59635903
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$earlyacademicyear      0.31486118
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$white                  0.26489324
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$structuraletiology     0.58565603
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$status                 0.01759709
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$ageyears               0.06594680
## pSERG[pSERG$HOSPITALONSET == "no" & pSERG$priorepilepsy == 1, ]$SEXmale                0.68396910
# Patients in each category
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  184 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       154 |        30 | 
##           |     0.837 |     0.163 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Time to first BZD
summary(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    7.00   21.50   68.46   55.00 1264.00
sd(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0)
## [1] 154.9925
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$BZDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##   184.0   184.0    21.5    20.0    30.0
# Figure time to first BZD
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")

# Time to first BZD depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    7.25   21.50   71.40   58.75 1264.00
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.00    6.25   25.00   53.40   44.25  330.00
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness, rho = 1)
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0 104     52.8     56.6
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1  80     43.7     39.9
##                                                  (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0     0.253      0.96
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1     0.360      0.96
## 
##  Chisq= 1  on 1 degrees of freedom, p= 0.3
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.3272417
# Figure time to first BZD by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first BZD
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "no", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$status + pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$SEX)
## 
##   n= 184, number of events= 184 
## 
##                                                                  coef
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          -0.037281
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -0.430975
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.026219
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.121744
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.150304
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.133821
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.059880
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.542730
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.005961
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.086885
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           0.963405
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.649875
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     1.026566
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.129465
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   1.162187
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      1.143188
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           1.061709
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  1.720698
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                1.005978
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.090771
##                                                              se(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           0.212936
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.168741
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.157271
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.155257
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.161067
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.187873
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.159752
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.214843
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.016146
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.153512
##                                                                  z
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          -0.175
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -2.554
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.167
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.784
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.933
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.712
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.375
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  2.526
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.369
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.566
##                                                             Pr(>|z|)  
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017            0.8610  
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent   0.0106 *
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                      0.8676  
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear        0.4330  
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                    0.3507  
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology       0.4763  
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy            0.7078  
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                   0.0115 *
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                 0.7120  
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                  0.5714  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             0.9634
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.6499
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.0266
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.1295
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     1.1622
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.1432
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.0617
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.7207
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  1.0060
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.0908
##                                                             exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017              1.0380
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     1.5388
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        0.9741
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          0.8854
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      0.8604
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         0.8747
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              0.9419
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     0.5812
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   0.9941
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    0.9168
##                                                             lower .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             0.6347
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.4669
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.7543
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.8331
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.8476
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.7910
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.7763
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.1294
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9746
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.8074
##                                                             upper .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             1.4624
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.9046
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.3972
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.5312
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     1.5936
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.6521
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.4521
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    2.6217
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  1.0383
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.4737
## 
## Concordance= 0.59  (se = 0.027 )
## Rsquare= 0.088   (max possible= 1 )
## Likelihood ratio test= 16.9  on 10 df,   p=0.08
## Wald test            = 17.86  on 10 df,   p=0.06
## Score (logrank) test = 18.41  on 10 df,   p=0.05
# Time to first non-BZD AED
summary(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    50.0    86.0   184.3   175.2  1800.0
sd(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0)
## [1] 269.1477
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$AEDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##     184     184      86      69     115
# Figure time to first non-BZD AED
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")

# Time to first non-BZD AED depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   47.25   88.50  187.08  169.00 1800.00
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   10.00   58.25   77.00  170.23  206.75  720.00
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness, rho = 1)
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0 104     53.8     51.5
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1  80     39.4     41.6
##                                                  (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0    0.0987     0.333
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1    0.1221     0.333
## 
##  Chisq= 0.3  on 1 degrees of freedom, p= 0.6
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.5638338
# Figure time to first non-BZD AED by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first non-BZD AED
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "no", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$status + pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$SEX)
## 
##   n= 184, number of events= 184 
## 
##                                                                 coef
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          -0.12754
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -0.70081
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.11229
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.01565
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -0.06712
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     -0.04680
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          -0.07505
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.06453
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               -0.02225
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.13378
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017            0.88026
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent   0.49618
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                      1.11884
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear        1.01577
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                    0.93508
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology       0.95428
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy            0.92770
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                   1.06665
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                 0.97800
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                  1.14315
##                                                             se(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           0.21073
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.16909
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.16004
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.15601
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.15732
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.18431
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.16528
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.21525
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.01570
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.16036
##                                                                  z
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          -0.605
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent -4.144
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.702
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.100
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -0.427
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology     -0.254
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy          -0.454
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.300
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears               -1.417
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.834
##                                                             Pr(>|z|)    
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             0.545    
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent 3.41e-05 ***
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.483    
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.920    
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.670    
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.800    
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.650    
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.764    
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.156    
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.404    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             0.8803
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.4962
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.1188
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.0158
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.9351
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.9543
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.9277
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.0667
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9780
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.1431
##                                                             exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017              1.1360
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     2.0154
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        0.8938
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          0.9845
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      1.0694
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         1.0479
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              1.0779
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     0.9375
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   1.0225
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    0.8748
##                                                             lower .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             0.5824
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.3562
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.8176
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         0.7482
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.6870
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.6650
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.6710
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.6995
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9484
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.8348
##                                                             upper .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             1.3304
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.6912
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       1.5310
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.3791
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     1.2728
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.3695
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.2826
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.6265
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  1.0086
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.5653
## 
## Concordance= 0.609  (se = 0.025 )
## Rsquare= 0.118   (max possible= 1 )
## Likelihood ratio test= 23.21  on 10 df,   p=0.01
## Wald test            = 23.72  on 10 df,   p=0.008
## Score (logrank) test = 24.58  on 10 df,   p=0.006
# Time to first CI
summary(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    20.0   124.2   193.0   504.4   657.0  4320.0     100
sd(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0)
## [1] NA
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$CONTTIME.0) ~ 
##     1)
## 
##    100 observations deleted due to missingness 
##       n  events  median 0.95LCL 0.95UCL 
##      84      84     193     155     330
# Figure time to first CI
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")

# Time to first CI depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    20.0   125.0   180.0   483.4   626.0  4320.0      77
summary(pSERG[which(pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##      75     330     600     735    1188    1435      23
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness, rho = 1)
## 
## n=84, 100 observations deleted due to missingness.
## 
##                                                   N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0 44     22.3     22.3
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1 40     20.3     20.3
##                                                  (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=0  5.71e-05   0.00018
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness=1  6.29e-05   0.00018
## 
##  Chisq= 0  on 1 degrees of freedom, p= 1
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.9893053
# Figure time to first CI by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first CI
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="no", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="no", ]$TYPESTATUS + 
                pSERG[pSERG$HOSPITALONSET=="no", ]$day + pSERG[pSERG$HOSPITALONSET=="no", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="no", ]$white +
                pSERG[pSERG$HOSPITALONSET=="no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="no", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="no", ]$status + pSERG[pSERG$HOSPITALONSET=="no", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="no", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "no", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "no", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "no", ]$status + pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears + 
##         pSERG[pSERG$HOSPITALONSET == "no", ]$SEX)
## 
##   n= 84, number of events= 84 
##    (100 observations deleted due to missingness)
## 
##                                                                   coef
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          -0.2799580
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.0045694
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    -0.0854560
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.6797016
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -0.5447898
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.4083752
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.0584413
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.2000818
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.0003276
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.2266975
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           0.7558155
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  1.0045798
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.9180935
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       1.9732889
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.5799637
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      1.5043715
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           1.0601828
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  1.2215027
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                1.0003277
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 1.2544503
##                                                               se(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017           0.4240482
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.2697624
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                     0.2363041
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       0.2654572
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                   0.2797099
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      0.3006407
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.2849113
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.3202091
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.0249597
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.2565803
##                                                                  z
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017          -0.660
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent  0.017
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                    -0.362
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear       2.560
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                  -1.948
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology      1.358
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy           0.205
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                  0.625
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                0.013
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                 0.884
##                                                             Pr(>|z|)  
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017            0.5091  
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent   0.9865  
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                      0.7176  
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear        0.0105 *
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                    0.0515 .
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology       0.1744  
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy            0.8375  
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                   0.5321  
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                 0.9895  
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                  0.3769  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                             exp(coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             0.7558
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    1.0046
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.9181
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.9733
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.5800
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        1.5044
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             1.0602
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    1.2215
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  1.0003
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   1.2545
##                                                             exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017              1.3231
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     0.9954
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        1.0892
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          0.5068
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      1.7242
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         0.6647
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              0.9432
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     0.8187
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   0.9997
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    0.7972
##                                                             lower .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017             0.3292
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent    0.5921
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                       0.5778
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear         1.1728
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                     0.3352
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology        0.8345
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy             0.6065
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                    0.6521
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                  0.9526
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                   0.7587
##                                                             upper .95
## pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017              1.735
## pSERG[pSERG$HOSPITALONSET == "no", ]$TYPESTATUSintermittent     1.705
## pSERG[pSERG$HOSPITALONSET == "no", ]$day                        1.459
## pSERG[pSERG$HOSPITALONSET == "no", ]$earlyacademicyear          3.320
## pSERG[pSERG$HOSPITALONSET == "no", ]$white                      1.003
## pSERG[pSERG$HOSPITALONSET == "no", ]$structuraletiology         2.712
## pSERG[pSERG$HOSPITALONSET == "no", ]$priorepilepsy              1.853
## pSERG[pSERG$HOSPITALONSET == "no", ]$status                     2.288
## pSERG[pSERG$HOSPITALONSET == "no", ]$ageyears                   1.050
## pSERG[pSERG$HOSPITALONSET == "no", ]$SEXmale                    2.074
## 
## Concordance= 0.611  (se = 0.037 )
## Rsquare= 0.139   (max possible= 0.999 )
## Likelihood ratio test= 12.56  on 10 df,   p=0.2
## Wald test            = 12.27  on 10 df,   p=0.3
## Score (logrank) test = 12.52  on 10 df,   p=0.3
#### Recommendations and outliers out of the hospital

# First BZD later than 20 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  184 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        92 |        92 | 
##           |     0.500 |     0.500 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  154 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        77 |        77 | 
##           |     0.500 |     0.500 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  30 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        15 |        15 | 
##           |     0.500 |     0.500 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore20min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstBZDmore20min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.4229168 2.3645315
## sample estimates:
## odds ratio 
##          1
# Difference adjusting for covariates within the first 20 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=20,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 20  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.353    -2.383     3.090 0.800
## RMST (arm=1)/(arm=0) 1.022     0.847     1.234 0.819
## RMTL (arm=1)/(arm=0) 0.922     0.550     1.546 0.759
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          18.083    1.673 10.807 0.000    14.803    21.363
## arm                 0.353    1.396  0.253 0.800    -2.383     3.090
## TYPESTATUSnumeric   0.012    1.012  0.012 0.991    -1.971     1.995
## day                -0.647    0.989 -0.654 0.513    -2.585     1.291
## earlyacademicyear  -0.030    0.969 -0.031 0.975    -1.930     1.869
## white              -1.063    0.983 -1.081 0.280    -2.990     0.864
## structuraletiology -0.922    1.171 -0.787 0.431    -3.218     1.374
## priorepilepsy      -1.912    0.988 -1.935 0.053    -3.850     0.025
## status             -4.822    1.490 -3.236 0.001    -7.742    -1.902
## ageyears           -0.077    0.101 -0.760 0.447    -0.275     0.121
## SEXnumeric          0.203    0.988  0.206 0.837    -1.733     2.139
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.913    0.110 26.531 0.000    18.404    14.841
## arm                 0.022    0.096  0.229 0.819     1.022     0.847
## TYPESTATUSnumeric   0.000    0.068 -0.004 0.997     1.000     0.874
## day                -0.045    0.067 -0.672 0.502     0.956     0.837
## earlyacademicyear  -0.002    0.065 -0.027 0.979     0.998     0.878
## white              -0.072    0.066 -1.088 0.276     0.931     0.818
## structuraletiology -0.062    0.080 -0.776 0.437     0.940     0.803
## priorepilepsy      -0.127    0.068 -1.877 0.061     0.880     0.771
## status             -0.377    0.134 -2.812 0.005     0.686     0.528
## ageyears           -0.005    0.007 -0.782 0.434     0.995     0.981
## SEXnumeric          0.015    0.068  0.214 0.831     1.015     0.888
##                    upper .95
## intercept             22.823
## arm                    1.234
## TYPESTATUSnumeric      1.143
## day                    1.091
## earlyacademicyear      1.135
## white                  1.059
## structuraletiology     1.100
## priorepilepsy          1.006
## status                 0.892
## ageyears               1.008
## SEXnumeric             1.159
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           0.971    0.372  2.608 0.009     2.641     1.273
## arm                -0.081    0.264 -0.307 0.759     0.922     0.550
## TYPESTATUSnumeric  -0.010    0.199 -0.051 0.959     0.990     0.670
## day                 0.114    0.189  0.603 0.546     1.121     0.774
## earlyacademicyear   0.008    0.192  0.041 0.967     1.008     0.692
## white               0.204    0.198  1.030 0.303     1.226     0.832
## structuraletiology  0.178    0.221  0.805 0.421     1.195     0.775
## priorepilepsy       0.400    0.204  1.964 0.050     1.492     1.001
## status              0.718    0.200  3.598 0.000     2.050     1.386
## ageyears            0.013    0.019  0.670 0.503     1.013     0.976
## SEXnumeric         -0.034    0.190 -0.178 0.859     0.967     0.666
##                    upper .95
## intercept              5.477
## arm                    1.546
## TYPESTATUSnumeric      1.461
## day                    1.622
## earlyacademicyear      1.468
## white                  1.807
## structuraletiology     1.842
## priorepilepsy          2.224
## status                 3.031
## ageyears               1.051
## SEXnumeric             1.403
# First BZD later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  184 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       123 |        61 | 
##           |     0.668 |     0.332 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  154 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       102 |        52 | 
##           |     0.662 |     0.338 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  30 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        21 |         9 | 
##           |     0.700 |     0.300 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore40min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstBZDmore40min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.8328
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3158394 2.0838829
## sample estimates:
## odds ratio 
##   0.841457
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.476    -5.567     6.519 0.877
## RMST (arm=1)/(arm=0) 1.022     0.783     1.333 0.873
## RMTL (arm=1)/(arm=0) 0.976     0.685     1.389 0.891
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          28.277    3.457  8.180 0.000    21.502    35.053
## arm                 0.476    3.083  0.154 0.877    -5.567     6.519
## TYPESTATUSnumeric  -2.929    2.160 -1.356 0.175    -7.163     1.305
## day                -0.751    2.159 -0.348 0.728    -4.983     3.481
## earlyacademicyear  -0.640    2.090 -0.306 0.759    -4.736     3.456
## white              -0.691    2.142 -0.323 0.747    -4.889     3.507
## structuraletiology  0.266    2.608  0.102 0.919    -4.845     5.377
## priorepilepsy      -0.971    2.185 -0.444 0.657    -5.255     3.312
## status             -8.705    3.037 -2.867 0.004   -14.657    -2.754
## ageyears           -0.176    0.216 -0.815 0.415    -0.598     0.247
## SEXnumeric         -0.150    2.181 -0.069 0.945    -4.424     4.124
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.358    0.145 23.216 0.000    28.742    21.646
## arm                 0.022    0.136  0.159 0.873     1.022     0.783
## TYPESTATUSnumeric  -0.129    0.096 -1.344 0.179     0.879     0.727
## day                -0.036    0.094 -0.382 0.702     0.965     0.803
## earlyacademicyear  -0.026    0.090 -0.284 0.776     0.975     0.817
## white              -0.028    0.093 -0.307 0.759     0.972     0.810
## structuraletiology  0.013    0.109  0.116 0.908     1.013     0.817
## priorepilepsy      -0.045    0.093 -0.478 0.633     0.956     0.796
## status             -0.447    0.181 -2.467 0.014     0.639     0.448
## ageyears           -0.008    0.010 -0.796 0.426     0.992     0.974
## SEXnumeric         -0.004    0.095 -0.037 0.970     0.996     0.827
##                    upper .95
## intercept             38.163
## arm                    1.333
## TYPESTATUSnumeric      1.061
## day                    1.159
## earlyacademicyear      1.163
## white                  1.166
## structuraletiology     1.255
## priorepilepsy          1.148
## status                 0.912
## ageyears               1.011
## SEXnumeric             1.201
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.508    0.219 11.444 0.000    12.282     7.993
## arm                -0.025    0.180 -0.137 0.891     0.976     0.685
## TYPESTATUSnumeric   0.171    0.127  1.348 0.178     1.186     0.925
## day                 0.039    0.129  0.300 0.764     1.039     0.808
## earlyacademicyear   0.042    0.125  0.335 0.738     1.043     0.816
## white               0.044    0.127  0.343 0.732     1.045     0.814
## structuraletiology -0.014    0.163 -0.088 0.930     0.986     0.716
## priorepilepsy       0.053    0.134  0.399 0.690     1.055     0.812
## status              0.441    0.145  3.045 0.002     1.554     1.170
## ageyears            0.010    0.013  0.833 0.405     1.011     0.986
## SEXnumeric          0.014    0.130  0.109 0.913     1.014     0.786
##                    upper .95
## intercept             18.873
## arm                    1.389
## TYPESTATUSnumeric      1.521
## day                    1.338
## earlyacademicyear      1.333
## white                  1.341
## structuraletiology     1.357
## priorepilepsy          1.371
## status                 2.063
## ageyears               1.036
## SEXnumeric             1.308
# First BZD later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  184 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       144 |        40 | 
##           |     0.783 |     0.217 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  154 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       119 |        35 | 
##           |     0.773 |     0.227 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  30 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        25 |         5 | 
##           |     0.833 |     0.167 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstBZDmore60min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstBZDmore60min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.6293
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.189624 1.998742
## sample estimates:
## odds ratio 
##  0.6813211
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.619    -9.236     7.998 0.888
## RMST (arm=1)/(arm=0)  0.982     0.718     1.342 0.909
## RMTL (arm=1)/(arm=0)  1.024     0.784     1.337 0.865
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept           36.598    5.145  7.113 0.000    26.514    46.682
## arm                 -0.619    4.396 -0.141 0.888    -9.236     7.998
## TYPESTATUSnumeric   -6.005    3.173 -1.893 0.058   -12.223     0.214
## day                 -1.095    3.185 -0.344 0.731    -7.337     5.147
## earlyacademicyear   -1.459    3.080 -0.474 0.636    -7.496     4.579
## white               -1.223    3.197 -0.383 0.702    -7.488     5.042
## structuraletiology   0.859    3.849  0.223 0.823    -6.685     8.403
## priorepilepsy        1.468    3.273  0.449 0.654    -4.947     7.883
## status             -13.050    4.058 -3.216 0.001   -21.004    -5.096
## ageyears            -0.296    0.312 -0.951 0.341    -0.907     0.314
## SEXnumeric          -0.979    3.233 -0.303 0.762    -7.316     5.357
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.620    0.172 21.076 0.000    37.334    26.663
## arm                -0.018    0.159 -0.114 0.909     0.982     0.718
## TYPESTATUSnumeric  -0.214    0.116 -1.841 0.066     0.807     0.643
## day                -0.042    0.111 -0.375 0.707     0.959     0.772
## earlyacademicyear  -0.046    0.107 -0.427 0.669     0.955     0.775
## white              -0.040    0.112 -0.356 0.722     0.961     0.772
## structuraletiology  0.030    0.128  0.235 0.814     1.030     0.802
## priorepilepsy       0.044    0.111  0.399 0.690     1.045     0.841
## status             -0.553    0.204 -2.706 0.007     0.575     0.385
## ageyears           -0.010    0.011 -0.920 0.358     0.990     0.968
## SEXnumeric         -0.028    0.113 -0.251 0.802     0.972     0.780
##                    upper .95
## intercept             52.276
## arm                    1.342
## TYPESTATUSnumeric      1.014
## day                    1.192
## earlyacademicyear      1.177
## white                  1.196
## structuraletiology     1.323
## priorepilepsy          1.298
## status                 0.859
## ageyears               1.012
## SEXnumeric             1.212
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.179    0.175 18.171 0.000    24.015    17.044
## arm                 0.023    0.136  0.171 0.865     1.024     0.784
## TYPESTATUSnumeric   0.190    0.101  1.892 0.058     1.210     0.993
## day                 0.033    0.103  0.317 0.751     1.033     0.844
## earlyacademicyear   0.051    0.100  0.515 0.607     1.053     0.866
## white               0.042    0.103  0.406 0.685     1.043     0.852
## structuraletiology -0.028    0.130 -0.214 0.830     0.972     0.753
## priorepilepsy      -0.053    0.108 -0.487 0.627     0.949     0.767
## status              0.372    0.112  3.326 0.001     1.451     1.165
## ageyears            0.010    0.010  0.970 0.332     1.010     0.990
## SEXnumeric          0.036    0.105  0.344 0.731     1.037     0.844
##                    upper .95
## intercept             33.836
## arm                    1.337
## TYPESTATUSnumeric      1.473
## day                    1.264
## earlyacademicyear      1.280
## white                  1.276
## structuraletiology     1.256
## priorepilepsy          1.173
## status                 1.806
## ageyears               1.029
## SEXnumeric             1.273
# First non-BZD ASM later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  184 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        33 |       151 | 
##           |     0.179 |     0.821 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  154 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        30 |       124 | 
##           |     0.195 |     0.805 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  30 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         3 |        27 | 
##           |     0.100 |     0.900 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore40min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstASMmore40min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.3004
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.6040606 11.9112959
## sample estimates:
## odds ratio 
##   2.169754
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.993    -1.627     3.614 0.458
## RMST (arm=1)/(arm=0) 1.027     0.958     1.100 0.451
## RMTL (arm=1)/(arm=0) 0.678     0.180     2.551 0.565
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          34.263    2.065 16.594 0.000    30.216    38.309
## arm                 0.993    1.337  0.743 0.458    -1.627     3.614
## TYPESTATUSnumeric  -0.877    1.023 -0.857 0.391    -2.882     1.128
## day                -0.452    1.135 -0.398 0.691    -2.677     1.773
## earlyacademicyear   1.599    1.056  1.513 0.130    -0.472     3.669
## white               0.741    1.109  0.668 0.504    -1.433     2.915
## structuraletiology  0.739    1.231  0.600 0.548    -1.674     3.153
## priorepilepsy       1.580    1.167  1.354 0.176    -0.707     3.866
## status              0.824    1.153  0.715 0.475    -1.436     3.085
## ageyears            0.075    0.112  0.672 0.502    -0.144     0.295
## SEXnumeric          1.308    1.109  1.179 0.238    -0.866     3.482
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.536    0.057 61.939 0.000    34.335    30.700
## arm                 0.027    0.035  0.753 0.451     1.027     0.958
## TYPESTATUSnumeric  -0.023    0.028 -0.843 0.399     0.977     0.926
## day                -0.012    0.030 -0.400 0.689     0.988     0.931
## earlyacademicyear   0.043    0.029  1.496 0.135     1.044     0.987
## white               0.020    0.030  0.673 0.501     1.020     0.962
## structuraletiology  0.020    0.033  0.604 0.546     1.020     0.956
## priorepilepsy       0.042    0.031  1.352 0.176     1.043     0.981
## status              0.022    0.030  0.709 0.478     1.022     0.963
## ageyears            0.002    0.003  0.687 0.492     1.002     0.996
## SEXnumeric          0.035    0.030  1.171 0.242     1.036     0.977
##                    upper .95
## intercept             38.400
## arm                    1.100
## TYPESTATUSnumeric      1.031
## day                    1.049
## earlyacademicyear      1.104
## white                  1.082
## structuraletiology     1.088
## priorepilepsy          1.110
## status                 1.085
## ageyears               1.008
## SEXnumeric             1.098
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           1.902    0.560  3.398 0.001     6.696     2.236
## arm                -0.389    0.676 -0.575 0.565     0.678     0.180
## TYPESTATUSnumeric   0.374    0.378  0.990 0.322     1.453     0.693
## day                 0.164    0.436  0.375 0.707     1.178     0.501
## earlyacademicyear  -0.661    0.425 -1.556 0.120     0.516     0.225
## white              -0.218    0.401 -0.545 0.586     0.804     0.366
## structuraletiology -0.277    0.483 -0.574 0.566     0.758     0.294
## priorepilepsy      -0.605    0.489 -1.237 0.216     0.546     0.210
## status             -0.404    0.577 -0.700 0.484     0.668     0.216
## ageyears           -0.022    0.049 -0.447 0.655     0.978     0.889
## SEXnumeric         -0.503    0.410 -1.226 0.220     0.605     0.271
##                    upper .95
## intercept             20.053
## arm                    2.551
## TYPESTATUSnumeric      3.047
## day                    2.770
## earlyacademicyear      1.187
## white                  1.764
## structuraletiology     1.953
## priorepilepsy          1.424
## status                 2.069
## ageyears               1.077
## SEXnumeric             1.351
# First non-BZD ASM later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  184 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        64 |       120 | 
##           |     0.348 |     0.652 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  154 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        55 |        99 | 
##           |     0.357 |     0.643 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  30 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         9 |        21 | 
##           |     0.300 |     0.700 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore60min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstASMmore60min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.6763
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.5238944 3.4427485
## sample estimates:
## odds ratio 
##   1.294519
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 2.761    -2.208     7.730 0.276
## RMST (arm=1)/(arm=0) 1.054     0.961     1.156 0.266
## RMTL (arm=1)/(arm=0) 0.680     0.288     1.603 0.378
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          46.149    3.713 12.429 0.000    38.872    53.427
## arm                 2.761    2.535  1.089 0.276    -2.208     7.730
## TYPESTATUSnumeric  -2.503    1.979 -1.264 0.206    -6.381     1.376
## day                -1.347    2.105 -0.640 0.522    -5.473     2.778
## earlyacademicyear   3.248    2.023  1.605 0.108    -0.718     7.214
## white               1.259    2.132  0.591 0.555    -2.919     5.437
## structuraletiology  0.685    2.419  0.283 0.777    -4.057     5.427
## priorepilepsy       4.062    2.150  1.890 0.059    -0.151     8.276
## status              1.720    2.212  0.777 0.437    -2.616     6.055
## ageyears            0.194    0.211  0.920 0.358    -0.219     0.607
## SEXnumeric          2.746    2.076  1.323 0.186    -1.322     6.815
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.836    0.074 51.585 0.000    46.324    40.041
## arm                 0.052    0.047  1.113 0.266     1.054     0.961
## TYPESTATUSnumeric  -0.047    0.039 -1.231 0.218     0.954     0.884
## day                -0.026    0.040 -0.643 0.520     0.974     0.901
## earlyacademicyear   0.062    0.039  1.586 0.113     1.064     0.986
## white               0.025    0.041  0.598 0.550     1.025     0.945
## structuraletiology  0.013    0.046  0.289 0.773     1.014     0.925
## priorepilepsy       0.078    0.041  1.881 0.060     1.081     0.997
## status              0.032    0.041  0.769 0.442     1.032     0.952
## ageyears            0.004    0.004  0.950 0.342     1.004     0.996
## SEXnumeric          0.053    0.040  1.310 0.190     1.054     0.974
##                    upper .95
## intercept             53.591
## arm                    1.156
## TYPESTATUSnumeric      1.028
## day                    1.054
## earlyacademicyear      1.148
## white                  1.111
## structuraletiology     1.110
## priorepilepsy          1.173
## status                 1.119
## ageyears               1.012
## SEXnumeric             1.141
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.699    0.386  6.988 0.000    14.863     6.972
## arm                -0.386    0.438 -0.882 0.378     0.680     0.288
## TYPESTATUSnumeric   0.346    0.246  1.408 0.159     1.413     0.873
## day                 0.173    0.282  0.612 0.541     1.189     0.684
## earlyacademicyear  -0.452    0.281 -1.610 0.107     0.636     0.367
## white              -0.136    0.265 -0.511 0.609     0.873     0.519
## structuraletiology -0.085    0.310 -0.275 0.784     0.919     0.501
## priorepilepsy      -0.541    0.307 -1.764 0.078     0.582     0.319
## status             -0.272    0.367 -0.741 0.458     0.762     0.371
## ageyears           -0.022    0.032 -0.693 0.488     0.978     0.919
## SEXnumeric         -0.360    0.265 -1.356 0.175     0.698     0.415
##                    upper .95
## intercept             31.682
## arm                    1.603
## TYPESTATUSnumeric      2.287
## day                    2.067
## earlyacademicyear      1.103
## white                  1.469
## structuraletiology     1.685
## priorepilepsy          1.062
## status                 1.565
## ageyears               1.041
## SEXnumeric             1.174
# First non-BZD ASM later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  184 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |       115 |        69 | 
##           |     0.625 |     0.375 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  154 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        95 |        59 | 
##           |     0.617 |     0.383 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  30 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        20 |        10 | 
##           |     0.667 |     0.333 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstASMmore120min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstASMmore120min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.6834
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3140104 1.9539929
## sample estimates:
## odds ratio 
##  0.8060165
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="no", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=120,
      covariates= pSERG[pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 2.272   -11.336    15.879 0.744
## RMST (arm=1)/(arm=0) 1.027     0.872     1.210 0.746
## RMTL (arm=1)/(arm=0) 0.940     0.648     1.363 0.742
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept           79.800    8.597  9.282 0.000    62.950    96.650
## arm                  2.272    6.943  0.327 0.744   -11.336    15.879
## TYPESTATUSnumeric  -20.854    5.358 -3.892 0.000   -31.355   -10.353
## day                 -3.333    5.367 -0.621 0.535   -13.853     7.187
## earlyacademicyear    3.497    5.374  0.651 0.515    -7.036    14.029
## white                1.691    5.551  0.305 0.761    -9.188    12.571
## structuraletiology  -2.338    6.685 -0.350 0.727   -15.441    10.764
## priorepilepsy        9.059    5.604  1.616 0.106    -1.925    20.044
## status              -1.338    6.614 -0.202 0.840   -14.302    11.626
## ageyears             0.529    0.539  0.980 0.327    -0.529     1.586
## SEXnumeric           4.151    5.440  0.763 0.445    -6.511    14.813
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.371    0.108 40.472 0.000    79.108    64.017
## arm                 0.027    0.084  0.324 0.746     1.027     0.872
## TYPESTATUSnumeric  -0.264    0.071 -3.725 0.000     0.768     0.668
## day                -0.040    0.065 -0.610 0.542     0.961     0.846
## earlyacademicyear   0.044    0.065  0.671 0.502     1.045     0.919
## white               0.021    0.069  0.301 0.764     1.021     0.892
## structuraletiology -0.027    0.083 -0.325 0.745     0.973     0.828
## priorepilepsy       0.109    0.068  1.597 0.110     1.116     0.975
## status             -0.015    0.081 -0.190 0.849     0.985     0.840
## ageyears            0.006    0.006  1.022 0.307     1.006     0.994
## SEXnumeric          0.051    0.067  0.762 0.446     1.052     0.923
##                    upper .95
## intercept             97.756
## arm                    1.210
## TYPESTATUSnumeric      0.882
## day                    1.092
## earlyacademicyear      1.187
## white                  1.169
## structuraletiology     1.145
## priorepilepsy          1.276
## status                 1.154
## ageyears               1.019
## SEXnumeric             1.200
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.651    0.224 16.321 0.000    38.497    24.833
## arm                -0.062    0.190 -0.329 0.742     0.940     0.648
## TYPESTATUSnumeric   0.527    0.140  3.771 0.000     1.693     1.288
## day                 0.092    0.146  0.628 0.530     1.096     0.824
## earlyacademicyear  -0.086    0.148 -0.586 0.558     0.917     0.687
## white              -0.045    0.143 -0.314 0.753     0.956     0.722
## structuraletiology  0.068    0.173  0.391 0.696     1.070     0.763
## priorepilepsy      -0.247    0.153 -1.609 0.108     0.781     0.578
## status              0.044    0.177  0.250 0.802     1.045     0.739
## ageyears           -0.015    0.017 -0.874 0.382     0.986     0.954
## SEXnumeric         -0.108    0.145 -0.748 0.455     0.897     0.675
##                    upper .95
## intercept             59.680
## arm                    1.363
## TYPESTATUSnumeric      2.226
## day                    1.458
## earlyacademicyear      1.225
## white                  1.266
## structuraletiology     1.501
## priorepilepsy          1.055
## status                 1.477
## ageyears               1.018
## SEXnumeric             1.192
# First CI later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         6 |        78 | 
##           |     0.071 |     0.929 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  77 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         6 |        71 | 
##           |     0.078 |     0.922 | 
##           |-----------|-----------|
## 
## 
## 
## 
table(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstCImore60min)
## 
## 0 1 
## 0 7
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore60min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstCImore60min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.09426226        Inf
## sample estimates:
## odds ratio 
##        Inf
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=60,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.826    -0.620     2.271 0.263
## RMST (arm=1)/(arm=0) 1.014     0.989     1.039 0.270
## RMTL (arm=1)/(arm=0) 0.000     0.000     0.000 0.000
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          59.945    0.870 68.909 0.000    58.240    61.650
## arm                 0.826    0.738  1.119 0.263    -0.620     2.271
## TYPESTATUSnumeric   0.491    0.641  0.765 0.444    -0.766     1.748
## day                -0.101    1.089 -0.093 0.926    -2.235     2.033
## earlyacademicyear  -1.916    1.096 -1.749 0.080    -4.064     0.231
## white              -1.023    1.096 -0.934 0.350    -3.171     1.125
## structuraletiology  0.489    0.563  0.869 0.385    -0.614     1.592
## priorepilepsy      -0.957    1.168 -0.819 0.413    -3.247     1.332
## status              1.491    0.940  1.586 0.113    -0.351     3.334
## ageyears           -0.054    0.064 -0.837 0.403    -0.180     0.072
## SEXnumeric          1.636    1.455  1.125 0.261    -1.215     4.488
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)       z     p exp(coef) lower .95
## intercept           4.093    0.015 276.997 0.000    59.936    58.225
## arm                 0.014    0.013   1.102 0.270     1.014     0.989
## TYPESTATUSnumeric   0.008    0.011   0.760 0.447     1.008     0.987
## day                -0.002    0.019  -0.087 0.930     0.998     0.963
## earlyacademicyear  -0.032    0.019  -1.723 0.085     0.968     0.933
## white              -0.017    0.019  -0.925 0.355     0.983     0.947
## structuraletiology  0.008    0.010   0.847 0.397     1.008     0.989
## priorepilepsy      -0.016    0.020  -0.812 0.417     0.984     0.946
## status              0.025    0.016   1.570 0.116     1.025     0.994
## ageyears           -0.001    0.001  -0.832 0.405     0.999     0.997
## SEXnumeric          0.028    0.025   1.110 0.267     1.028     0.979
##                    upper .95
## intercept             61.697
## arm                    1.039
## TYPESTATUSnumeric      1.030
## day                    1.036
## earlyacademicyear      1.004
## white                  1.020
## structuraletiology     1.027
## priorepilepsy          1.023
## status                 1.058
## ageyears               1.001
## SEXnumeric             1.080
## 
## 
## Model summary (ratio of time-lost) 
##                       coef se(coef)       z     p exp(coef) lower .95
## intercept           -3.964    2.740  -1.447 0.148     0.019     0.000
## arm                -17.619    0.928 -18.986 0.000     0.000     0.000
## TYPESTATUSnumeric   -1.291    1.369  -0.943 0.346     0.275     0.019
## day                  1.144    1.206   0.949 0.343     3.140     0.296
## earlyacademicyear    3.138    1.190   2.638 0.008    23.052     2.240
## white                1.674    1.724   0.971 0.331     5.335     0.182
## structuraletiology  -2.106    1.245  -1.692 0.091     0.122     0.011
## priorepilepsy        1.450    0.887   1.635 0.102     4.264     0.750
## status             -18.128    1.231 -14.731 0.000     0.000     0.000
## ageyears             0.011    0.064   0.172 0.863     1.011     0.892
## SEXnumeric          -1.889    1.159  -1.629 0.103     0.151     0.016
##                    upper .95
## intercept              4.079
## arm                    0.000
## TYPESTATUSnumeric      4.021
## day                   33.360
## earlyacademicyear    237.289
## white                156.600
## structuraletiology     1.396
## priorepilepsy         24.247
## status                 0.000
## ageyears               1.146
## SEXnumeric             1.467
# First CI later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        20 |        64 | 
##           |     0.238 |     0.762 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  77 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        18 |        59 | 
##           |     0.234 |     0.766 | 
##           |-----------|-----------|
## 
## 
## 
## 
table(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstCImore120min)
## 
## 0 1 
## 2 5
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore120min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstCImore120min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.6689
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1129328 8.6849104
## sample estimates:
## odds ratio 
##  0.7653212
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=120,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 4.913    -6.788    16.613 0.411
## RMST (arm=1)/(arm=0) 1.045     0.941     1.160 0.415
## RMTL (arm=1)/(arm=0) 0.523     0.102     2.684 0.438
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          110.300    8.310 13.273 0.000    94.013   126.587
## arm                  4.913    5.970  0.823 0.411    -6.788    16.613
## TYPESTATUSnumeric    2.340    4.679  0.500 0.617    -6.832    11.511
## day                 -4.426    5.006 -0.884 0.377   -14.237     5.385
## earlyacademicyear   -8.889    5.320 -1.671 0.095   -19.316     1.538
## white                6.523    5.294  1.232 0.218    -3.853    16.898
## structuraletiology   1.789    5.855  0.306 0.760    -9.687    13.266
## priorepilepsy       -5.047    5.550 -0.909 0.363   -15.926     5.832
## status              10.101    4.748  2.127 0.033     0.794    19.407
## ageyears             0.120    0.444  0.270 0.787    -0.751     0.991
## SEXnumeric           0.826    5.200  0.159 0.874    -9.366    11.018
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.702    0.075 62.467 0.000   110.126    95.022
## arm                 0.044    0.054  0.816 0.415     1.045     0.941
## TYPESTATUSnumeric   0.022    0.043  0.507 0.612     1.022     0.940
## day                -0.041    0.046 -0.893 0.372     0.960     0.878
## earlyacademicyear  -0.081    0.049 -1.646 0.100     0.922     0.837
## white               0.060    0.049  1.231 0.218     1.062     0.965
## structuraletiology  0.015    0.054  0.286 0.775     1.015     0.914
## priorepilepsy      -0.046    0.051 -0.893 0.372     0.955     0.864
## status              0.090    0.043  2.104 0.035     1.095     1.006
## ageyears            0.001    0.004  0.262 0.794     1.001     0.993
## SEXnumeric          0.008    0.047  0.170 0.865     1.008     0.919
##                    upper .95
## intercept            127.631
## arm                    1.160
## TYPESTATUSnumeric      1.111
## day                    1.050
## earlyacademicyear      1.016
## white                  1.168
## structuraletiology     1.128
## priorepilepsy          1.056
## status                 1.191
## ageyears               1.009
## SEXnumeric             1.106
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.049    0.975  2.103 0.035     7.764     1.149
## arm                -0.647    0.834 -0.776 0.438     0.523     0.102
## TYPESTATUSnumeric  -0.215    0.505 -0.425 0.671     0.807     0.300
## day                 0.380    0.506  0.752 0.452     1.463     0.543
## earlyacademicyear   0.945    0.592  1.596 0.111     2.573     0.806
## white              -0.611    0.555 -1.101 0.271     0.543     0.183
## structuraletiology -0.255    0.596 -0.428 0.668     0.775     0.241
## priorepilepsy       0.527    0.513  1.026 0.305     1.694     0.619
## status             -1.415    0.766 -1.847 0.065     0.243     0.054
## ageyears           -0.015    0.046 -0.322 0.747     0.985     0.900
## SEXnumeric         -0.017    0.558 -0.031 0.975     0.983     0.329
##                    upper .95
## intercept             52.442
## arm                    2.684
## TYPESTATUSnumeric      2.172
## day                    3.942
## earlyacademicyear      8.213
## white                  1.611
## structuraletiology     2.490
## priorepilepsy          4.631
## status                 1.090
## ageyears               1.079
## SEXnumeric             2.931
# First CI later than 240 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        48 |        36 | 
##           |     0.571 |     0.429 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 0, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  77 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        46 |        31 | 
##           |     0.597 |     0.403 | 
##           |-----------|-----------|
## 
## 
## 
## 
table(pSERG[pSERG$HOSPITALONSET=="no" & pSERG$awareness2017 == 1, ]$firstCImore240min)
## 
## 0 1 
## 2 5
fisher.test(pSERG[pSERG$HOSPITALONSET=="no", ]$firstCImore240min, pSERG[pSERG$HOSPITALONSET=="no", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "no", ]$firstCImore240min and pSERG[pSERG$HOSPITALONSET == "no", ]$awareness2017
## p-value = 0.1326
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.5550491 40.6682398
## sample estimates:
## odds ratio 
##   3.652315
# Difference adjusting for covariates within the first 240 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", ]$awareness2017, tau=240,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="no", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 240  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 28.511   -20.659    77.681 0.256
## RMST (arm=1)/(arm=0)  1.165     0.904     1.502 0.239
## RMTL (arm=1)/(arm=0)  0.583     0.181     1.875 0.365
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          185.450   26.115  7.101 0.000   134.266   236.634
## arm                 28.511   25.087  1.136 0.256   -20.659    77.681
## TYPESTATUSnumeric  -17.357   15.906 -1.091 0.275   -48.531    13.818
## day                 -8.354   15.591 -0.536 0.592   -38.911    22.203
## earlyacademicyear  -27.603   15.269 -1.808 0.071   -57.529     2.323
## white               22.788   16.083  1.417 0.157    -8.735    54.311
## structuraletiology  -3.952   17.806 -0.222 0.824   -38.851    30.947
## priorepilepsy        8.510   17.091  0.498 0.619   -24.988    42.008
## status              12.547   16.197  0.775 0.439   -19.198    44.293
## ageyears            -0.384    1.411 -0.272 0.785    -3.149     2.381
## SEXnumeric          -9.170   14.558 -0.630 0.529   -37.702    19.363
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           5.213    0.145 35.832 0.000   183.645   138.083
## arm                 0.153    0.130  1.179 0.239     1.165     0.904
## TYPESTATUSnumeric  -0.104    0.095 -1.089 0.276     0.902     0.748
## day                -0.043    0.088 -0.492 0.623     0.958     0.807
## earlyacademicyear  -0.156    0.087 -1.787 0.074     0.856     0.721
## white               0.131    0.095  1.379 0.168     1.140     0.946
## structuraletiology -0.023    0.102 -0.228 0.820     0.977     0.800
## priorepilepsy       0.048    0.095  0.503 0.615     1.049     0.871
## status              0.078    0.091  0.855 0.393     1.081     0.905
## ageyears           -0.002    0.008 -0.266 0.790     0.998     0.982
## SEXnumeric         -0.050    0.082 -0.607 0.544     0.951     0.809
##                    upper .95
## intercept            244.240
## arm                    1.502
## TYPESTATUSnumeric      1.086
## day                    1.137
## earlyacademicyear      1.015
## white                  1.373
## structuraletiology     1.193
## priorepilepsy          1.263
## status                 1.291
## ageyears               1.014
## SEXnumeric             1.118
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.927    0.451  8.716 0.000    50.778    20.995
## arm                -0.540    0.596 -0.905 0.365     0.583     0.181
## TYPESTATUSnumeric   0.240    0.232  1.036 0.300     1.271     0.807
## day                 0.165    0.261  0.632 0.527     1.180     0.707
## earlyacademicyear   0.448    0.255  1.758 0.079     1.565     0.950
## white              -0.354    0.246 -1.440 0.150     0.702     0.434
## structuraletiology  0.053    0.275  0.191 0.848     1.054     0.615
## priorepilepsy      -0.136    0.291 -0.467 0.640     0.873     0.493
## status             -0.154    0.278 -0.551 0.581     0.858     0.497
## ageyears            0.006    0.023  0.266 0.790     1.006     0.962
## SEXnumeric          0.159    0.240  0.664 0.507     1.173     0.733
##                    upper .95
## intercept            122.811
## arm                    1.875
## TYPESTATUSnumeric      2.003
## day                    1.968
## earlyacademicyear      2.577
## white                  1.136
## structuraletiology     1.807
## priorepilepsy          1.545
## status                 1.480
## ageyears               1.052
## SEXnumeric             1.876
## IN THE HOSPITAL

# Patients in each group
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        66 |        18 | 
##           |     0.786 |     0.214 | 
##           |-----------|-----------|
## 
## 
## 
## 
# Time to first BZD
summary(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    4.00   10.00   30.83   24.25  360.00
sd(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0)
## [1] 62.38161
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$BZDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##      84      84      10       5      16
# Figure time to first BZD
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")

# Time to first BZD depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    4.00    9.50   32.83   27.50  360.00
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1), ]$BZDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.00    4.25   12.50   23.50   20.75  205.00
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness, rho = 1)
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0 46     24.4     24.2
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1 38     19.6     19.8
##                                                   (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0   0.00150   0.00518
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1   0.00183   0.00518
## 
##  Chisq= 0  on 1 degrees of freedom, p= 0.9
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.9426513
# Figure time to first BZD by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,60), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first BZD (min)", ylab= "Cum. prob. having received first BZD")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first BZD
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="yes", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="yes", ]$day + pSERG[pSERG$HOSPITALONSET=="yes", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="yes", ]$white +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="yes", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$status + pSERG[pSERG$HOSPITALONSET=="yes", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="yes", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$BZDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "yes", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$status + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$ageyears + pSERG[pSERG$HOSPITALONSET == "yes", ]$SEX)
## 
##   n= 84, number of events= 84 
## 
##                                                                  coef
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.18923
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.06385
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.30148
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.41950
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.01746
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology     -0.03476
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.04428
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.09315
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.02157
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.07387
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017            1.20831
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent   0.93815
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                      1.35186
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear        1.52119
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                    0.98269
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology       0.96584
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy            1.04528
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                   1.09763
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                 0.97866
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                  1.07666
##                                                              se(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.29369
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.30279
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.27727
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.25481
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.24425
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.26017
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.31139
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.35498
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.02309
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.25797
##                                                                   z
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.644
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.211
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     1.087
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       1.646
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.071
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology     -0.134
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.142
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.262
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.934
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.286
##                                                              Pr(>|z|)  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017            0.5194  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent   0.8330  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                      0.2769  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear        0.0997 .
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                    0.9430  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology       0.8937  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy            0.8869  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                   0.7930  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                 0.3502  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                  0.7746  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             1.2083
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.9381
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       1.3519
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         1.5212
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.9827
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.9658
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             1.0453
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    1.0976
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9787
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   1.0767
##                                                              exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017              0.8276
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.0659
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        0.7397
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          0.6574
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.0176
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.0354
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              0.9567
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     0.9111
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.0218
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    0.9288
##                                                              lower .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             0.6795
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.5182
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.7851
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.9232
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.6088
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.5800
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.5678
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.5474
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9354
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.6494
##                                                              upper .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017              2.149
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.698
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        2.328
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          2.507
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.586
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.608
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              1.924
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     2.201
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.024
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    1.785
## 
## Concordance= 0.593  (se = 0.04 )
## Rsquare= 0.092   (max possible= 0.999 )
## Likelihood ratio test= 8.13  on 10 df,   p=0.6
## Wald test            = 8.11  on 10 df,   p=0.6
## Score (logrank) test = 8.26  on 10 df,   p=0.6
# Time to first non-BZD AED
summary(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    3.00   21.75   39.00   85.01   76.25 1419.00
sd(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0)
## [1] 171.8644
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$AEDTIME.0) ~ 
##     1)
## 
##       n  events  median 0.95LCL 0.95UCL 
##      84      84      39      29      58
# Figure time to first non-BZD AED
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")

# Time to first non-BZD AED depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     3.0    20.0    41.5    72.7    75.5   503.0
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1), ]$AEDTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    16.0    24.0    30.0   130.2    81.0  1419.0
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness, rho = 1)
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0 46     22.9     24.2
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1 38     20.1     18.8
##                                                   (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0    0.0709     0.244
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1    0.0912     0.244
## 
##  Chisq= 0.2  on 1 degrees of freedom, p= 0.6
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.6209923
# Figure time to first non-BZD AED by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,120), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first non-BZD ASM (min)", ylab= "Cum. prob. having received first non-BZD ASM")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first non-BZD AED
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="yes", ]$TYPESTATUS +  
                pSERG[pSERG$HOSPITALONSET=="yes", ]$day + pSERG[pSERG$HOSPITALONSET=="yes", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="yes", ]$white +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="yes", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$status + pSERG[pSERG$HOSPITALONSET=="yes", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="yes", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$AEDTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "yes", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$status + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$ageyears + pSERG[pSERG$HOSPITALONSET == "yes", ]$SEX)
## 
##   n= 84, number of events= 84 
## 
##                                                                  coef
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.20097
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.23346
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.51702
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.21865
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.08460
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.50860
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.31219
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.20665
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.03994
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                -0.13215
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017            1.22259
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent   0.79179
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                      1.67702
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear        1.24440
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                    0.91888
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology       1.66296
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy            1.36642
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                   1.22955
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                 0.96085
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                  0.87621
##                                                              se(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.29256
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.29715
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.27515
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.24998
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.25610
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.26648
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.29450
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.34116
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.02282
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.26308
##                                                                   z
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.687
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.786
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     1.879
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.875
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                  -0.330
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      1.909
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           1.060
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.606
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -1.750
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                -0.502
##                                                              Pr(>|z|)  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017            0.4921  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent   0.4321  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                      0.0602 .
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear        0.3818  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                    0.7411  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology       0.0563 .
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy            0.2891  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                   0.5447  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                 0.0800 .
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                  0.6154  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             1.2226
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.7918
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       1.6770
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         1.2444
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.9189
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        1.6630
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             1.3664
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    1.2295
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9608
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.8762
##                                                              exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017              0.8179
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.2630
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        0.5963
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          0.8036
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.0883
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         0.6013
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              0.7318
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     0.8133
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.0407
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    1.1413
##                                                              lower .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             0.6891
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.4423
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.9780
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.7624
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.5562
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.9864
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.7672
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.6300
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9188
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.5232
##                                                              upper .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017              2.169
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.418
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        2.876
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          2.031
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      1.518
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         2.804
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              2.434
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     2.400
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.005
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    1.467
## 
## Concordance= 0.609  (se = 0.038 )
## Rsquare= 0.164   (max possible= 0.999 )
## Likelihood ratio test= 15.07  on 10 df,   p=0.1
## Wald test            = 15.01  on 10 df,   p=0.1
## Score (logrank) test = 15.32  on 10 df,   p=0.1
# Time to first CI
summary(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   122.0   210.0   569.9   495.0  7200.0      49
sd(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0)
## [1] NA
survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ 1)
## Call: survfit(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$CONTTIME.0) ~ 
##     1)
## 
##    49 observations deleted due to missingness 
##       n  events  median 0.95LCL 0.95UCL 
##      35      35     210     165     420
# Figure time to first CI
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ 1), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("purple4"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")

# Time to first CI depending on awareness
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.0   122.0   210.0   609.9   510.0  7200.0      37
summary(pSERG[which(pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1), ]$CONTTIME.0)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##   120.0   146.0   204.5   376.5   372.5  1175.0      12
survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)
## Call:
## survdiff(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness, rho = 1)
## 
## n=35, 49 observations deleted due to missingness.
## 
##                                                    N Observed Expected
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0 23    12.43    11.46
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1 12     5.74     6.71
##                                                   (O-E)^2/E (O-E)^2/V
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=0    0.0824     0.337
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness=1    0.1405     0.337
## 
##  Chisq= 0.3  on 1 degrees of freedom, p= 0.6
pchisq(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$chisq, length(survdiff(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness, rho=1)$n)-1, lower.tail = FALSE)
## [1] 0.5615184
# Figure time to first CI by awareness
plot(survfit(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017), fun = "event", 
     conf.int = FALSE, xlim = c(0,500), col = c("violetred3", "seagreen3"), lwd = 3, 
     cex.axis = 1.3, cex.lab = 1.5,
     frame.plot=FALSE,
     xlab= "Time to first CI (min)", ylab= "Cum. prob. having received first CI")
legend("topleft", legend=c("2011-2016", "2017-2019"),
  col=c("violetred3", "seagreen3"),
  lty=1,
  lwd=3,
  horiz=FALSE,
  bty='n',
  cex=1.3)

########################## COX REGRESSION WITH ALL FACTORS OF INTEREST################################
## Time to first CI
summary(coxph(Surv(pSERG[pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0) ~ pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET=="yes", ]$TYPESTATUS + 
                pSERG[pSERG$HOSPITALONSET=="yes", ]$day + pSERG[pSERG$HOSPITALONSET=="yes", ]$earlyacademicyear + pSERG[pSERG$HOSPITALONSET=="yes", ]$white +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET=="yes", ]$priorepilepsy +
                pSERG[pSERG$HOSPITALONSET=="yes", ]$status + pSERG[pSERG$HOSPITALONSET=="yes", ]$ageyears + pSERG[pSERG$HOSPITALONSET=="yes", ]$SEX))
## Call:
## coxph(formula = Surv(pSERG[pSERG$HOSPITALONSET == "yes", ]$CONTTIME.0) ~ 
##     pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017 + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$TYPESTATUS + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$day + pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear + 
##         pSERG[pSERG$HOSPITALONSET == "yes", ]$white + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$structuraletiology + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$priorepilepsy + pSERG[pSERG$HOSPITALONSET == 
##         "yes", ]$status + pSERG[pSERG$HOSPITALONSET == "yes", 
##         ]$ageyears + pSERG[pSERG$HOSPITALONSET == "yes", ]$SEX)
## 
##   n= 35, number of events= 35 
##    (49 observations deleted due to missingness)
## 
##                                                                  coef
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.39419
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.47707
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.25278
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.48003
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.16398
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology     -0.62622
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.88920
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                 -0.17897
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -0.05362
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.91754
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017            1.48318
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent   0.62060
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                      1.28760
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear        1.61613
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                    1.17819
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology       0.53461
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy            2.43318
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                   0.83613
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                 0.94779
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                  2.50313
##                                                              se(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.57675
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent  0.53133
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.48161
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       0.42508
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.44513
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology      0.49824
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           0.61925
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                  0.81158
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                0.04333
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 0.47211
##                                                                   z
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017           0.683
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent -0.898
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                     0.525
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear       1.129
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                   0.368
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology     -1.257
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy           1.436
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                 -0.221
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears               -1.238
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                 1.943
##                                                              Pr(>|z|)  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             0.494  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.369  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.600  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.259  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.713  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.209  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.151  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.825  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.216  
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.052 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                                              exp(coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             1.4832
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.6206
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       1.2876
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         1.6161
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     1.1782
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.5346
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             2.4332
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.8361
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.9478
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   2.5031
##                                                              exp(-coef)
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017              0.6742
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.6113
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        0.7766
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          0.6188
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      0.8488
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.8705
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              0.4110
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     1.1960
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.0551
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    0.3995
##                                                              lower .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017             0.4789
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent    0.2190
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                       0.5010
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear         0.7025
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                     0.4924
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology        0.2013
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy             0.7229
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                    0.1704
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                  0.8706
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                   0.9923
##                                                              upper .95
## pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017              4.593
## pSERG[pSERG$HOSPITALONSET == "yes", ]$TYPESTATUSintermittent     1.758
## pSERG[pSERG$HOSPITALONSET == "yes", ]$day                        3.309
## pSERG[pSERG$HOSPITALONSET == "yes", ]$earlyacademicyear          3.718
## pSERG[pSERG$HOSPITALONSET == "yes", ]$white                      2.819
## pSERG[pSERG$HOSPITALONSET == "yes", ]$structuraletiology         1.420
## pSERG[pSERG$HOSPITALONSET == "yes", ]$priorepilepsy              8.190
## pSERG[pSERG$HOSPITALONSET == "yes", ]$status                     4.103
## pSERG[pSERG$HOSPITALONSET == "yes", ]$ageyears                   1.032
## pSERG[pSERG$HOSPITALONSET == "yes", ]$SEXmale                    6.315
## 
## Concordance= 0.642  (se = 0.06 )
## Rsquare= 0.291   (max possible= 0.995 )
## Likelihood ratio test= 12.05  on 10 df,   p=0.3
## Wald test            = 10.55  on 10 df,   p=0.4
## Score (logrank) test = 11.61  on 10 df,   p=0.3
#### Recommendations and outliers in the hospital

# First BZD later than 20 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        57 |        27 | 
##           |     0.679 |     0.321 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  66 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        44 |        22 | 
##           |     0.667 |     0.333 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstBZDmore20min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  18 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        13 |         5 | 
##           |     0.722 |     0.278 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore20min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstBZDmore20min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 0.7798
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1905202 2.6912865
## sample estimates:
## odds ratio 
##  0.7715721
# Difference adjusting for covariates within the first 20 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=20,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 20  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.647    -2.858     4.152 0.718
## RMST (arm=1)/(arm=0) 1.071     0.787     1.456 0.663
## RMTL (arm=1)/(arm=0) 0.941     0.620     1.427 0.773
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept           9.914    2.314  4.284 0.000     5.379    14.449
## arm                 0.647    1.788  0.362 0.718    -2.858     4.152
## TYPESTATUSnumeric  -0.099    1.775 -0.056 0.955    -3.579     3.381
## day                -2.119    1.621 -1.307 0.191    -5.297     1.058
## earlyacademicyear  -2.270    1.664 -1.364 0.172    -5.532     0.991
## white               0.988    1.675  0.590 0.555    -2.294     4.271
## structuraletiology -0.211    1.735 -0.121 0.903    -3.611     3.189
## priorepilepsy       1.761    1.862  0.946 0.344    -1.889     5.412
## status              0.427    1.992  0.214 0.830    -3.478     4.332
## ageyears            0.250    0.159  1.572 0.116    -0.062     0.563
## SEXnumeric          0.825    1.765  0.467 0.640    -2.636     4.285
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.286    0.215 10.644 0.000     9.834     6.455
## arm                 0.068    0.157  0.435 0.663     1.071     0.787
## TYPESTATUSnumeric  -0.021    0.167 -0.128 0.898     0.979     0.705
## day                -0.178    0.146 -1.220 0.222     0.837     0.629
## earlyacademicyear  -0.205    0.155 -1.323 0.186     0.815     0.602
## white               0.082    0.160  0.515 0.607     1.086     0.794
## structuraletiology -0.012    0.160 -0.073 0.941     0.988     0.722
## priorepilepsy       0.149    0.166  0.898 0.369     1.160     0.839
## status              0.055    0.164  0.335 0.737     1.056     0.766
## ageyears            0.021    0.014  1.559 0.119     1.022     0.995
## SEXnumeric          0.057    0.162  0.352 0.725     1.059     0.770
##                    upper .95
## intercept             14.981
## arm                    1.456
## TYPESTATUSnumeric      1.359
## day                    1.114
## earlyacademicyear      1.104
## white                  1.485
## structuraletiology     1.354
## priorepilepsy          1.605
## status                 1.456
## ageyears               1.050
## SEXnumeric             1.455
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.298    0.264  8.719 0.000     9.957     5.940
## arm                -0.061    0.213 -0.288 0.773     0.941     0.620
## TYPESTATUSnumeric  -0.007    0.199 -0.033 0.974     0.994     0.673
## day                 0.266    0.191  1.394 0.163     1.305     0.898
## earlyacademicyear   0.263    0.191  1.375 0.169     1.301     0.894
## white              -0.128    0.184 -0.695 0.487     0.880     0.613
## structuraletiology  0.035    0.193  0.180 0.857     1.035     0.709
## priorepilepsy      -0.221    0.232 -0.955 0.340     0.802     0.509
## status             -0.021    0.269 -0.080 0.936     0.979     0.577
## ageyears           -0.031    0.020 -1.514 0.130     0.970     0.932
## SEXnumeric         -0.125    0.201 -0.622 0.534     0.882     0.595
##                    upper .95
## intercept             16.692
## arm                    1.427
## TYPESTATUSnumeric      1.467
## day                    1.896
## earlyacademicyear      1.891
## white                  1.263
## structuraletiology     1.512
## priorepilepsy          1.262
## status                 1.659
## ageyears               1.009
## SEXnumeric             1.309
# First BZD later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        69 |        15 | 
##           |     0.821 |     0.179 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  66 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        52 |        14 | 
##           |     0.788 |     0.212 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstBZDmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  18 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        17 |         1 | 
##           |     0.944 |     0.056 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore40min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstBZDmore40min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 0.1736
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.004888634 1.672955447
## sample estimates:
## odds ratio 
##  0.2213607
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -2.210    -8.115     3.695 0.463
## RMST (arm=1)/(arm=0)  0.896     0.596     1.346 0.596
## RMTL (arm=1)/(arm=0)  1.108     0.872     1.406 0.402
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          15.264    4.723  3.232 0.001     6.006    24.521
## arm                -2.210    3.013 -0.733 0.463    -8.115     3.695
## TYPESTATUSnumeric  -3.018    2.923 -1.033 0.302    -8.747     2.711
## day                -2.966    3.076 -0.964 0.335    -8.995     3.062
## earlyacademicyear  -4.431    3.050 -1.453 0.146   -10.409     1.547
## white               1.767    3.225  0.548 0.584    -4.554     8.088
## structuraletiology  0.437    3.272  0.134 0.894    -5.975     6.849
## priorepilepsy       2.118    3.656  0.579 0.562    -5.048     9.283
## status             -0.923    3.879 -0.238 0.812    -8.526     6.680
## ageyears            0.631    0.294  2.149 0.032     0.055     1.207
## SEXnumeric         -1.560    3.091 -0.505 0.614    -7.618     4.498
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.683    0.320  8.397 0.000    14.626     7.819
## arm                -0.110    0.208 -0.531 0.596     0.896     0.596
## TYPESTATUSnumeric  -0.222    0.216 -1.026 0.305     0.801     0.525
## day                -0.174    0.192 -0.908 0.364     0.840     0.577
## earlyacademicyear  -0.282    0.199 -1.418 0.156     0.754     0.511
## white               0.102    0.213  0.479 0.632     1.107     0.730
## structuraletiology  0.047    0.210  0.224 0.823     1.048     0.695
## priorepilepsy       0.126    0.221  0.571 0.568     1.135     0.736
## status             -0.020    0.224 -0.088 0.930     0.980     0.632
## ageyears            0.038    0.017  2.231 0.026     1.039     1.005
## SEXnumeric         -0.121    0.198 -0.608 0.543     0.886     0.601
##                    upper .95
## intercept             27.357
## arm                    1.346
## TYPESTATUSnumeric      1.223
## day                    1.223
## earlyacademicyear      1.114
## white                  1.680
## structuraletiology     1.580
## priorepilepsy          1.750
## status                 1.522
## ageyears               1.075
## SEXnumeric             1.308
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.192    0.196 16.305 0.000    24.344    16.586
## arm                 0.102    0.122  0.838 0.402     1.108     0.872
## TYPESTATUSnumeric   0.117    0.116  1.011 0.312     1.124     0.896
## day                 0.130    0.132  0.981 0.327     1.138     0.879
## earlyacademicyear   0.185    0.129  1.433 0.152     1.204     0.934
## white              -0.080    0.136 -0.592 0.554     0.923     0.707
## structuraletiology -0.011    0.136 -0.078 0.938     0.989     0.758
## priorepilepsy      -0.092    0.162 -0.563 0.573     0.913     0.664
## status              0.053    0.177  0.301 0.763     1.055     0.745
## ageyears           -0.027    0.014 -1.978 0.048     0.973     0.947
## SEXnumeric          0.054    0.129  0.419 0.675     1.055     0.820
##                    upper .95
## intercept             35.732
## arm                    1.406
## TYPESTATUSnumeric      1.411
## day                    1.475
## earlyacademicyear      1.551
## white                  1.204
## structuraletiology     1.292
## priorepilepsy          1.255
## status                 1.493
## ageyears               1.000
## SEXnumeric             1.358
# First BZD later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        73 |        11 | 
##           |     0.869 |     0.131 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  66 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        56 |        10 | 
##           |     0.848 |     0.152 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstBZDmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  18 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        17 |         1 | 
##           |     0.944 |     0.056 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstBZDmore60min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstBZDmore60min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 0.4428
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.007178925 2.657237489
## sample estimates:
## odds ratio 
##  0.3327754
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$BZDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -4.671   -12.560     3.218 0.246
## RMST (arm=1)/(arm=0)  0.794     0.486     1.295 0.355
## RMTL (arm=1)/(arm=0)  1.124     0.933     1.354 0.219
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          22.536    6.843  3.294 0.001     9.125    35.948
## arm                -4.671    4.025 -1.160 0.246   -12.560     3.218
## TYPESTATUSnumeric  -4.372    3.820 -1.144 0.252   -11.859     3.115
## day                -3.494    4.267 -0.819 0.413   -11.857     4.870
## earlyacademicyear  -8.395    4.212 -1.993 0.046   -16.650    -0.140
## white               0.495    4.633  0.107 0.915    -8.585     9.576
## structuraletiology  0.416    4.406  0.094 0.925    -8.220     9.053
## priorepilepsy       0.580    5.006  0.116 0.908    -9.231    10.391
## status             -1.663    4.985 -0.334 0.739   -11.432     8.107
## ageyears            0.887    0.417  2.129 0.033     0.070     1.704
## SEXnumeric         -4.452    4.358 -1.022 0.307   -12.994     4.090
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.081    0.373  8.250 0.000    21.785    10.478
## arm                -0.231    0.250 -0.925 0.355     0.794     0.486
## TYPESTATUSnumeric  -0.269    0.254 -1.061 0.289     0.764     0.465
## day                -0.188    0.219 -0.857 0.391     0.829     0.540
## earlyacademicyear  -0.452    0.224 -2.017 0.044     0.636     0.410
## white               0.005    0.247  0.021 0.983     1.005     0.619
## structuraletiology  0.049    0.239  0.204 0.839     1.050     0.657
## priorepilepsy       0.025    0.252  0.101 0.920     1.026     0.626
## status             -0.052    0.252 -0.208 0.836     0.949     0.580
## ageyears            0.045    0.020  2.290 0.022     1.046     1.007
## SEXnumeric         -0.254    0.230 -1.106 0.269     0.775     0.494
##                    upper .95
## intercept             45.294
## arm                    1.295
## TYPESTATUSnumeric      1.256
## day                    1.273
## earlyacademicyear      0.987
## white                  1.632
## structuraletiology     1.678
## priorepilepsy          1.680
## status                 1.554
## ageyears               1.087
## SEXnumeric             1.217
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.616    0.172 21.065 0.000    37.187    26.563
## arm                 0.117    0.095  1.228 0.219     1.124     0.933
## TYPESTATUSnumeric   0.103    0.089  1.156 0.248     1.108     0.931
## day                 0.085    0.108  0.788 0.431     1.089     0.881
## earlyacademicyear   0.206    0.109  1.897 0.058     1.229     0.993
## white              -0.017    0.116 -0.143 0.886     0.984     0.784
## structuraletiology -0.005    0.107 -0.048 0.962     0.995     0.807
## priorepilepsy      -0.014    0.127 -0.113 0.910     0.986     0.768
## status              0.046    0.128  0.361 0.718     1.047     0.815
## ageyears           -0.022    0.011 -1.970 0.049     0.978     0.957
## SEXnumeric          0.104    0.108  0.962 0.336     1.110     0.898
##                    upper .95
## intercept             52.061
## arm                    1.354
## TYPESTATUSnumeric      1.319
## day                    1.345
## earlyacademicyear      1.520
## white                  1.234
## structuraletiology     1.227
## priorepilepsy          1.265
## status                 1.346
## ageyears               1.000
## SEXnumeric             1.371
# First non-BZD ASM later than 40 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        43 |        41 | 
##           |     0.512 |     0.488 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  66 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        32 |        34 | 
##           |     0.485 |     0.515 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstASMmore40min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  18 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        11 |         7 | 
##           |     0.611 |     0.389 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore40min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstASMmore40min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 0.4287
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1748355 1.9500290
## sample estimates:
## odds ratio 
##  0.6025918
# Difference adjusting for covariates within the first 40 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=40,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 40  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -0.152    -4.755     4.451 0.948
## RMST (arm=1)/(arm=0)  0.997     0.858     1.160 0.973
## RMTL (arm=1)/(arm=0)  1.043     0.626     1.737 0.872
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          28.692    3.749  7.653 0.000    21.344    36.040
## arm                -0.152    2.348 -0.065 0.948    -4.755     4.451
## TYPESTATUSnumeric   1.943    3.033  0.641 0.522    -4.001     7.887
## day                -4.723    2.558 -1.846 0.065    -9.737     0.292
## earlyacademicyear  -0.288    2.728 -0.106 0.916    -5.634     5.058
## white               4.010    2.545  1.576 0.115    -0.978     8.997
## structuraletiology -1.498    2.610 -0.574 0.566    -6.613     3.617
## priorepilepsy      -0.025    2.784 -0.009 0.993    -5.482     5.431
## status             -1.818    3.402 -0.534 0.593    -8.487     4.851
## ageyears            0.437    0.245  1.780 0.075    -0.044     0.918
## SEXnumeric         -0.585    2.933 -0.199 0.842    -6.333     5.164
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.353    0.126 26.653 0.000    28.597    22.348
## arm                -0.003    0.077 -0.033 0.973     0.997     0.858
## TYPESTATUSnumeric   0.066    0.100  0.656 0.512     1.068     0.877
## day                -0.155    0.086 -1.806 0.071     0.856     0.724
## earlyacademicyear  -0.007    0.091 -0.081 0.936     0.993     0.830
## white               0.134    0.088  1.523 0.128     1.143     0.962
## structuraletiology -0.050    0.089 -0.566 0.572     0.951     0.798
## priorepilepsy      -0.004    0.088 -0.041 0.968     0.996     0.839
## status             -0.059    0.113 -0.523 0.601     0.943     0.756
## ageyears            0.014    0.008  1.757 0.079     1.014     0.998
## SEXnumeric         -0.023    0.099 -0.232 0.817     0.977     0.805
##                    upper .95
## intercept             36.595
## arm                    1.160
## TYPESTATUSnumeric      1.300
## day                    1.013
## earlyacademicyear      1.187
## white                  1.358
## structuraletiology     1.132
## priorepilepsy          1.184
## status                 1.176
## ageyears               1.030
## SEXnumeric             1.186
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           2.403    0.396  6.073 0.000    11.053     5.090
## arm                 0.042    0.260  0.161 0.872     1.043     0.626
## TYPESTATUSnumeric  -0.187    0.324 -0.576 0.565     0.830     0.440
## day                 0.512    0.280  1.830 0.067     1.669     0.964
## earlyacademicyear   0.050    0.275  0.181 0.856     1.051     0.613
## white              -0.419    0.262 -1.601 0.109     0.657     0.393
## structuraletiology  0.148    0.251  0.590 0.555     1.159     0.709
## priorepilepsy      -0.018    0.358 -0.049 0.961     0.982     0.487
## status              0.201    0.379  0.531 0.595     1.223     0.582
## ageyears           -0.052    0.032 -1.633 0.102     0.949     0.891
## SEXnumeric          0.016    0.296  0.053 0.958     1.016     0.568
##                    upper .95
## intercept             24.003
## arm                    1.737
## TYPESTATUSnumeric      1.566
## day                    2.888
## earlyacademicyear      1.803
## white                  1.099
## structuraletiology     1.895
## priorepilepsy          1.980
## status                 2.572
## ageyears               1.011
## SEXnumeric             1.815
# First non-BZD ASM later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        56 |        28 | 
##           |     0.667 |     0.333 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  66 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        43 |        23 | 
##           |     0.652 |     0.348 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstASMmore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  18 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        13 |         5 | 
##           |     0.722 |     0.278 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore60min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstASMmore60min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 0.7788
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1786629 2.5087283
## sample estimates:
## odds ratio 
##  0.7218025
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=60,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -3.333   -11.602     4.935 0.429
## RMST (arm=1)/(arm=0)  0.917     0.736     1.141 0.436
## RMTL (arm=1)/(arm=0)  1.169     0.795     1.719 0.429
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          38.112    6.375  5.978 0.000    25.617    50.607
## arm                -3.333    4.219 -0.790 0.429   -11.602     4.935
## TYPESTATUSnumeric  -0.593    5.091 -0.116 0.907   -10.570     9.385
## day                -8.585    4.327 -1.984 0.047   -17.066    -0.104
## earlyacademicyear   1.169    4.495  0.260 0.795    -7.641     9.979
## white               6.444    4.407  1.462 0.144    -2.194    15.082
## structuraletiology -5.796    4.203 -1.379 0.168   -14.033     2.442
## priorepilepsy      -1.489    4.807 -0.310 0.757   -10.912     7.933
## status             -3.432    5.487 -0.625 0.532   -14.186     7.323
## ageyears            0.720    0.402  1.789 0.074    -0.069     1.509
## SEXnumeric          1.394    4.718  0.296 0.768    -7.852    10.640
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.636    0.167 21.749 0.000    37.952    27.347
## arm                -0.087    0.112 -0.779 0.436     0.917     0.736
## TYPESTATUSnumeric  -0.014    0.135 -0.103 0.918     0.986     0.756
## day                -0.222    0.114 -1.950 0.051     0.801     0.641
## earlyacademicyear   0.037    0.118  0.311 0.756     1.038     0.822
## white               0.169    0.121  1.399 0.162     1.184     0.934
## structuraletiology -0.160    0.114 -1.401 0.161     0.852     0.681
## priorepilepsy      -0.043    0.120 -0.360 0.719     0.958     0.758
## status             -0.095    0.146 -0.653 0.514     0.909     0.682
## ageyears            0.017    0.010  1.764 0.078     1.018     0.998
## SEXnumeric          0.034    0.122  0.274 0.784     1.034     0.813
##                    upper .95
## intercept             52.668
## arm                    1.141
## TYPESTATUSnumeric      1.286
## day                    1.001
## earlyacademicyear      1.309
## white                  1.502
## structuraletiology     1.066
## priorepilepsy          1.211
## status                 1.211
## ageyears               1.038
## SEXnumeric             1.315
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.077    0.304 10.119 0.000    21.697    11.955
## arm                 0.156    0.197  0.792 0.429     1.169     0.795
## TYPESTATUSnumeric   0.032    0.232  0.139 0.889     1.033     0.655
## day                 0.417    0.216  1.933 0.053     1.518     0.994
## earlyacademicyear  -0.038    0.209 -0.181 0.856     0.963     0.639
## white              -0.306    0.203 -1.509 0.131     0.736     0.495
## structuraletiology  0.248    0.192  1.292 0.196     1.282     0.880
## priorepilepsy       0.066    0.256  0.257 0.797     1.068     0.647
## status              0.139    0.261  0.531 0.596     1.149     0.688
## ageyears           -0.039    0.023 -1.695 0.090     0.961     0.919
## SEXnumeric         -0.082    0.226 -0.363 0.717     0.921     0.592
##                    upper .95
## intercept             39.378
## arm                    1.719
## TYPESTATUSnumeric      1.629
## day                    2.317
## earlyacademicyear      1.451
## white                  1.096
## structuraletiology     1.868
## priorepilepsy          1.762
## status                 1.917
## ageyears               1.006
## SEXnumeric             1.434
# First non-BZD ASM later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  84 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        72 |        12 | 
##           |     0.857 |     0.143 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  66 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        57 |         9 | 
##           |     0.864 |     0.136 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstASMmore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  18 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        15 |         3 | 
##           |     0.833 |     0.167 | 
##           |-----------|-----------|
## 
## 
## 
## 
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstASMmore120min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstASMmore120min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 0.7143
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1959377 5.9466903
## sample estimates:
## odds ratio 
##   1.262937
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[pSERG$HOSPITALONSET=="yes", ]$AEDTIME.0, status=pSERG[pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=120,
      covariates= pSERG[pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                        Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) -5.185   -22.741    12.371 0.563
## RMST (arm=1)/(arm=0)  0.897     0.635     1.267 0.537
## RMTL (arm=1)/(arm=0)  1.074     0.828     1.393 0.592
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept           57.049   13.547  4.211 0.000    30.497    83.600
## arm                 -5.185    8.957 -0.579 0.563   -22.741    12.371
## TYPESTATUSnumeric  -11.448    8.409 -1.361 0.173   -27.929     5.033
## day                -15.583    8.285 -1.881 0.060   -31.821     0.654
## earlyacademicyear   -2.209    8.506 -0.260 0.795   -18.881    14.463
## white                6.401    8.641  0.741 0.459   -10.535    23.337
## structuraletiology -12.940    7.630 -1.696 0.090   -27.896     2.015
## priorepilepsy       -4.295    9.722 -0.442 0.659   -23.348    14.759
## status              -3.488   10.936 -0.319 0.750   -24.922    17.947
## ageyears             1.550    0.776  1.997 0.046     0.028     3.072
## SEXnumeric           4.885    8.321  0.587 0.557   -11.424    21.194
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.041    0.259 15.626 0.000    56.902    34.276
## arm                -0.109    0.176 -0.617 0.537     0.897     0.635
## TYPESTATUSnumeric  -0.241    0.182 -1.320 0.187     0.786     0.550
## day                -0.289    0.158 -1.830 0.067     0.749     0.549
## earlyacademicyear  -0.033    0.169 -0.192 0.847     0.968     0.695
## white               0.122    0.175  0.693 0.488     1.129     0.801
## structuraletiology -0.271    0.159 -1.699 0.089     0.763     0.558
## priorepilepsy      -0.095    0.184 -0.516 0.606     0.909     0.634
## status             -0.071    0.219 -0.323 0.747     0.932     0.607
## ageyears            0.027    0.013  2.023 0.043     1.027     1.001
## SEXnumeric          0.089    0.155  0.574 0.566     1.093     0.806
##                    upper .95
## intercept             94.466
## arm                    1.267
## TYPESTATUSnumeric      1.124
## day                    1.021
## earlyacademicyear      1.348
## white                  1.593
## structuraletiology     1.042
## priorepilepsy          1.304
## status                 1.430
## ageyears               1.055
## SEXnumeric             1.483
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.141    0.205 20.206 0.000    62.861    42.067
## arm                 0.071    0.133  0.536 0.592     1.074     0.828
## TYPESTATUSnumeric   0.160    0.118  1.362 0.173     1.174     0.932
## day                 0.240    0.130  1.848 0.065     1.271     0.986
## earlyacademicyear   0.037    0.126  0.298 0.766     1.038     0.812
## white              -0.098    0.127 -0.771 0.441     0.907     0.707
## structuraletiology  0.182    0.111  1.642 0.101     1.200     0.965
## priorepilepsy       0.060    0.151  0.400 0.689     1.062     0.791
## status              0.048    0.163  0.291 0.771     1.049     0.762
## ageyears           -0.025    0.013 -1.883 0.060     0.975     0.950
## SEXnumeric         -0.078    0.127 -0.611 0.541     0.925     0.721
##                    upper .95
## intercept             93.933
## arm                    1.393
## TYPESTATUSnumeric      1.478
## day                    1.639
## earlyacademicyear      1.328
## white                  1.163
## structuraletiology     1.491
## priorepilepsy          1.426
## status                 1.444
## ageyears               1.001
## SEXnumeric             1.188
# First CI later than 60 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  35 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         3 |        32 | 
##           |     0.086 |     0.914 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstCImore60min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  29 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         3 |        26 | 
##           |     0.103 |     0.897 | 
##           |-----------|-----------|
## 
## 
## 
## 
table(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstCImore60min)
## 
## 0 1 
## 0 6
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore60min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstCImore60min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.07862118        Inf
## sample estimates:
## odds ratio 
##        Inf
# Difference adjusting for covariates within the first 60 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=60,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## Warning in sqrt(diag(varbeta)): NaNs produced
## 
## The truncation time: tau = 60  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 3.237    -2.847     9.321 0.297
## RMST (arm=1)/(arm=0) 1.055     0.949     1.172 0.323
## RMTL (arm=1)/(arm=0) 0.000       NaN       NaN   NaN
## 
## 
## Model summary (difference of RMST) 
##                      coef se(coef)      z     p lower .95 upper .95
## intercept          57.833    3.896 14.843 0.000    50.196    65.470
## arm                 3.237    3.104  1.043 0.297    -2.847     9.321
## TYPESTATUSnumeric   5.332    5.913  0.902 0.367    -6.256    16.921
## day                -4.901    3.869 -1.267 0.205   -12.485     2.683
## earlyacademicyear  -1.560    3.193 -0.489 0.625    -7.819     4.698
## white              -3.362    3.946 -0.852 0.394   -11.097     4.372
## structuraletiology  3.051    4.719  0.647 0.518    -6.198    12.300
## priorepilepsy       2.926    3.501  0.836 0.403    -3.935     9.787
## status              3.447    4.782  0.721 0.471    -5.925    12.819
## ageyears            0.367    0.399  0.920 0.358    -0.414     1.148
## SEXnumeric         -5.557    4.155 -1.338 0.181   -13.700     2.586
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.052    0.075 54.184 0.000    57.511    49.670
## arm                 0.053    0.054  0.988 0.323     1.055     0.949
## TYPESTATUSnumeric   0.097    0.114  0.848 0.397     1.102     0.881
## day                -0.091    0.077 -1.170 0.242     0.913     0.785
## earlyacademicyear  -0.026    0.058 -0.453 0.650     0.974     0.870
## white              -0.056    0.070 -0.797 0.425     0.946     0.824
## structuraletiology  0.054    0.085  0.639 0.523     1.056     0.893
## priorepilepsy       0.047    0.063  0.737 0.461     1.048     0.926
## status              0.065    0.093  0.699 0.484     1.067     0.890
## ageyears            0.007    0.008  0.881 0.378     1.007     0.992
## SEXnumeric         -0.098    0.076 -1.278 0.201     0.907     0.781
##                    upper .95
## intercept             66.589
## arm                    1.172
## TYPESTATUSnumeric      1.379
## day                    1.063
## earlyacademicyear      1.091
## white                  1.085
## structuraletiology     1.248
## priorepilepsy          1.186
## status                 1.280
## ageyears               1.022
## SEXnumeric             1.054
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)       z    p    exp(coef)
## intercept          -189.306      NaN     NaN  NaN 0.000000e+00
## arm                 -28.451      NaN     NaN  NaN 0.000000e+00
## TYPESTATUSnumeric   -41.708      NaN     NaN  NaN 0.000000e+00
## day                  81.136      NaN     NaN  NaN 1.725126e+35
## earlyacademicyear    64.796      NaN     NaN  NaN 1.382580e+28
## white                85.305      NaN     NaN  NaN 1.115588e+37
## structuraletiology   18.306    0.938  19.515 0.00 8.919254e+07
## priorepilepsy       -64.355    0.704 -91.424 0.00 0.000000e+00
## status              -27.650      NaN     NaN  NaN 0.000000e+00
## ageyears              0.242    0.152   1.597 0.11 1.274000e+00
## SEXnumeric           26.327      NaN     NaN  NaN 2.714457e+11
##                       lower .95    upper .95
## intercept                   NaN          NaN
## arm                         NaN          NaN
## TYPESTATUSnumeric           NaN          NaN
## day                         NaN          NaN
## earlyacademicyear           NaN          NaN
## white                       NaN          NaN
## structuraletiology 14185531.039 5.608044e+08
## priorepilepsy             0.000 0.000000e+00
## status                      NaN          NaN
## ageyears                  0.946 1.716000e+00
## SEXnumeric                  NaN          NaN
# First CI later than 120 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  35 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         8 |        27 | 
##           |     0.229 |     0.771 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstCImore120min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  29 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |         7 |        22 | 
##           |     0.241 |     0.759 | 
##           |-----------|-----------|
## 
## 
## 
## 
table(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstCImore120min)
## 
## 0 1 
## 1 5
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore120min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstCImore120min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.1369372 85.8104846
## sample estimates:
## odds ratio 
##   1.571737
# Difference adjusting for covariates within the first 120 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=120,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## Warning in sqrt(diag(varbeta)): NaNs produced
## 
## The truncation time: tau = 120  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95   upper .95     p
## RMST (arm=1)-(arm=0) 8.283    -6.148      22.713 0.261
## RMST (arm=1)/(arm=0) 1.072     0.943       1.218 0.288
## RMTL (arm=1)/(arm=0) 0.000     0.000 7068292.932 0.220
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          117.436    8.836 13.291 0.000   100.118   134.755
## arm                  8.283    7.363  1.125 0.261    -6.148    22.713
## TYPESTATUSnumeric    9.063   14.273  0.635 0.525   -18.911    37.038
## day                -11.561    9.252 -1.250 0.211   -29.695     6.572
## earlyacademicyear   -6.026    8.294 -0.727 0.468   -22.281    10.230
## white               -6.927    9.358 -0.740 0.459   -25.268    11.414
## structuraletiology   4.212   11.192  0.376 0.707   -17.724    26.148
## priorepilepsy        8.735    8.740  0.999 0.318    -8.396    25.866
## status               6.581   11.265  0.584 0.559   -15.499    28.661
## ageyears             0.636    0.868  0.733 0.464    -1.065     2.337
## SEXnumeric         -12.726    9.257 -1.375 0.169   -30.869     5.416
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           4.759    0.085 56.299 0.000   116.599    98.797
## arm                 0.069    0.065  1.062 0.288     1.072     0.943
## TYPESTATUSnumeric   0.083    0.140  0.590 0.555     1.086     0.826
## day                -0.108    0.094 -1.148 0.251     0.898     0.747
## earlyacademicyear  -0.052    0.076 -0.685 0.493     0.949     0.817
## white              -0.057    0.086 -0.660 0.509     0.945     0.798
## structuraletiology  0.039    0.103  0.378 0.705     1.040     0.850
## priorepilepsy       0.071    0.082  0.870 0.384     1.074     0.914
## status              0.064    0.113  0.564 0.573     1.066     0.854
## ageyears            0.006    0.009  0.720 0.471     1.006     0.989
## SEXnumeric         -0.114    0.088 -1.298 0.194     0.892     0.750
##                    upper .95
## intercept            137.607
## arm                    1.218
## TYPESTATUSnumeric      1.429
## day                    1.079
## earlyacademicyear      1.102
## white                  1.118
## structuraletiology     1.271
## priorepilepsy          1.262
## status                 1.330
## ageyears               1.023
## SEXnumeric             1.060
## 
## 
## Model summary (ratio of time-lost) 
##                        coef se(coef)        z     p    exp(coef)
## intercept          -144.348   36.616   -3.942 0.000 0.000000e+00
## arm                 -26.350   21.491   -1.226 0.220 0.000000e+00
## TYPESTATUSnumeric   -22.649    0.197 -114.936 0.000 0.000000e+00
## day                  62.122    2.871   21.638 0.000 9.535760e+26
## earlyacademicyear    43.361    0.461   94.022 0.000 6.786335e+18
## white                63.198      NaN      NaN   NaN 2.796426e+27
## structuraletiology   18.255    0.989   18.463 0.000 8.472256e+07
## priorepilepsy       -45.442    1.215  -37.391 0.000 0.000000e+00
## status              -22.914    3.417   -6.705 0.000 0.000000e+00
## ageyears              0.203    0.141    1.438 0.151 1.225000e+00
## SEXnumeric           23.316    1.556   14.981 0.000 1.336374e+10
##                       lower .95    upper .95
## intercept          0.000000e+00 0.000000e+00
## arm                0.000000e+00 7.068293e+06
## TYPESTATUSnumeric  0.000000e+00 0.000000e+00
## day                3.432012e+24 2.649487e+29
## earlyacademicyear  2.748373e+18 1.675695e+19
## white                       NaN          NaN
## structuraletiology 1.220139e+07 5.882863e+08
## priorepilepsy      0.000000e+00 0.000000e+00
## status             0.000000e+00 0.000000e+00
## ageyears           9.290000e-01 1.616000e+00
## SEXnumeric         6.326410e+08 2.822922e+11
# First CI later than 240 minutes
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  35 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        20 |        15 | 
##           |     0.571 |     0.429 | 
##           |-----------|-----------|
## 
## 
## 
## 
CrossTable(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 0, ]$firstCImore240min)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  29 
## 
##  
##           |         0 |         1 | 
##           |-----------|-----------|
##           |        16 |        13 | 
##           |     0.552 |     0.448 | 
##           |-----------|-----------|
## 
## 
## 
## 
table(pSERG[pSERG$HOSPITALONSET=="yes" & pSERG$awareness2017 == 1, ]$firstCImore240min)
## 
## 0 1 
## 4 2
fisher.test(pSERG[pSERG$HOSPITALONSET=="yes", ]$firstCImore240min, pSERG[pSERG$HOSPITALONSET=="yes", ]$awareness2017, alternative = "two.sided")
## 
##  Fisher's Exact Test for Count Data
## 
## data:  pSERG[pSERG$HOSPITALONSET == "yes", ]$firstCImore240min and pSERG[pSERG$HOSPITALONSET == "yes", ]$awareness2017
## p-value = 0.6804
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.04905162 5.18455750
## sample estimates:
## odds ratio 
##   0.623748
# Difference adjusting for covariates within the first 240 minutes
rmst2(time=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$CONTTIME.0, status=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$event, arm=pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", ]$awareness2017, tau=240,
      covariates= pSERG[!is.na(pSERG$CONTTIME.0) & pSERG$HOSPITALONSET=="yes", c("TYPESTATUSnumeric", "day",
                             "earlyacademicyear", "white", "structuraletiology",
                             "priorepilepsy", "status", "ageyears", "SEXnumeric")])
## 
## The truncation time: tau = 240  was specified. 
## 
## Summary of between-group contrast (adjusted for the covariates) 
##                       Est. lower .95 upper .95     p
## RMST (arm=1)-(arm=0) 0.165   -52.080    52.411 0.995
## RMST (arm=1)/(arm=0) 1.002     0.754     1.330 0.991
## RMTL (arm=1)/(arm=0) 1.024     0.366     2.860 0.965
## 
## 
## Model summary (difference of RMST) 
##                       coef se(coef)      z     p lower .95 upper .95
## intercept          211.320   31.666  6.673 0.000   149.256   273.384
## arm                  0.165   26.656  0.006 0.995   -52.080    52.411
## TYPESTATUSnumeric   -7.193   32.352 -0.222 0.824   -70.602    56.216
## day                -23.496   24.915 -0.943 0.346   -72.329    25.337
## earlyacademicyear  -19.437   25.020 -0.777 0.437   -68.475    29.601
## white              -20.455   26.475 -0.773 0.440   -72.346    31.436
## structuraletiology  25.614   28.465  0.900 0.368   -30.176    81.404
## priorepilepsy      -14.641   27.349 -0.535 0.592   -68.243    38.962
## status              16.861   36.812  0.458 0.647   -55.288    89.010
## ageyears             2.612    1.825  1.431 0.152    -0.965     6.189
## SEXnumeric         -39.356   24.742 -1.591 0.112   -87.850     9.137
## 
## 
## Model summary (ratio of RMST) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           5.348    0.175 30.473 0.000   210.110   148.960
## arm                 0.002    0.145  0.011 0.991     1.002     0.754
## TYPESTATUSnumeric  -0.035    0.201 -0.173 0.862     0.966     0.651
## day                -0.136    0.142 -0.959 0.338     0.873     0.660
## earlyacademicyear  -0.106    0.141 -0.752 0.452     0.899     0.682
## white              -0.105    0.148 -0.708 0.479     0.900     0.673
## structuraletiology  0.139    0.156  0.890 0.374     1.149     0.846
## priorepilepsy      -0.079    0.160 -0.492 0.623     0.924     0.676
## status              0.092    0.217  0.425 0.671     1.097     0.717
## ageyears            0.014    0.011  1.365 0.172     1.015     0.994
## SEXnumeric         -0.210    0.143 -1.464 0.143     0.811     0.613
##                    upper .95
## intercept            296.363
## arm                    1.330
## TYPESTATUSnumeric      1.433
## day                    1.153
## earlyacademicyear      1.186
## white                  1.204
## structuraletiology     1.559
## priorepilepsy          1.264
## status                 1.678
## ageyears               1.036
## SEXnumeric             1.074
## 
## 
## Model summary (ratio of time-lost) 
##                      coef se(coef)      z     p exp(coef) lower .95
## intercept           3.279    0.625  5.242 0.000    26.548     7.791
## arm                 0.023    0.524  0.045 0.965     1.024     0.366
## TYPESTATUSnumeric   0.206    0.436  0.473 0.637     1.229     0.522
## day                 0.368    0.505  0.729 0.466     1.445     0.537
## earlyacademicyear   0.372    0.436  0.852 0.394     1.450     0.617
## white               0.468    0.502  0.933 0.351     1.597     0.598
## structuraletiology -0.472    0.536 -0.880 0.379     0.624     0.218
## priorepilepsy       0.312    0.424  0.737 0.461     1.366     0.595
## status             -0.317    0.584 -0.543 0.587     0.728     0.232
## ageyears           -0.048    0.034 -1.412 0.158     0.953     0.892
## SEXnumeric          0.819    0.454  1.802 0.072     2.267     0.931
##                    upper .95
## intercept             90.459
## arm                    2.860
## TYPESTATUSnumeric      2.891
## day                    3.888
## earlyacademicyear      3.411
## white                  4.267
## structuraletiology     1.783
## priorepilepsy          3.136
## status                 2.287
## ageyears               1.019
## SEXnumeric             5.523