[R] fitting distributions with R

Huntsinger, Reid reid_huntsinger at merck.com
Tue Sep 6 16:00:08 CEST 2005


The MLE of beta is the reciprocal of the sample mean, so you don't need an
optimizer here. 

Reid Huntsinger

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Nadja Riedwyl
Sent: Tuesday, September 06, 2005 9:39 AM
To: r-help at stat.math.ethz.ch
Subject: [R] fitting distributions with R


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!

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html




More information about the R-help mailing list