plot with power law line function

45 views
Skip to first unread message

anvar sour

unread,
Feb 2, 2018, 3:51:01 PM2/2/18
to ggplot2
Hi there,

I do appreciate if someone kindly help me that enables me to perform fitting power-law line between two variable.  I have two variable (LnB and LnC), I want to plot this two variables and then I want to fit regression line with power-law function across this two variable. Is it possible to use geom-smooth to adjust a power-law curve?


Thanks for the help in advance.
Best Regards,
Anvar,

Bin Wang

unread,
Feb 3, 2018, 1:10:57 AM2/3/18
to ggplot2

just use the nls() function, in which specify the model (power law function) u use.  And  below  is  a link to a post talking about non-linear fitting. 

https://www.r-bloggers.com/first-steps-with-non-linear-regression-in-r/

-Bin

anvar sour

unread,
Feb 8, 2018, 3:16:16 AM2/8/18
to ggplot2
Dear Bin Wang,

thanks for your attention, but how I can calculate "a", and "b" for my data in the following code?
nlm <- nls(Biomass ~ a * I(Coverage^b), start = list(a = ......, b = ......), data=data)
plot(Biomass ~ Coverage, data=data)
lines(data$Coverage, fitted(nlm), col = "red", lwd = 2)

Best Regards,
Anvar,
Reply all
Reply to author
Forward
0 new messages