Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
faosorios authored Jan 22, 2024
1 parent 0de0c5c commit 97c52ea
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions pkg/R/wilson_hilferty.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
## ID: wilson_hilferty.R, last updated 2022-08-22, F.Osorio
## ID: wilson_hilferty.R, last updated 2024-01-03, F.Osorio

wilson.hilferty <- function(x)
{ # Wilson-Hilferty transformation
wilson.hilferty <- function(x, shape, rate = 1)
{ # Wilson-Hilferty transformation for gamma deviates
if (!is.vector(x))
stop("'x' must be a vector")
if (!all(is.finite(x)))
stop("'x' must contain finite values only")
if (any(x < 0))
stop("'x' must be non-negative")
n <- length(x)

if (is.null(shape))
stop("'shape' must be provided")
if (shape < 0)
stop("'shape' must be non-negative")
if (rate < 0)
stop("'rate' must be non-negative")

z <- .C("wilson_hilferty_gamma",
x = as.double(x),
n = as.integer(n),
shape = as.double(shape),
rate = as.double(rate),
z = double(n))$z
z
}

WH.normal <- function(x)
{ # Wilson-Hilferty transformation for multivariate normal deviates
if (is.data.frame(x))
x <- as.matrix(x)
else if (!is.matrix(x))
Expand Down

0 comments on commit 97c52ea

Please sign in to comment.