1

I am trying to overlay an nls object regression curve on a scatter plot in ggplot2, but I keep running into an error after various attempts in formatting the arguments. I have tried the following recommendation from here, but it does not work anymore since the version of ggplot2 was 2.0 at the time of that post, and is now 3.1.0 (at least the version I am using). Aside from using a previous version of the package, I am not understanding why this format is not working unless something has changed in ggplot2 that I cannot find documentation for. Thanks in advance!

ggplot(enzymes, aes(x=X,y=Y))+
  geom_point()+
  geom_smooth(method = 'nls', data = enzymes, se = FALSE,
              formula = Y~gamma_0*X/(gamma_1 + X),
              method.args = list(start = c(gamma_0 = 1/5.42, gamma_1 = 5.42/.49)))+
  labs(title = "Enzymes Nonlinear Regression Plot")

ggplot(enzymes, aes(x=X,y=Y))+
  geom_point()+
  geom_smooth(method = 'nls', se = FALSE,
              method.args = list(formula = Y~gamma_0*X/(gamma_1 + X), 
                                 start = list(gamma_0 = 1/5.42, gamma_1 = 5.42/.49)))+
  labs(title = "Enzymes Nonlinear Regression Plot")

Both give the following warning

Warning message:
Computation failed in `stat_smooth()`:
parameters without starting value in 'data': Y, X 

Clearly, both have starting values...(unless I'm totally missing something)

J.Reising
  • 11
  • 2

0 Answers0