I have successfully power fit the relationship between two variables using lm() with poly(x,2) argument via a package from a prof of mine, and now I would like to add the poly curve to the existing scatterplot; how do I do this in the simplest way?
Asked
Active
Viewed 59 times
0
-
2see `?predict` ... ? – Ben Bolker Jun 18 '15 at 14:10
-
I have tried using the predict arguments, but inevitably end up with a birds nest. I worked around with this code, but it seems overly messy and verbose. lmpol<-lm(PhosphorusConcentration~NitrogenConcentration+I(NitrogenConcentration^2),data=G2) plot(PhosphorusConcentration~NitrogenConcentration, data=G,main="Ground: \nN vs P") text(3.7,0.06,"p=7.488e-07, R^2=0.2881") text(3.62,.42,"P concentration = N concentration*0.212144 \n- 0.032403*(N concentration)^2 \n - 0.13840") beta<-coef(lmpol) vec<-seq(1,4.5,by=.1) lines(vec,beta[1]+beta[2]*vec+beta[3]*vec^2,col="red") – Ivan Haworth Jun 19 '15 at 15:04