lbelzile/mev

Improve fit of `extgp`

lbelzile opened this issue · 0 comments

Request of P. Naveau and P. Ailliot

Issues with discrete data for extgp model. Following code to look at.

pextgpd=function(theta,x){  #fonction de répartition sans prendre en compte la discrétisation
p=(1-pmax((1+theta[3]*(x-theta[4])/theta[1]),0)^(-1/theta[3]))^(theta[2]) #renvoie NaN si x<theta[4]
  p[is.na(p)]=0
  return(p)
}

qextgpd=function(theta,p,step){  #fonction quantile avec discrétisation (pour les qqplots)
qcont=theta[4]+theta[1]/theta[3]*((1-p^(1/theta[2]))^(-theta[3])-1) #sans discrétisation
  return(step*floor((qcont-step)/step))  #quantile après discrétisation
}

LLexpGPD=function(theta,y,step){  #fonction de vraisemblance discrétisée
  #theta=(sigma,alpha,xi,ym)
out=sum(log(pextgpd(theta,y+step)-pextgpd(theta,pmax(y,theta[4]))))
  return(-out)
}