[R] how to code y~x/(x+a) in lm() function

David Carlson dcarlson at tamu.edu
Wed Aug 21 00:00:24 CEST 2013


?curve

set.seed(42)
x <- 1:15
y <- x/(1+x)+rnorm(15, 0, .02)
plot(y~x)
lm.out <- lm((1/y-1)~I(1/x)+0)
curve(x/(coef(lm.out)+x), 1, 15, add=TRUE)

-------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of Ye Lin
Sent: Tuesday, August 20, 2013 4:40 PM
To: R help
Subject: [R] how to code y~x/(x+a) in lm() function

Hey All,

I wanna to fit a model y~x/(a+x) to my data, here is the code I
use now:

lm((1/y-1)~I(1/x)+0, data=b)

and it will return the coefficient which is value of a

however, if I use the code above, I am not able to draw  a curve
the
presents this equation. How can I do this?

Thanks for your help!

	[[alternative HTML version deleted]]

______________________________________________
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.



More information about the R-help mailing list