Maithili Shiva
2009-Mar-16  05:30 UTC
[R] Fw: Fitting GUMBEL Distribution - CDF function and P P Plot
Dera R Helpers,
I am re-posting my query.
Please guide me.
Maithili
--- On Fri, 3/13/09, Maithili Shiva <maithili_shiva at yahoo.com> wrote:
 I am trying to fit the Gumbel distribution to a data. I am
 using lmom package. I am getting problem in Cumulative
 Distribution Function of Gumbel distribution as I am getting
 it as a series of 0's and 1's thereby affecting the
 P P Plot. My R code is as follows.
 
 
  library(quantreg)
  library(RODBC)
  library(MASS)
  library(actuar)
  library(lmom)
 
  x <-
 
c(986.78,1067.76,1046.47,1034.71,1004.53,1007.89,964.94,1060.24,1188.07,1085.63,988.33,972.71,1177.71,972.48,1203.20,1047.27,1062.95,1113.65,995.97,1093.98)
 
 
 #Estimating the parameters for GUMBEL distribution
 
  N                    <- length(x)
 
  lmom 		    <- samlmu(x); lmom
 
  parameters_of_GUMBEL <- pelgum(lmom); parameters_of_GUMBEL
  
 
  # Parameters are xi =  1019.4003   alpha =   59.5327
 
 
 
  # _____________________ P - P Plot ________________________
  
  e        <- c(1:N)
 
  f        <- c((e-.5)/N)
 
  Fx       <- cdfgum(x, para = parameters_of_GUMBEL)
  
  g        <- sort(Fx)
  
  png(filename = "GUMBEL_P-P.png")
  
  a <- par('bg'= "#FFFFCC")
  
  plot (f,g,bg=a,fg= "#804000",main ="P-P
 Plot", ylab=" Cumulative Distribution
 Function", xlab="i", font.main=2,
 cex.main=1,col="#999966",bty 
"o",col.main="black",col.axis="black",col.lab
 ="black")
 
  abline(rq(g ~ f, tau = .5),col="red")
 
  dev.off()
 
 
 # Fx RETURNS    0 1 1 1 0 0 0 1 1 1 0 0 1 0 1 1 1 1 0 1 
 and Thus plot is not proper
 
  
 
 
 Please guide me as where I am going wrong.
 
 With regards
 
 
 Maithili
J. R. M. Hosking
2009-Mar-16  13:55 UTC
[R] Fw: Fitting GUMBEL Distribution - CDF function and P P Plot
Congratulations, you have discovered a bug in the implementation of function cdfgum. A corrected version of package lmom will be submitted today and should be available on CRAN within a day or two. Meanwhile, as a workaround define cdfgum in your own workspace, thus: cdfgum <- function(x,para) exp(-exp(-(x - para[1])/para[2])) J. R. M. Hosking Maithili Shiva wrote:> Dera R Helpers, > > I am re-posting my query. > > Please guide me. > > Maithili > > > --- On Fri, 3/13/09, Maithili Shiva <maithili_shiva at yahoo.com> wrote: > > I am trying to fit the Gumbel distribution to a data. I am > using lmom package. I am getting problem in Cumulative > Distribution Function of Gumbel distribution as I am getting > it as a series of 0's and 1's thereby affecting the > P P Plot. My R code is as follows. > > > library(quantreg) > library(RODBC) > library(MASS) > library(actuar) > library(lmom) > > x <- > c(986.78,1067.76,1046.47,1034.71,1004.53,1007.89,964.94,1060.24,1188.07,1085.63,988.33,972.71,1177.71,972.48,1203.20,1047.27,1062.95,1113.65,995.97,1093.98) > > > #Estimating the parameters for GUMBEL distribution > > N <- length(x) > > lmom <- samlmu(x); lmom > > parameters_of_GUMBEL <- pelgum(lmom); parameters_of_GUMBEL > > > # Parameters are xi = 1019.4003 alpha = 59.5327 > > > > # _____________________ P - P Plot ________________________ > > e <- c(1:N) > > f <- c((e-.5)/N) > > Fx <- cdfgum(x, para = parameters_of_GUMBEL) > > g <- sort(Fx) > > png(filename = "GUMBEL_P-P.png") > > a <- par('bg'= "#FFFFCC") > > plot (f,g,bg=a,fg= "#804000",main ="P-P > Plot", ylab=" Cumulative Distribution > Function", xlab="i", font.main=2, > cex.main=1,col="#999966",bty > "o",col.main="black",col.axis="black",col.lab > ="black") > > abline(rq(g ~ f, tau = .5),col="red") > > dev.off() > > > # Fx RETURNS 0 1 1 1 0 0 0 1 1 1 0 0 1 0 1 1 1 1 0 1 > and Thus plot is not proper > > > > > Please guide me as where I am going wrong. > > With regards > > > Maithili > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Reasonably Related Threads
- Fitting GUMBEL Distribution - CDF function ISSUE
- lmom - Estimating Normal Distribution Parameters using lmom package
- lmom: plotting log Pearson Type III
- Adding gamma and 3-parameter log normal distributions to L-moments ratio diagram lmrd()
- cdf of weibull distribution