Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dates #20

Merged
merged 9 commits into from May 11, 2017
Merged

Dates #20

merged 9 commits into from May 11, 2017

Conversation

annecori
Copy link
Collaborator

@annecori annecori commented May 11, 2017

proposed changes to allow a Date column to be specified in I, which is then used for plotting
--> addresses issue #12

also, added errors when the estimation is performed to early or too late
--> addresses issue #15 and #19

finally, also allowed EstimateR and WT to take incidence objects (from class incidence from package incidence) as arguments
--> addresses issue #13

@annecori annecori requested a review from jstockwin May 11, 2017 11:08
@jstockwin
Copy link
Collaborator

@annecori What am I doing wrong:

library(devtools)
install_github('annecori/EpiEstim', ref = "dates", force = TRUE)
library(EpiEstim)


I <- data.frame(c(0,1,2,2,3,3), c(1,0,0,0,0,0), as.Date(c("01-05-2017", "02-05-2017", "03-05-2017", "04-05-2017", "05-05-2017", "06-05-2017")))
colnames(I) <- c("local", "imported", "dates")
> str(I)
'data.frame':	6 obs. of  3 variables:
 $ local   : num  0 1 2 2 3 3
 $ imported: num  1 0 0 0 0 0
 $ dates   : Date, format: "0001-05-20" "0002-05-20" "0003-05-20" "0004-05-20" ...
> EstimateR(I, T.Start=1:5, T.End=2:6, method="ParametricSI")
Error in process_I(I) : I must contain only non negative integer values.

@jstockwin
Copy link
Collaborator

Okay so now it's working a bit better, but I'm still getting errors:

library(devtools)
install_github('annecori/EpiEstim', ref = "dates", force = TRUE)
library(EpiEstim)


I <- data.frame(c(0,1,2,2,3,3,4,3,4,5,2),
                c(1,0,0,0,0,0,0,0,0,0,0),
                as.Date(c("2017-05-01", "2017-05-02", "2017-05-03", "2017-05-04", "2017-05-05", "2017-05-06"
                          , "2017-05-07", "2017-05-08", "2017-05-09", "2017-05-10", "2017-05-11")))
colnames(I) <- c("local", "imported", "dates")

>EstimateR(I, T.Start=8:10, T.End=9:11, method="ParametricSI", Mean.SI=2, Std.SI=1, plot=TRUE)
Error: Invalid input: date_trans works with objects of class Date only
In addition: Warning message:
In EstimateR_func(I = I, T.Start = T.Start, T.End = T.End, method = method,  :
  You're estimating R too early in the epidemic to get the desired posterior CV.

@jstockwin
Copy link
Collaborator

I also get this sometimes:

Error in if (any(I < 0)) { : missing value where TRUE/FALSE needed
In addition: Warning message:
In Ops.factor(left, right) : ‘<’ not meaningful for factors

Perhaps you need to restrict the <0 check to only I$local and I$imported.

There seem to be a lot of code changes which are nothing to do with the dates, so it's quite hard to track down exactly what is going on, and I don't really have the time right now.

Hopefully those errors give you something to work on, though...

@annecori
Copy link
Collaborator Author

Thanks for your comments Jake, seems by creating weird dates you have indeed found a bug in some of my checking functions - I think I've fixed the issues related with your two first comments - for the third one if it still happens can you please provide some code?
thanks

@jstockwin
Copy link
Collaborator

@annecori The most recent snippet of code now runs properly. The others which didn't run now give a correct looking error.

I've not tested much outside what I've explicitly said about. In particular, nothing about the incidence objects, but it seems you've got an example of this so I assume you've checked that.

@jstockwin
Copy link
Collaborator

I've approved this but will leave it up to you to merge. If you want anything else tested let me know, but I'm pretty short on time.

@annecori annecori merged commit 0dfe3fa into hackout3 May 11, 2017
@annecori annecori deleted the dates branch May 11, 2017 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants