epinowcast / primarycensored

Primary event censored distributions in R and Stan.
https://primarycensored.epinowcast.org/
Other
7 stars 1 forks source link

Consider adding feature to truncate delay to given percent of total mass #66

Open athowes opened 1 month ago

athowes commented 1 month ago

Similar to what I've done here:

cmf_cowling <- ppcens(
  q = 0:round(5 * gi_mean_cowling),
  pdist = pgamma,
  shape = gamma_shape(gi_mean_cowling, gi_sd_cowling),
  scale = gamma_scale(gi_mean_cowling, gi_sd_cowling),
  pwindow = 1
)

(D_cowling <- min(which(cmf_cowling > 0.99)) - 1)

pmf_cowling <- dpcens(
  x = 0:(D_cowling - 1),
  pdist = pgamma,
  shape = gamma_shape(gi_mean_cowling, gi_sd_cowling),
  scale = gamma_scale(gi_mean_cowling, gi_sd_cowling),
  pwindow = 1,
  swindow = 1,
  D = D_cowling
)

Of course the 0.99 can be a parameter. And I used q = 0:round(5 * gi_mean_cowling) as I thought that'd ensure 0.99 was in there, but might need another solution here.

This function could be useful for users who want a shorter delay PMF.

seabbs commented 4 weeks ago

Thanks @athowes. I agree that I can see a use for this. I am not totally clear how this would be communicated (especially in light of #63) so do you have a suggestion?

I think this would definitely be something to restrict to the R side vs trying to extend it to the stan code.

seabbs commented 1 week ago

I'm still not clear how to communicate or provide an interface for this. Perhaps via a helper function that does this vs including it directly?

seabbs commented 1 week ago

@zsusswein, sbfnk, and @jamesmbaazam I imagine you might have some thoughts on what this should look like given you've all implemented this kind of thing in various places.

zsusswein commented 1 week ago

I may be missing something but this feels like a job for qpcens()?

seabbs commented 6 days ago

Good point so the flow would be qpcens() for D and then use dpcens() vs what I think the request was which is a single wrapper function.