Re: [R] how to fit a curve of form Y = X^Z

From: Moshe Olshansky <m_olshansky_at_yahoo.com>
Date: Tue, 17 Jun 2008 15:42:38 -0700 (PDT)


I see two possibilities:

  1. Taking logarithm yields log(Y) = log(X)*Z and this is the regular linear regression with intercept = 0, and in this case Z = Sum(log(Xi)*log(Yi))/Sum(log(Xi)^2). This is very simple but not necessarily what you want (but this solution can be used as a starting point for the next one).
  2. Let f(Z) = Sum((Yi-Xi^Z)^2) and use nonlinear optimization (see ?nls, ?nlm, ?optim, etc.). Note that you can compute the first two derivatives analytically.
    • On Wed, 18/6/08, Avril Coghlan <alc_at_sanger.ac.uk> wrote:

> From: Avril Coghlan <alc_at_sanger.ac.uk>
> Subject: [R] how to fit a curve of form Y = X^Z
> To: "R mailing list" <r-help@r-project.org>
> Received: Wednesday, 18 June, 2008, 12:16 AM
> Hello,
>
> I have a question about R, and will be very grateful for
> any help.
> I have two variables X and Y, and think that Y is related
> to X by a function of the form : Y = X^Z, where Z is <
> 1.
> However, I'm not sure how to find the best-fit equation
> to
> fit my data to a curve of this form using R. Have you any
> ideas?
>
> regards
> Avril Coghlan
> Wellcome Trust Sanger Institute,
> Cambridge, UK
>
>
>
>
> --
> The Wellcome Trust Sanger Institute is operated by Genome
> Research
> Limited, a charity registered in England with number
> 1021457 and a
> company registered in England with number 2742969, whose
> registered
> office is 215 Euston Road, London, NW1 2BE.
>
> ______________________________________________
> 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.



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. Received on Tue 17 Jun 2008 - 22:45:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 17 Jun 2008 - 23:31:29 GMT.

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

list of date sections of archive