[R] Fitting a curve to to an oscillating scatter . .

Prof Brian D Ripley ripley at stats.ox.ac.uk
Sun Aug 13 20:58:28 CEST 2000


On Sun, 13 Aug 2000, Phil Rhoades wrote:

> I have just got going with R and think it is really nice however, as far as 
> I can see, it can't do what I got it for:

Sure it can.  It is a fully fledging computing language.

> I have some output from a computer simulation of mutating genes represented 
> by a biological statistic - so the graph looks roughly like the top of:
> 
> 	x = y^2
> 
> - with oscillations around the general curve.
> 
> If I use scatter.smooth() I get a nice curve representing the oscillations 
> but what the curve I want to fit is the more basic curve ie the top arm of 
> the x = y^2.
> 
> Any suggestions?

plot(x, y)
fit <- lm(y ~ I(x^0.5)) # or y ~ sqrt(x)
lines(predict(fit), sort(x))

if indeed the response is y to stimulus x.


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list