# [R] parameters in fitdistr

From: Carsten Steinhoff <carsten.steinhoff_at_gmx.de>
Date: Wed 07 Jun 2006 - 00:09:17 EST

Hello,

today I've updated from Version 2.1.1 to 2.3.1.

The function you can find below for MLE with double tuncated Lognormal Distr. is working very well with 2.1.1 but now with the same function I get the error: object "u_right" not found ... although I've declared standard-values. I also tryed it with the call: my.lnvfit(rlnorm(1000,5,2),u_left=100,u_right=10000)!

Is it due to changes in the environment or in the function "fitdistr" (MASS) ?
For both I could not find anything regarding this problem in the documentation.

Who can help?

Thanks a lot,
Carsten

lognormal_tr=function (loss, u_left=0, u_right=Inf, mu=NA, sigma=NA, ...)

{

library(MASS)
verluste=which(loss>=u_left & loss <=u_right) loss=loss[verluste]

```if (is.na(mu))
mu = mean(log(loss))
if (is.na(sigma))
```

sigma = sd (log(loss))

# Function to optimize

lnv2=function(x,mu,sigma,left,right)
{

return(dlnorm(x,mu,sigma)/(plnorm(right,mu,sigma)-plnorm(left,mu,sigma))) }

pars=fitdistr(loss,lnv2,list(mu=mu,sigma=sigma),left=u_left,right=u_right, ...)
return(mu=as.vector(pars\$estimate[1]), sigma=as.vector(pars\$estimate[2])) }

R-help@stat.math.ethz.ch mailing list

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 07 Jun 2006 - 02:10:36 EST.

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