#' Fisher's Z transformation and inverse
#'
#' @param r correlation coefficient
#' @param z inverse hyperbolic tangent of the correlation coefficient
#' @name artanh
NULL
#' @rdname artanh
#' @export
artanh <- function(r) {
if (!is.numeric(r)) stop("r must be numeric")
if (any(r < -1) | any(r > 1)) stop("r must be between -1 and 1")
z <- (1/2) * log((1+r)/(1-r), base=exp(1))
return(z)
}
#' @rdname artanh
#' @export
tanh <- function(z) {
if (!is.numeric(z)) stop("z must be numeric")
r <- (exp(2*z)-1)/(exp(2*z)+1)
r[is.infinite(z) & z > 0] <- 1
r[is.infinite(z) & z < 0] <- -1
return(r)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.