Comments (4)
This looks like a good solution and doesn't add too much code to handle each of the possible inputs.
My suggestion of the argument name would be onset_to_outcome
or onset_to_outcome_delay
. delay_pmf
might not be appropriate if the density being used internally is the PDF, but I'd have to check the code again to be sure. delay_function
would be a little misleading if the argument also accepts distribution objects as well as functions.
As always, happy to discuss and if there are improvement to be made on the {epiparameter} side to make this step easier feel free to let me know or make an issue.
from cfr.
Yes, delay_dist
seems like a suitable name.
from cfr.
Here's a proposed solution that supports <epidist>
, <distribution>
from {distributional}, <distcrete>
, and a simple closure. I'm suggested support for {distributional} and {distcrete} as they are used in {epiparameter}, and I'm wary of making users work with closures.
I'm unsure about minor differences between epidist and distributional/dgamma, perhaps the accuracy of parameters is the issue. With distcrete, possibly to do with assumed distcrete distribution, or the interval?.
# dummy function that gets PDF/PMF at time points (x)
dens = function(f, x = seq(10)) {
if (inherits(f, "epidist") || inherits(f, "distribution")) {
return(stats::density(f, at = x))
} else if (inherits(f, "distcrete")) {
f$d(x)
} else if (is.function(f)) {
return(f(x))
}
}
# epidist
epidist = epiparameter::epidist_db(
disease = "ebola", epi_dist = "onset_to_death", single_epidist = TRUE
)
#> Using WHO-Ebola-Response-Team, Agua-Agum J, Ariyarajah A, Aylward B, Blake ...
#> _The New England Journal of Medicine_. doi:10.1056/NEJMc1414992
#> <https://doi.org/10.1056/NEJMc1414992>..
#> To retrieve the short citation use the 'get_citation' function
epiparameter::get_parameters(epidist)
#> shape scale
#> 1.641602 4.995122
# distribution object from distributional
a = distributional::dist_gamma(shape = 1.64102, rate = 1 / 4.995122)
# distcrete object
b = distcrete::distcrete(
"gamma", interval = 1, shape = 1.64102, scale = 4.995122, w = 0
)
# anonymous function/closure
g = \(x) stats::dgamma(x, shape = 1.64102, scale = 4.995122)
dens(f = epidist)
#> [1] 0.06495664 0.08295091 0.08807606 0.08671117 0.08190472 0.07536471
#> [7] 0.06810476 0.06073534 0.05361882 0.04696038
dens(f = a)
#> [[1]]
#> [1] 0.06502352 0.08300284 0.08811042 0.08673049 0.08191234 0.07536373
#> [7] 0.06809777 0.06072439 0.05360548 0.04694582
dens(f = b)
#> [1] 0.07553940 0.08628361 0.08780566 0.08452294 0.07873225 0.07176041
#> [7] 0.06440200 0.05713331 0.05023183 0.04384829
dens(f = g)
#> [1] 0.06502352 0.08300284 0.08811042 0.08673049 0.08191234 0.07536373
#> [7] 0.06809777 0.06072439 0.05360548 0.04694582
Created on 2023-10-13 with reprex v2.0.2
from cfr.
Thanks @joshwlambert. Per your suggestion also happy to support only <epidist>
and closure for now. I agree with renaming the argument. The density being used is the PDF/PMF as far as I can tell. Agreed that naming needs some thought - would delay_dist
be more appropriate? That way it's agnostic to object type but hopefully nudges towards <epidist>
.
from cfr.
Related Issues (20)
- Add message to cfr_rolling()
- CFR stands for Risk or Ratio? HOT 4
- replace `cases` by `confirm` for API consistency HOT 7
- Mid-year cleanup HOT 3
- Fix maths rendering in vignettes HOT 2
- Correct `estimate_outcomes()` explanation HOT 1
- Pre-release v0.1.1 HOT 1
- Rename output columns `*_mean`
- Release cfr 0.1.1
- Change README example to show clearer real-time bias
- Difference in the time series of the delay-adjusted rolling Ebola results HOT 2
- Statistically consistent way to handle E(known outcomes) < deaths
- Check Turkey underascertainment estimate HOT 1
- Accounting for different delays to death and recovery
- Including uncertainty in baseline CFR for underascertainment estimation
- Release cfr 0.2.0 HOT 1
- Release cfr 0.1.2
- update reference to `epidist` with `epiparameter`
- Sampling uncertainty for under ascertainment
- Include age structure
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cfr.