[R] Please Please Help me!!!

Gabor Grothendieck ggrothendieck at gmail.com
Sun Jul 15 15:16:21 CEST 2007


The reason no one answered may be that you did not follow the last
line to every r-help message or read and follow the posting guide.  Its
time consuming to develop a test environment and data needed to clarify
and test the answer to a question.  By providing data and reproducible
code you reduce the amount of time it takes responders to answer thereby
making it more likely someone will.

On 7/15/07, TIMMMAY <ed_deroiste at yahoo.co.uk> wrote:
>
> 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[1],p[2])*p[3]))^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[?])
>
> Reply | Reply to Author | Show Only this Message
>
> 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[1],p[2])*p[3]))^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 :)
>
>
>
>
> « Return to forum
>
> Start a free forum or mailing list archive on Nabble  Help - Powered by -
> Terms of Use - Jobs at Nabble - Nabble Support
>
> --
> View this message in context: http://www.nabble.com/Please-Please-Help-me%21%21%21-tf4081887.html#a11601686
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list