# [R] using nls for gamma distribution (a,b,d)

Peter Ehlers ehlers at ucalgary.ca
Thu Apr 15 18:48:20 CEST 2010

```I don't know what else is wrong, but do you really want
a shape parameter equal to 28? gamma(28) is about 10^28.
That's not a model I would trust.

-Peter Ehlers

On 2010-04-15 9:37, Asif Wazir wrote:
> Dear all
> i want to estimated the parameter of the gamma density(a,b,d)
>
> f(x) = (1/gamma(b)*(a^b)) * ((x-d)^(b-1)) * exp{-(x-d)/a)} for x>d
>
> f(x) = Age specific fertility rate
> x = age
> when i run this in R by usling nls()
>
> gamma.asfr<- formula(asfr ~ (((age-d)^(b-1))/((gamma(b))*(a^b)))*
> exp(-((age-d)/a)))
>
> gamma.asfr1<- nls(gamma.asfr, data= asfr.aus, start = list(b = 28, a = 1,
> d= 0.5), trace = TRUE)
>
> error: Error in numericDeriv(form[[3L]], names(ind), env) :  Missing value
> or an infinity produced when evaluating the model
>
> when I use plinear algoritm, and run this
>
> gamma.asfr1<- nls(gamma.asfr, data= asfr.aus, start = list(b = 28, a = 1,
> d= 0.5), trace = TRUE, algorithm="plinear")
>
> error: number of iterations exceeded maximum of 50
>
> then i fix the iteration and minFactor even then its can't work
>
> gamma.asfr1<- nls(gamma.asfr, data= asfr.aus, start = list(b = 28, a = 1,
> d= 0.5), trace = TRUE, algorithm="plinear", nls.control(maxiter=500,
> minFactor=0.000001))
>
> error: Missing value or an infinity produced when evaluating the model
>
> Can any body tell the problem, where i am doing wrong
>
>
> thanks in advanc
> ..
> Muhammad Asif Wazir
> Ph.D student
> Institut für Statistik und Decision Support Systems (ISDS).
> University of Vienna, Austria
> cell: 00436509092298
>
> 	[[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.

--
Peter Ehlers
University of Calgary

```