[R] fitting distributions using fitdistr (MASS)

From: Usha <usha.nair_at_tcs.com>
Date: Tue, 03 May 2011 02:53:19 -0700 (PDT)


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

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)

>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_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.
Received on Thu 05 May 2011 - 06:25:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 May 2011 - 07:00:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive