Skip to content
Prev 75314 / 398502 Next

Question about curve fitting...

I think here it's important to consider how the errors term come into 
the model. If "y = k1 * x^k2 * e" then in the log-scale you have a 
linear model; however if you assume that "y = k1 * x^k2 + e", the you 
want a nonlinear model (i.e., nls()). For instance,

x <- runif(500, 1, 3)
y <- 1 * x^2 + rnorm(500)
m <- nls(y ~ exp(k1 + k2 * log(x)), start = c("k1" = 1, "k2" = 2))
c(exp(coef(m)[1]), coef(m)[2])


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Dan Bolser" <dmb at mrc-dunn.cam.ac.uk>
To: "S.O. Nyangoma" <S.O.Nyangoma at amc.uva.nl>
Cc: "R mailing list" <r-help at stat.math.ethz.ch>
Sent: Wednesday, August 10, 2005 4:53 PM
Subject: Re: [R] Question about curve fitting...