Title: | Extends Distributions Available in the 'greta' Package |
---|---|
Description: | Provides extra distributions for use with the 'greta' package. These will include distributions such as zero inflated negative binomial, zero inflated poisson, interval censored lognormal, and more. |
Authors: | Nick Golding [aut] , Nicholas Tierney [aut, cre] |
Maintainer: | Nicholas Tierney <[email protected]> |
License: | Apache License 2.0 |
Version: | 0.0.0.9000 |
Built: | 2024-12-19 05:21:57 UTC |
Source: | https://github.com/greta-dev/greta.distributions |
This code creates the text of a basic greta distribution. To write the text
to file, see write_new_distribution()
.
greta_distribution_template(dist_name, dist_arg_list)
greta_distribution_template(dist_name, dist_arg_list)
dist_name |
character length 1, name of the distribution |
dist_arg_list |
character vector, arguments to the distribution |
text of a basic greta distribution
greta_distribution_template( dist_name = "lognormal", dist_arg_list = c("meanlog", "sdlog") )
greta_distribution_template( dist_name = "lognormal", dist_arg_list = c("meanlog", "sdlog") )
When you add a new distribution, you want to add a test to make sure it is
behaving as expected. This function generates a test template. It only
creates the text, it does not write to file. See
write_distribution_test()
to write the test to file automatically.
greta_distribution_template_test(dist_name)
greta_distribution_template_test(dist_name)
dist_name |
character. A distribution name. E.g., "lognormal" |
text containing test template code
gumbel <- greta_distribution_template_test("gumbel")
gumbel <- greta_distribution_template_test("gumbel")
When you add a new distribution, you want to add a test to make sure it is
behaving as expected. This function generates a test template. See also
greta_distribution_template_test()
to see the text generated if you want
to save it somewhere else.
write_distribution_test(dist_name, overwrite = FALSE)
write_distribution_test(dist_name, overwrite = FALSE)
dist_name |
character, name of distribution. |
overwrite |
logical. Default is FALSE. Whether to overwrite the test file if it already exists. |
test file written out to tests/testthat/test-{dist_name}
.
## Not run: write_distribution_test("gumbel") ## End(Not run)
## Not run: write_distribution_test("gumbel") ## End(Not run)
This generates a starting place for writing a new greta
distribution.
By default this will save the output to "R/dist_name.R". To save to
somewhere else, see greta_distribution_template()
, which will generate
the R code as plain text, and you can then save somewhere else as you wish.
write_new_distribution( dist_name = NULL, dist_arg_list = NULL, overwrite = FALSE )
write_new_distribution( dist_name = NULL, dist_arg_list = NULL, overwrite = FALSE )
dist_name |
name of distribution. |
dist_arg_list |
arguments for distribution. |
overwrite |
logical. default FALSE. Whether to overwrite the test file if it already exists. |
writes to file a new distribution name.
## Not run: write_new_distribution( dist_name = "lognormal", dist_arg_list = c("meanlog", "sdlog") ) ## End(Not run)
## Not run: write_new_distribution( dist_name = "lognormal", dist_arg_list = c("meanlog", "sdlog") ) ## End(Not run)
A Zero Inflated Negative Binomial distribution
zero_inflated_negative_binomial(size, prob, pi, dim = NULL)
zero_inflated_negative_binomial(size, prob, pi, dim = NULL)
size |
positive integer parameter |
prob |
probability parameter ( |
pi |
proportion of zeros |
dim |
a scalar giving the number of rows in the resulting greta array |
## Not run: zinb <- zero_inflated_negative_binomial(size = 2, prob= 0.2, pi = 0.10) calculate(zinb, nsim = 10) m <- model(zinb) mcmc(m) ## End(Not run)
## Not run: zinb <- zero_inflated_negative_binomial(size = 2, prob= 0.2, pi = 0.10) calculate(zinb, nsim = 10) m <- model(zinb) mcmc(m) ## End(Not run)
A zero inflated poisson distribution.
zero_inflated_poisson(lambda, pi, dim = NULL)
zero_inflated_poisson(lambda, pi, dim = NULL)
lambda |
rate parameter |
pi |
proportion of zeros |
dim |
a scalar giving the number of rows in the resulting greta array |
## Not run: zip <- zero_inflated_poisson(lambda = 2, pi = 0.2) calculate(zip, nsim = 10) mcmc(m) ## End(Not run)
## Not run: zip <- zero_inflated_poisson(lambda = 2, pi = 0.2) calculate(zip, nsim = 10) mcmc(m) ## End(Not run)