R/Decon2CDF.R

Defines functions Decon2CDF

Documented in Decon2CDF

#'Extract the CDF estimate for a specific quantile from a QPdecon object
#'
#'@export
#'@param qpobj a QPdecon output object, with Pdf = FALSE
#'@param quant a vector of quantiles of interest
#'@details Uses linear interpolation to extract the approximate estimate for the requested quantile.
#'@examples
#'y <- rnorm(100) + rnorm(100)
#' qpobj <- QPdecon::QPdecon(Y=y,Pdf=FALSE,f_Z=1)
#' Decon2CDF(qpobj = qpobj,quant = c(1.64,1.96))

Decon2CDF <- function(qpobj, quant){

  x <- qpobj$x
  FX_hat <- qpobj$f_X
  # linear interpolation to obtain F.hat(x)

  CDF_hat <- approx(x = x,y = FX_hat,xout = quant,method = "linear",yleft = 0,yright = 1)$y

  return(CDF_hat)

}
blebedenko/thescript2 documentation built on Dec. 19, 2021, 9:53 a.m.