Hi R-users,

I'm not sure what's wrong and how do I check the error?

I have 3 sets of data 

> aug_dt1
 [1]  22.8  49.6  77.9  67.6  91.2  48.9 124.6  54.6  85.8  62.8  63.3 174.7  32.3  22.7  99.9 123.2   4.8 149.0  66.0
[20]  73.9  37.4  22.4  69.5  87.3  66.9  87.2  81.5 109.1  47.4  22.8  92.4  60.9  77.5  91.3  91.9  78.2  39.4 107.5
[39]  57.9  65.5  76.0  47.2 145.5  95.9 106.0 120.4 108.0  96.8  30.2  16.6  54.0  91.0  63.0 120.6  10.0 144.2 126.4
[58] 160.6

> dec_dt1
 [1]   3.3  44.2 157.5   1.0  22.1 179.7  42.0  37.1 184.2  31.5   1.5   3.8  54.7  19.3  19.9   0.5  45.5  15.8  42.7
[20] 104.7  52.6  15.4  67.4  21.7  66.5  11.8 124.4  39.3  17.3  77.5  11.4  18.0  68.2  77.0  41.3  16.3  61.6  24.6
[39] 197.3   4.6  62.1  24.4  37.9  97.7   1.3  69.8  13.9  98.4  30.6   8.6  43.4   1.0 102.0  35.0  21.8  55.4  18.2
[58]  67.6

> jan_dt1
 [1]  49.7  21.8   5.6  24.2   0.8  32.0  88.9  61.6  36.8  74.0  16.3   2.6   7.6 149.7  13.0  65.2   3.8  72.1  49.0
[20]   3.8  24.1   4.3  19.6  32.3   5.6  54.6  94.2  40.7 101.3   0.5  11.7   9.9  86.4  24.3  91.3  66.5  13.2   0.8
[39]  16.0  24.7  18.1  13.5 126.5  18.1  62.5  98.9 212.6  19.2  42.4  41.6  73.2   8.6  15.0  43.2  43.0   1.4 167.4
[58]  11.4

This is my code to estimate alpha and beta:

library(MASS)
alpha.beta <- function(dt)
{ tol <- 1E-6
  fit <- list()
  x <- dt
  a <- x [x > tol]
  fit <- fitdistr(a,dgamma, list(shape = 1, rate = 0.01), lower = 0.01)
  fit
}

When I run I got this message:
> alpha.beta(dec_dt1)
Error in fitdistr(a, dgamma, list(shape = 1, rate = 0.01), lower = 0.01) : 
  optimization failed
> alpha.beta(aug_dt1)
Error in fitdistr(a, dgamma, list(shape = 1, rate = 0.01), lower = 0.01) : 
  optimization failed

but it works for january data
> alpha.beta(jan_dt1)
     shape         rate   
  0.89517560   0.02063325 
 (0.14460597) (0.00437990)

Thank you so much for any help given.


      
	[[alternative HTML version deleted]]


