0

I want to use non-linear regression lines to show the Height over Diameter relation of trees. I'm using the following formula:

h = A + B ∙ d + C ∙ d²

For this I used the nls package in R. I inserted the Formula in the follwing way:

M1<-nls(T_Height~p1+p2*DBH+p3*DBH^2)
plot(T_Height~DBH)
lines(DBH,predict(M1),lty=2,col='red',lwd=3)

However the result is not a single line fit but looks as followsenter image description here

What am I doing wrong? Is there a way to reduce the result to one single fitted line?

Thanks in advance

Lukas
  • 223
  • 3
  • 12
  • 1
    I think the function you are looking for is abline – user124123 Oct 24 '16 at 09:06
  • I thought abline is only used for linear lines? When I use it it will go straight up reaching H= 30 at the DBH=0.2. That can't be right – Lukas Oct 24 '16 at 09:11
  • Actually yes use predict not abline. – user124123 Oct 24 '16 at 09:15
  • What do you mean with sorting DBH and predict(M1) in the right order? Order them in the formula or sort them with sort()? I will have a look into the curve functions. And in which way is this a duplicate? Whcih question does it duplicate? – Lukas Oct 24 '16 at 09:19

0 Answers0