On Tue, 3 May 2011, Usha wrote:
Please guide me through to resolve the error message that I get
this is what i have done.
x1<- rnorm(100,2,1)
x1fitbeta<-fitdistr(x1,"beta")
Error in fitdistr(x1, "beta") : 'start' must be a named list
You have many errors, starting with not reading the posting guide.
But the main ones seem to be:
(A) A beta distribution has support (0,1). I bet your data are not
confined to that interval. If true (and you failed to give the
reproducible example the posting guide asked for), then the
log-likelihood is -Inf ('not finite') for any value of the parameters.
fitdistr() is support software for a book: it is not a tutorial on the
basics of maximum-likelihood estimation.
(B) As the help says
For the following named distributions, reasonable starting values
will be computed if ‘start’ is omitted or only partially
specified: ‘"cauchy"’, ‘"gamma"’, ‘"logistic"’, ‘"negative
binomial"’ (parametrized by ‘mu’ and ‘size’), ‘"t"’ and
‘"weibull"’.
Since beta is not one of those, you need to specify starting values.
Yes, I do understand that sometime for the distribution to converge to the
given set of data, it requires initial parameters of the distribution, to
start off with. Hence, i tried this
x1fitbeta<-fitdistr(x1,densfun=dbeta, start=list(shape1=2,shape2=3))
Error in optim(x = c(1.89074018737135, 1.52649293971978, 2.19950245230280,
:
initial value in 'vmmin' is not finite
I tried with "f" and "chi-square" what i did with "t". Please find below
the output.
x1fitt<-fitdistr(x1,"t")
Error in fitdistr(x1, "t") : optimization failed
In addition: Warning messages:
1: In log(s) : NaNs produced
2: In log(s) : NaNs produced
3: In log(s) : NaNs produced
4: In log(s) : NaNs produced
5: In log(s) : NaNs produced
6: In log(s) : NaNs produced
x1fitt<-fitdistr(x1,"t", df=1)
Warning messages:
1: In log(s) : NaNs produced
2: In log(s) : NaNs produced
x1fitf<-fitdistr(x1,"f",start=list(df1=2,df2=3))
Warning message:
In df(x, df1, df2, log) : NaNs produced
x1fitf
df1 df2
5.6733242 4.4962519
(1.3407776) (0.9016752)
No guarantee that your x1 values are positive, either.
x1fitchi<-fitdistr(x1,"chi-squared",df=3)
Error in fitdistr(x1, "chi-squared", df = 3) :
'start' must be a named list
It is the same as what i gave for beta?!!
x1fitbeta<-fitdistr(x1,"beta", start=list(shape1=2,shape2=3))
Error in optim(x = c(1.89074018737135, 1.52649293971978, 2.19950245230280,
:
initial value in 'vmmin' is not finite
What is the right syntax....why do I get error for only some, what are the
exceptions?
I dont know how rectify this error. please resolve
Thanks in advance.
--
View this message in context:
http://r.789695.n4.nabble.com/fitting-distributions-using-fitdistr-MASS-tp3492103p3492103.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]
______________________________________________
R-help@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.
--
Brian D. Ripley, rip...@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________
R-help@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.