| Title: | Incorporate Rounding for Discrete Data Modeling |
|---|---|
| Description: | Provides density, distribution and random number generator functions to account for discretization in data where recorded values mask the underlying measurement process. Details on methodology are described in Glazer et al. (2026) <doi:10.1080/00031305.2025.2604812>. |
| Authors: | Berkeley Ho [aut, cre] |
| Maintainer: | Berkeley Ho <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-05-18 21:15:57 UTC |
| Source: | https://github.com/cran/roundr |
Returns the probability mass function for the rounded asymmetric Laplace distribution
drdald( x, mu = 0, sigma = 1, tau = 0.5, n.quad = 7, thresh = 1e-20, log = FALSE )drdald( x, mu = 0, sigma = 1, tau = 0.5, n.quad = 7, thresh = 1e-20, log = FALSE )
x |
Vector of quantiles. |
mu |
Vector of location parameters. |
sigma |
Vector of scale parameters. |
tau |
Vector of skewness parameters. |
n.quad |
Numeric. The degree of a Legendre polynomial used for approximation. |
thresh |
Numeric. Threshold used to truncate small probability values
before taking logarithms when |
log |
Logical. If TRUE, probabilities p are given as log(p). |
A vector of densities.
drdald(-1) drdald(x = 0, mu = 2, sigma = 2, tau = .3) x = -3:3 mu = 1 sigma = 1 tau = 0.5 drdald(x = x, mu = mu, sigma = sigma, tau = tau, log = TRUE)drdald(-1) drdald(x = 0, mu = 2, sigma = 2, tau = .3) x = -3:3 mu = 1 sigma = 1 tau = 0.5 drdald(x = x, mu = mu, sigma = sigma, tau = tau, log = TRUE)
Returns the probability mass function for the rounded normal distribution
drdnorm(x, mu = 0, sigma = 1, n.quad = 7, thresh = 1e-20, log = FALSE)drdnorm(x, mu = 0, sigma = 1, n.quad = 7, thresh = 1e-20, log = FALSE)
x |
Vector of quantiles. |
mu |
Vector of means. |
sigma |
Vector of standard deviations. |
n.quad |
Numeric. The degree of a Legendre polynomial used for approximation. |
thresh |
Numeric. Threshold used to truncate small probability values
before taking logarithms when |
log |
Logical. If TRUE, probabilities p are given as log(p). |
A vector of densities.
drdnorm(x = 1) drdnorm(x = -1, mu = 1, sigma = 4) y <- c(-1, 0, 1, 2, 3) mu <- 1.5 sigma <- 2 drdnorm(x = y, mu = mu, sigma = sigma, log = TRUE)drdnorm(x = 1) drdnorm(x = -1, mu = 1, sigma = 4) y <- c(-1, 0, 1, 2, 3) mu <- 1.5 sigma <- 2 drdnorm(x = y, mu = mu, sigma = sigma, log = TRUE)
Returns the Cumulative Distribution Function for the rounded asymmetric Laplace distribution
drpald( q, mu = 0, sigma = 1, tau = 0.5, lower.tail = TRUE, log.p = FALSE, n.quad = 7, thresh = 1e-20, tails = 35 )drpald( q, mu = 0, sigma = 1, tau = 0.5, lower.tail = TRUE, log.p = FALSE, n.quad = 7, thresh = 1e-20, tails = 35 )
q |
Vector of quantiles. |
mu |
Vector of location parameters. |
sigma |
Vector of scale parameters. |
tau |
Vector of skewness parameters. |
lower.tail |
Logical. If TRUE, probabilities are |
log.p |
Logical. If TRUE, probabilities p are given as log(p). |
n.quad |
Numeric. The degree of a Legendre polynomial used for approximation. |
thresh |
Numeric. Threshold used to truncate small probability values
before taking logarithms when |
tails |
Numeric. Threshold used to generate probabilities for sampling. |
A vector of cumulative probability densities
drpald(0) drpald(q = 0.5, mu = 0, sigma = 1, tau = 0.75, log.p = TRUE) q = -1:3 mu = 1 sigma = 2 tau = 0.5 drpald(q = q, mu = mu, sigma = sigma, tau = tau, lower.tail = FALSE)drpald(0) drpald(q = 0.5, mu = 0, sigma = 1, tau = 0.75, log.p = TRUE) q = -1:3 mu = 1 sigma = 2 tau = 0.5 drpald(q = q, mu = mu, sigma = sigma, tau = tau, lower.tail = FALSE)
Returns the Cumulative Distribution Function for the rounded normal distribution
drpnorm( q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE, n.quad = 7, thresh = 1e-20, tails = 10 )drpnorm( q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE, n.quad = 7, thresh = 1e-20, tails = 10 )
q |
Vector of quantiles. |
mu |
Vector of means. |
sigma |
Vector of standard deviations. |
lower.tail |
Logical. If TRUE, probabilities are |
log.p |
Logical. If TRUE, probabilities p are given as log(p). |
n.quad |
Numeric. The degree of a Legendre polynomial used for approximation. |
thresh |
Numeric. Threshold used to truncate small probability values
before taking logarithms when |
tails |
Numeric. Threshold used to generate probabilities for sampling. |
Vector of cumulative probability densities for the given quantiles.
drpnorm(2) drpnorm(q = 0, mu = 1, sigma = 1) q <- c(1, 2, 3) mu <- 3 sigma <- 2 drpnorm(q = q, mu = mu, sigma = sigma, lower.tail = FALSE)drpnorm(2) drpnorm(q = 0, mu = 1, sigma = 1) q <- c(1, 2, 3) mu <- 3 sigma <- 2 drpnorm(q = q, mu = mu, sigma = sigma, lower.tail = FALSE)
Returns randomly generated values from the rounded asymmetric Laplace distribution
drrald( n, type = c("floor", "ceil", "nearest"), mu = 0, sigma = 1, tau = 0.5, tails = 35 )drrald( n, type = c("floor", "ceil", "nearest"), mu = 0, sigma = 1, tau = 0.5, tails = 35 )
n |
Number of observations. When |
type |
Character. Type of rounding applied to the latent variable.
One of |
mu |
Vector of values for the location parameter. |
sigma |
Vector of values for the scale parameter. |
tau |
Vector of values to for the skewness parameter. |
tails |
Numeric. Threshold used to generate probabilities for sampling. |
A vector of numbers randomly generated from a rounded asymmetric Laplace distribution.
drrald(1, "floor") drrald(n = 5, type = "ceil", mu = 5, sigma = 4, tau = 0.5) mu = c(1, 4) sigma = c(1, 2) tau = c(0.3, 0.5) drrald(n = 7, type = "nearest", mu = mu, sigma = sigma, tau = tau)drrald(1, "floor") drrald(n = 5, type = "ceil", mu = 5, sigma = 4, tau = 0.5) mu = c(1, 4) sigma = c(1, 2) tau = c(0.3, 0.5) drrald(n = 7, type = "nearest", mu = mu, sigma = sigma, tau = tau)
Returns randomly generated values from the rounded normal distribution
drrnorm(n, type = c("floor", "ceil", "nearest"), mu = 0, sigma = 1, tails = 10)drrnorm(n, type = c("floor", "ceil", "nearest"), mu = 0, sigma = 1, tails = 10)
n |
Number of observations. When |
type |
Character. Type of rounding applied to the latent variable.
One of |
mu |
Vector of means. |
sigma |
Vector of standard deviations. |
tails |
Numeric. Threshold used to generate probabilities for sampling. |
A vector of numbers randomly generated from a rounded normal distribution.
drrnorm(1, "floor") drrnorm(n = 10, type = "nearest", mu = 4, sigma = 2) mu <- c(0, 5) sigma <- c(1, 4) drrnorm(n = 20, "ceil", mu = mu, sigma = sigma)drrnorm(1, "floor") drrnorm(n = 10, type = "nearest", mu = 4, sigma = 2) mu <- c(0, 5) sigma <- c(1, 4) drrnorm(n = 20, "ceil", mu = mu, sigma = sigma)