Skip to content

Extends the functionality of the greta probabilistic programming framework to support censored data modeling

License

Notifications You must be signed in to change notification settings

mtwesley/greta.censored

Repository files navigation

greta.censored: Censored Distributions for greta

CRAN status Codecov test coverage R-CMD-check

Overview

greta.censored is an R package that extends greta to support the following distributions with right, left, and interval censoring:

  • Normal
  • Log-Normal
  • Student’s T
  • Gamma
  • Exponential
  • Weibull
  • Pareto
  • Beta

Installation

You can install the stable version of greta.censored from CRAN with:

install.packages("greta.censored")

Alternatively, you can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("mtwesley/greta.censored")

Usage

Here are some examples demonstrating how to use the main functions of the greta.censored package:

Example 1: Censored Normal Distribution

library(greta)
library(greta.censored)

# Define the parameters
mean <- as.greta_array(0)
sd <- as.greta_array(1)
is_censored <- as.greta_array(c(0, 1, 0))
censor <- "right"
lower <- -Inf
upper <- 1

# Create the censored normal distribution
dist <- normal_censored(mean, sd, is_censored, censor, lower, upper)

# Print the distribution
print(dist)

Example 2: Censored Log-Normal Distribution

library(greta)
library(greta.censored)

# Define the parameters
meanlog <- as.greta_array(0)
sdlog <- as.greta_array(1)
is_censored <- as.greta_array(c(0, 1, 0))
censor <- "left"
lower <- 0
upper <- Inf

# Create the censored log-normal distribution
dist <- lognormal_censored(meanlog, sdlog, is_censored, censor, lower, upper)

# Print the distribution
print(dist)

Code of Conduct

Please note that the greta.censored project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

Citation

If you use the greta.censored package, please cite it as follows:

Wesley M (2024). greta.censored: Censored Distributions for ‘greta’. R package version 0.1.0, https://CRAN.R-project.org/package=greta.censored.

Or use the following:

citation("greta.censored")

Or in BibTeX format:

@Manual{
  title = {greta.censored: Censored Distributions for 'greta'},
  author = {Mlen-Too Wesley},
  year = {2024},
  note = {R package version 0.1.0},
  url = {https://CRAN.R-project.org/package=greta.censored},
}

Alternatively, refer to the package’s CRAN page: greta.censored on CRAN.

About

Extends the functionality of the greta probabilistic programming framework to support censored data modeling

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages