Hi, Well, i need some help, practical and theoretical. I am wondering why the fitdistplus (mle function) is returning an error for this code: [code] x1 <- c(100,200,140,98,97,56,42,10,2,2,1,4,3,2,12,3,1,1,1,1,0,0); plotdist(x1); descdist(x1, boot =1000); y<- sum(x1); d= as.vector(length(x1)); for(i in 1:length(x1)){ d[i] = x1[i]/y; } fitdist(d, "beta") [/code] Error: Error in fitdist(d, "beta") : the function mle failed to estimate the parameters, with the error code 100 and what should i do to fix this ?? Thank you -- View this message in context: http://r.789695.n4.nabble.com/Beta-distribution-help-needed-tp3695076p3695076.html Sent from the R help mailing list archive at Nabble.com.
This is a theoretical issue. It is impossible for beta-distributed values to take the value of 0 or 1. Hence, an attempt to fit a beta distribution to a vector containing these values fails. HTH, Daniel baxy77 wrote:> > Hi, > > Well, i need some help, practical and theoretical. I am wondering why the > fitdistplus (mle function) is returning an error for this code: > > [code] > x1 <- c(100,200,140,98,97,56,42,10,2,2,1,4,3,2,12,3,1,1,1,1,0,0); > plotdist(x1); > descdist(x1, boot =1000); > y<- sum(x1); > d= as.vector(length(x1)); > for(i in 1:length(x1)){ > d[i] = x1[i]/y; > } > fitdist(d, "beta") > > [/code] > > Error: > > Error in fitdist(d, "beta") : > the function mle failed to estimate the parameters, > with the error code 100 > > and what should i do to fix this ?? > > Thank you >-- View this message in context: http://r.789695.n4.nabble.com/Beta-distribution-help-needed-tp3695076p3695113.html Sent from the R help mailing list archive at Nabble.com.
This is not very confusing. It is the exact same error in the sense that this time the values of x1 are not only outside the interval (0-1) but within [0-1] as in your first example, but this time they are also outside [0-1]. The reason is that you did not divide x1 by sum(x1) this time. In other words, the problem that the values you supply to fitdist() are not permissible by the definition of the distribution "got even worse" if one may say so. For fitdist() to estimate the parameters of a beta distribution it needs the values to be in the open interval (0-1). Read up on http://en.wikipedia.org/wiki/Beta_distribution where the first sentence says: "In probability theory and statistics, the beta distribution is a family of continuous probability distributions defined on the interval (0, 1)..." HTH, Daniel baxy77 wrote:> > ok then this is confusing > > if i do it like this: > > x1 <- c(100,200,140,98,97,56,42,10,2,2,1,4,3,2,12,3,1,1,1,1,0,0); > k <-fitdist(x1, "beta") > plot(k) > > it says > > > Error in mledist(data, distname, start, fix.arg, ...) : > values must be in [0-1] to fit a beta distribution > Calls: fitdist -> mledist > > > I mean the real problem is the Cullen-Frey plot says it is a beta > distribution and i want to see its function . how do i do this >-- View this message in context: http://r.789695.n4.nabble.com/Beta-distribution-help-needed-tp3695076p3695639.html Sent from the R help mailing list archive at Nabble.com.