ekenah / TranStat

An R package for the analysis of infectious disease transmission data
GNU Lesser General Public License v3.0
8 stars 3 forks source link

Error in transreg command #3

Closed yushuf closed 7 years ago

yushuf commented 7 years ago

Command: transreg( Surv(start, stop, infector) ~ infx + susx + ext(external), sus = "susceptible", data = dat, subset = (trace == 1), dist = "exponential", xdist = "exponential" ) Error: Error in $<-.data.frame(*tmp*, "sus", value = c(1751L, 404L, 131L, : replacement has 2993 rows, data has 2988 In addition: Warning message: In Surv(start, stop, infector) : Stop time must be > start time, NA created

Comments: In my data 'dat', python simulation producing some start and stop time which are equal. But the Survfit looks for greater only. The equality is happening in xdat file. sending the data file in your email

dat[which(dat$start>=dat$stop), ] infectious susceptible entry exit infector infset susx infx interval 2811 NA 1074 0.2289881 0.2289881 0 0 0 0 0.2289881 2812 NA 1075 0.2289881 0.2289881 0 0 0 0 0.2289881 2813 NA 1076 0.2289881 0.2289881 0 0 0 0 0.2289881 2814 NA 1078 0.2289881 0.2289881 0 0 1 0 0.2289881 2815 NA 1079 0.2289881 0.2289881 0 0 0 0 0.2289881 external trace start stop 2811 1 1 0.2289881 0.2289881 2812 1 1 0.2289881 0.2289881 2813 1 1 0.2289881 0.2289881 2814 1 1 0.2289881 0.2289881 2815 1 1 0.2289881 0.2289881

ekenah commented 7 years ago

The error is in the Python simulations. It occurs when the last infection is an external infection who is also the index case in his or her household. The entry and exit times for the other household members will be equal. I have revised the Python code to prevent these rows from being added to the external data.