[R] Error in optim while using fitdistr() function

From: Aswad Gurjar <aswadgurjar_at_gmail.com>
Date: Sun, 10 Feb 2008 11:28:58 +0530


Hello,

I am trying to fit distribution for data consisting of 421 readings.It is basically no of requests arrived per minute.It contains many 0 entries as no of requests.When i use
fd<-fitdistr(V2,"gamma")
I get following error:
Error in optim(x = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, :

        initial value in 'vmmin' is not finite

What should I do ? I need this function because I want to get value of estimated parameters.
Is there any other function to perform such calculations? Please help me.
Thank You.

Code is as follows:
x<-data.frame()
N<-data.frame((read.table("cs2ip.txt"))) attach(N)

m<-min(V1)
k<-floor(1 + log2(length(V1)))
f<-(max(V1)-min(V1))/k
i<-1
j<-1

while(i<=(length(V1))) {
 fc<-0
 while(V1[i]<=(m+f)) {
  fc<-fc+V2[i]
  i<-i+1
  if(i>length(V1))
  break
  }
 x[j,1]<-fc
 m<-m+f
 j<-j+1
}
library(MASS)
fd<-fitdistr(V2,"gamma")

Input data is:
TIME NO
(SEC) OF REQUESTS
32400 0
32460 0
32520 0
32580 0
32640 0
32700 0
32760 0
32820 0
32880 0
32940 0
33000 0
33060 0
33120 0
33180 0
33240 0
33300 0
33360 0
33420 0
33480 0
33540 0
33600 0
33660 0
33720 0
33780 0
33840 0
33900 0
33960 0
34020 0
34080 0
34140 0
34200 0
34260 0
34320 0
34380 0
34440 0
34500 0
34560 0
34620 0
34680 0
34740 0
34800 0
34860 0
34920 0
34980 0
35040 0
35100 0
35160 0
35220 32
35280 0
35340 0
35400 0
35460 0
35520 0
35580 0
35640 0
35700 0
35760 0
35820 0
35880 0
35940 0
36000 0
36060 0
36120 31
36180 32
36240 0
36300 0
36360 0
36420 0
36480 0
36540 0
36600 0
36660 0
36720 0
36780 0
36840 0
36900 0
36960 0
37020 0
37080 0
37140 0
37200 0
37260 0
37320 0
37380 0
37440 0
37500 0
37560 0
37620 0
37680 0
37740 0
37800 0
37860 0
37920 32
37980 0
38040 0
38100 0
38160 0
38220 0
38280 0
38340 0
38400 0
38460 0
38520 0
38580 0
38640 0
38700 0
38760 0
38820 32
38880 32
38940 32
39000 0
39060 0
39120 0
39180 0
39240 0
39300 0
39360 0
39420 0
39480 0
39540 0
39600 0
39660 0
39720 32
39780 32
39840 77
39900 0
39960 0
40020 0
40080 0
40140 0
40200 0
40260 0
40320 0
40380 0
40440 0
40500 0
40560 0
40620 32
40680 32
40740 109
40800 67
40860 92
40920 0
40980 0
41040 0
41100 0
41160 0
41220 0
41280 0
41340 0
41400 0
41460 0
41520 112
41580 0
41640 0
41700 0
41760 0
41820 0
41880 0
41940 0
42000 0
42060 0
42120 0
42180 0
42240 0
42300 0
42360 0
42420 0
42480 0
42540 66
42600 0
42660 93
42720 0
42780 0
42840 0
42900 0
42960 0
43020 0
43080 0
43140 0
43200 0
43260 0
43320 0
43380 0
43440 0
43500 0
43560 0
43620 0
43680 138
43740 0
43800 0
43860 0
43920 0
43980 0
44040 0
44100 0
44160 0
44220 0
44280 0
44340 0
44400 0
44460 0
44520 0
44580 0
44640 0
44700 0
44760 0
44820 0
44880 0
44940 0
45000 0
45060 0
45120 69
45180 90
45240 0
45300 0
45360 112
45420 0
45480 0
45540 0
45600 87
45660 0
45720 97
45780 0
45840 0
45900 0
45960 0
46020 0
46080 0
46140 0
46200 0
46260 0
46320 92
46380 0
46440 0
46500 0
46560 0
46620 0
46680 0
46740 0
46800 0
46860 0
46920 0
46980 0
47040 0
47100 0
47160 0
47220 0
47280 0
47340 0
47400 0
47460 0
47520 0
47580 0
47640 0
47700 0
47760 0
47820 0
47880 0
47940 0
48000 0
48060 0
48120 0
48180 0
48240 0
48300 0
48360 0
48420 0
48480 0
48540 0
48600 0
48660 0
48720 0
48780 0
48840 0
48900 0
48960 0
49020 0
49080 0
49140 0
49200 0
49260 0
49320 0
49380 0
49440 0
49500 0
49560 0
49620 32
49680 32
49740 0
49800 0
49860 0
49920 0
49980 33
50040 0
50100 0
50160 0
50220 0
50280 0
50340 0
50400 0
50460 0
50520 102
50580 0
50640 0
50700 0
50760 100
50820 0
50880 0
50940 0
51000 0
51060 0
51120 0
51180 0
51240 0
51300 0
51360 0
51420 32
51480 32
51540 0
51600 0
51660 0
51720 0
51780 0
51840 0
51900 0
51960 0
52020 0
52080 0
52140 0
52200 0
52260 0
52320 0
52380 0
52440 0
52500 0
52560 0
52620 0
52680 0
52740 0
52800 0
52860 0
52920 0
52980 0
53040 0
53100 0
53160 0
53220 0
53280 0
53340 0
53400 0
53460 0
53520 0
53580 0
53640 0
53700 0
53760 0
53820 0
53880 0
53940 0
54000 0
54060 0
54120 0
54180 0
54240 0
54300 0
54360 0
54420 0
54480 0
54540 0
54600 0
54660 0
54720 0
54780 0
54840 0
54900 0
54960 0
55020 0
55080 0
55140 0
55200 0
55260 0
55320 0
55380 0
55440 0
55500 0
55560 0
55620 0
55680 0
55740 0
55800 0
55860 0
55920 0
55980 0
56040 0
56100 0
56160 0
56220 0
56280 0
56340 0
56400 0
56460 0
56520 0
56580 0
56640 0
56700 0
56760 0
56820 0
56880 0
56940 0
57000 0
57060 0
57120 0
57180 0
57240 0
57300 0
57360 0
57420 0
57480 0
57540 0
57600 0

Aswad

        [[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 Sun 10 Feb 2008 - 06:02:32 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 Sun 10 Feb 2008 - 06:30:13 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