-1

I'm trying to convert a distribution into a pseudo-uniform distribution. Using the spd R package, it is easy and it works as expected.

 library(spd)
 x <- c(rnorm(100,-1,0.7),rnorm(100,3,1))
 fit<-spdfit(x,upper=0.9,lower=0.1,tailfit="GPD", kernelfit="epanech")
 uniformX = pspd(x,fit) 

I want to generalize extreme value modeling to include threshold uncertainity. So I used the evmix package.

 library(evmix) 
 x <- c(rnorm(100,-1,0.7),rnorm(100,3,1))
 fit = fgkg(x, phiul = FALSE, phiur = FALSE, std.err = FALSE)
 pgkg(x,fit$lambda, fit$ul, fit$sigmaul, fit$xil, fit$phiul, fit$ur, 
 fit$sigmaur, fit$xir, fit$phiur)

Im messing up somewhere.

user3647872
  • 85
  • 1
  • 9

1 Answers1

1

Please check out the help for pgkg function:

help(pgkg)

which gives the syntax:

pgkg(q, kerncentres, lambda = NULL, ul = as.vector(quantile(kerncentres,
  0.1)), sigmaul = sqrt(6 * var(kerncentres))/pi, xil = 0, phiul = TRUE,
  ur = as.vector(quantile(kerncentres, 0.9)), sigmaur = sqrt(6 *
  var(kerncentres))/pi, xir = 0, phiur = TRUE, bw = NULL,
  kernel = "gaussian", lower.tail = TRUE)

You have missed the kernel centres (the data), which is always needed for kernel density estimators. Here is the corrected code:

library(evmix) 
x <- c(rnorm(100,-1,0.7),rnorm(100,3,1))
fit = fgkg(x, phiul = FALSE, phiur = FALSE, std.err = FALSE)
prob = pgkg(x, x, fit$lambda, fit$ul, fit$sigmaul, fit$xil, fit$phiul, 
fit$ur, fit$sigmaur, fit$xir, fit$phiur)
hist(prob) % now uniform as expected
  • Thank you so much,Carl. I wasn't sure that was correct. – user3647872 Apr 14 '15 at 03:05
  • @Carl Scarrott please consider the following question: http://stackoverflow.com/questions/30463052/unexpected-behavior-of-the-fdwm-function-of-the-evmix-r-package Thanks – Antoine May 26 '15 at 15:40