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 <[EMAIL PROTECTED]> wrote:

> From: Avril Coghlan <[EMAIL PROTECTED]>
> 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@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@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.

Reply via email to