R/pearsonIV.R

Defines functions pearsonIV

Documented in pearsonIV

# Pearson IV Scaled Function

#' Pearson IV Scaled prediction function
#'
#' Generates a prediction based on a Pearson IV scaled function based on and using nomenclature from Nagahara 1999 & 2001
#'
#' @param x A vector of values (In the context of the package, a vector of Temperature values)
#' @param h Value of the "h" new scale parameter
#' @param mu Value of the "mu" location parameter
#' @param tau Value of the "tau" original scale parameter
#' @param delta Value of the "delta" shape parameter
#' @param b Value of the "b" shape parameter
#'
#' @return A vector of predicted values (In the context of the package, a vector of Performance values)
#'
#' @examples
#'
#' @export

pearsonIV <- function(x,h,mu,tau,delta,b){

  # first part top
  f_top <- exp(lngamma_complex(b + b*delta*1i))*exp(lngamma_complex(b - b*delta*1i))*tau^(2*b - 1)

  # first part bottom
  f_bot <- exp(lngamma(b))*exp(lngamma(b - 0.5))*pi^(1/2)

  # second part top
  s_top <- exp(2*b*delta*atan((x-mu)/tau))

  # second part bottom
  s_bot <- ((x - mu)^2 + tau^2)^b

  # putting it together to generate the prediction
  y <- h*(f_top/f_bot)*(s_top/s_bot)

  # avoid returning a complex vector
  y <- as.numeric(y)

  #return
  return(y)

}
ggcostoya/tpcurves2 documentation built on Jan. 1, 2021, 2:19 a.m.