TIMMMAY ed_deroiste at yahoo.co.uk
Sun Jul 15 13:44:23 CEST 2007

```I posted the message below a few days ago but I have not had any responses. I
keep thinking that there must be some easy way to answer the problem I am
just not familiar enough with regression to answer the problem myself. If
anyone can help me I would be very grateful. I need to fit a gamma curve to
a set of data. ie a scatterplot of the data indicates that the curve looks
like a truncated gamma density function and I would like to estimate the
paramaters so that I can fit a curve to the data points. Its not MLE
paramater estimation just a curve fitting exercise. The problem again is

I have a set transition intensities and when plotted the curve looks like a
gamma density. I want to fit a gamma density curve to these intensities. It
is just a curve fitting problem but whats causing the trouble is that I need
to use least squares minimization to calculate the parameters for the gamma
curve. How do I do this???

The curve will be a truncated gamma function so it will have 3 paramaters a,
b, c. I tried to do the following

nls(lograte ~ log(c) + a*log(b) + (a-1)*log(age)+b*(age)-lgamma(a),
start=list(a=1,b=1,c=1)), where lograte, and age are my data. a,b the gamma
parameters and c the parameter we need because we are fitting a truncated
distribution.

I also tried defining
fn = function(p) sum((log(y)-log(dgamma(x,p,p)*p))^2)
a residual sum of squares and using nlm to minimise this and find paramaters
but this doesnt work either. Can anyone help me ?? Please :)

Original message follows :(
Fitting a Gamma Curve
by TIMMMAY Jul 12, 2007; 03:38pm :: Rate this Message:    (use ratings to
moderate[?])

Hi there, I hope someone can help me before I tear all my hair out. I have a
set transition intensities and when plotted the curve looks like a gamma
density. I want to fit a gamma density curve to these intensities. It is
just a curve fitting problem but whats causing the trouble is that I need to
use least squares minimization to calculate the parameters for the gamma
curve. How do I do this???

The curve will be a truncated gamma function so it will have 3 paramaters a,
b, c. I tried to do the following

nls(lograte ~ log(c) + a*log(b) + (a-1)*log(age)+b*(age)-lgamma(a),
start=list(a=1,b=1,c=1)), where lograte, and age are my data. a,b the gamma
parameters and c the parameter we need because we are fitting a truncated
distribution.

I also tried defining
fn = function(p) sum((log(y)-log(dgamma(x,p,p)*p))^2)
a residual sum of squares and using nlm to minimise this and find paramaters
but this doesnt work either. Can anyone help me ?? Please :)