[R] fitting distributions with R
Nadja Riedwyl
riedwyl at giub.unibe.ch
Tue Sep 6 15:39:20 CEST 2005
Dear all
I've got the dataset
data:2743;4678;21427;6194;10286;1505;12811;2161;6853;2625;14542;694;11491;
14924;28640;17097;2136;5308;3477;91301;11488;3860;64114;14334
I know from other testing that it should be possible to fit the data with the
exponentialdistribution. I tried to get parameterestimates for the
exponentialdistribution with R, but as the values
of the parameter are very close to 0 i get into troubles. Do you know, what i
could do in order to get estimates?How do you choose the starting values? in
my opinion it should be around 1/mean(data).
#Parameterestimation with mle() with the log-likelihood funktion of the
#exponentialdistribution
library(stats4)
ll<-function(beta)
{n<-24
x<-data2
-n*log(beta)+beta*sum(x)}
est<-mle(minuslog=ll, start=list(beta=0.1))
summary(est)
#instead of a result, i get:
Error in optim(start, f, method = method, hessian = TRUE, ...) :
non-finite finite-difference value [1]
In addition: There were 50 or more warnings (use warnings() to see the first
50)
#with fitdistr() for the exponentialdistribution
library(MASS)
fitdistr(data2,densfun=dexp,start=list(rate=0.1),lower=6e-06,method="BFGS")
#instead of a result, i get
Error in optim(start, mylogfn, x = x, hessian = TRUE, ...) :
non-finite finite-difference value [1]
In addition: Warning messages:
1: bounds can only be used with method L-BFGS-B in: optim(start, mylogfn, x =
x, hessian = TRUE, ...)
2: NaNs produced in: dexp(x, 1/rate, log)
i'll be very happy for any help i can get to solve this problem
thank you!
More information about the R-help
mailing list