The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

TKApprox

A General Framework for Bayesian Estimation Using the Tierney-Kadane Approximation

Overview

TKApprox provides a distribution-independent framework for Bayesian estimation of arbitrary univariate probability models using the Tierney-Kadane approximation. Users specify the probability distribution, likelihood, prior distributions, and censoring mechanism, while the package automatically constructs the posterior distribution, computes posterior modes and Hessians, approximates posterior expectations under several Bayesian loss functions, and returns Bayesian parameter estimates, posterior covariance matrices, credible intervals, diagnostic plots, and model comparison statistics.

Features

Installation

# Install from CRAN (when available)
install.packages("TKApprox")

# Install development version from GitHub
devtools::install_github("yourusername/TKApprox")

Quick Start

Example: Exponential Distribution with Gamma Prior

library(TKApprox)

# Define the exponential distribution
pdf_exp <- function(x, param) dexp(x, rate = param)
cdf_exp <- function(x, param) pexp(x, rate = param)

# Specify gamma prior for the rate parameter
prior_spec <- list(
  rate = list(family = "gamma", hyperparameters = list(shape = 2, rate = 1))
)

# Generate some data
set.seed(123)
data <- rexp(20, rate = 1.5)

# Fit the model using squared error loss (posterior mean)
fit <- tk_fit(
  data = data,
  censoring_scheme = "complete",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "sel"
)

# View results
summary(fit)

# Plot diagnostics
plot(fit)

# Compute model comparison statistics
print_model_comparison(fit)

Example with Right-Censored Data

# Define censoring indicators (1 = observed, 0 = right-censored)
status <- c(1, 1, 0, 1, 0, 1, 1, 0, 1, 1)

fit_censored <- tk_fit(
  data = data,
  censoring_scheme = "right-censored",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "sel",
  status = status
)

summary(fit_censored)

Example with LINEX Loss

fit_linex <- tk_fit(
  data = data,
  censoring_scheme = "complete",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "linex",
  loss_params = list(c = 0.5)
)

summary(fit_linex)

Prior Sensitivity Analysis

sensitivity <- tk_sensitivity(
  fit = fit,
  parameter_name = "rate",
  hyperparameter_name = "shape",
  hyperparameter_values = c(0.5, 1, 2, 5, 10)
)

print(sensitivity)
plot(sensitivity)

Censoring Schemes

The package supports the following censoring schemes:

Loss Functions

The following Bayesian loss functions are supported:

Prior Distributions

Supported prior families:

Package Philosophy

TKApprox follows the same design philosophy as UniIS, UniCensorEM, and UniLindleyApprox:

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting pull requests.

License

GPL (>= 3)

Citation

To cite this package, use:

citation("TKApprox")

Author

Your Name

Acknowledgments

This package extends the design philosophy established in UniIS, UniCensorEM, and UniLindleyApprox packages.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.