0

I would like to use non-linear regression within ggplot, such that I may plot data and fit a curve to the reaction rate r = (k1*PA*PB^0.5)/(1+k2*PA^0.5) where PA and PB are tabulated against reaction rate r. I would like to find constants k1 and k2. I have been able to use nls() to carry out regression, but I need to lay the curve on top of ggplot data.

1. r      PA      PB
2. 0.02   0.002   0.005
3. 0.05   0.004   0.009
4. 0.09   0.005   0.019

plot <- qplot(data = melt.data[which(melt.data$variable ==     c('PA','PB')),], 
              x = Experimental.rate,
              y = value, 
              color = variable)

plot <- plot + stat_smooth(method = nls, 
              formula = with(data, 'y ~ k1 * PA * PB^0.5 / (1 + k2 * PA^0.5 )'), 
              start = list(k1 = 0.1, k2 = 0.1))

Something of this sort...data is for example only I have ~30 rows in series. Let me know what else I can provide to make this an easier to understand example -

4

0 回答 0