Power regression in R similar to excel

后端 未结 3 1160
天涯浪人
天涯浪人 2020-12-14 12:05

I have a simple dataset and I am trying to use the power trend to best fit the data. The sample data is very small and is as follows:

structure(list(Discharg         


        
3条回答
  •  情话喂你
    2020-12-14 12:34

    2018 Update: The call "start" now seems to be depreciated. It is not in the stat_smooth function information either.

    If you want to choose starting values, you need to use "method.args" option now.

    See changes below:

    ggplot(DD,aes(x = Discharge,y = Age)) +
      geom_point() + 
      stat_smooth(method = 'nls', formula = 'y~a*x^b', method.args = list(start= c(a = 1,b=1)),se=FALSE) + geom_text(x = 600, y = 1, label = power_eqn(DD), parse = TRUE)
    

提交回复
热议问题