Learn R Programming

HelpersMG (version 6.2)

rcutter: Random values of unobserved values of cut distribution.

Description

Return n random numbers.
It can be used to get the posterior predictive distribution; see example.
If random_method is "ML", the parameter values obtained using maximum likelihood are used.
If random_method is "medianMCMC", the parameter values obtained using median of posterior distribution are used.
If random_method is "MCMC", the parameter values are one sample of the MCMC posterior distribution.
if observed_detection_limit is set to TRUE, the number of random number is equal to the number of observations; n is not used.
rcutter is the abbreviation for random-cutter.

Usage

rcutter(
  cutter = stop("A result of cutter() must be provided"),
  n = 1,
  lower_detection_limit = NULL,
  upper_detection_limit = NULL,
  method_cut = c("censored", "truncated"),
  observed_detection_limit = FALSE,
  random_method = c("medianMCMC", "MCMC", "ML"),
  index_mcmc = NULL
)

Value

A vector with the random numbers.

Arguments

cutter

The fitted model obtained with cutter()

n

number of random numbers

lower_detection_limit

The lower detection limit

upper_detection_limit

The upper detection limit

method_cut

What method is used to cut the distribution: "censored", "truncated"?

observed_detection_limit

If TRUE, will use the pattern of detection limit as in observations

random_method

How to get parameters; it can be "ML", "medianMCMC", or "MCMC"

index_mcmc

For MCMC random_method, the index of data to be used.

Author

Marc Girondot marc.girondot@gmail.com

Details

rcutter returns random values based on fitted distribution with cut.

See Also

Other Distributions: cutter(), dSnbinom(), dbeta_new(), dcutter(), dggamma(), logLik.cutter(), plot.cutter(), print.cutter(), r2norm(), rmnorm(), rnbinom_new()

Examples

Run this code
if (FALSE) {
library(HelpersMG)
# _______________________________________________________________
# right censored distribution with gamma distribution
# _______________________________________________________________
# Detection limit
DL <- 100
# Generate 100 random data from a gamma distribution
obc <- rgamma(100, scale=20, shape=2)
# remove the data below the detection limit
obc[obc>DL] <- +Inf
# search for the parameters the best fit these censored data
result <- cutter(observations=obc, upper_detection_limit=DL, 
                           cut_method="censored")
result
# Posterior predictive distribution
r <- rcutter(cutter=result, upper_detection_limit=DL, n=100)
hist(r)
# _______________________________________________________________
# left censored distribution with gamma distribution
# _______________________________________________________________
# Detection limit
DL <- 10
# Generate 100 random data from a gamma distribution
obc <- rgamma(100, scale=20, shape=2)
# remove the data below the detection limit
obc[obc

Run the code above in your browser using DataLab