Non-linear regression line and Computation failed in `stat_smooth()`: argument "p" is missing, with no default

Good Evening (or morning) everyone,

I have been trying to fit a non-linear regression line into my standard curve. However, I am getting the following error: missing p value

I have been using the following code:

 stat_smooth(method= "nlm", 
                formula = y ~ a*x^b,
                method.args = list(start = c(a = 470, b = 460)),
                se=FALSE)+

I am not sure whether the value 'a' and 'b' are correct, as I have taken them from the regline equation code:

stat_cor(label.y = c(825),
              label.x = c(0.88), 
          aes(label = paste(..rr.label.., ..p.label.., sep = "~`,`~")))+
   stat_regline_equation(label.x=0.88, label.y=750)+

I have never been fitting a non-linear regression line. However, it is crucial in this experiment as I have got two variables only (concentration and the ratio) in a non-linear relationship.

This is the following code used

library(tidyverse)
library(tidyr)
library(dplyr)
library(readr)
library(ggplot2)
library(ggpubr)
library(gridExtra)
library(cowplot)
ggplot(data = STD, aes(x = Absorbance, y = STD)) +
  labs(title = "Quantifying PGD2 in cell culture lysates and its enzymatic reactions ",
       caption = "PGD2 ELISA")+
    geom_point(colour = "#69b3a2")+
    stat_smooth(method= "nlm", 
                formula = y ~ a*x^b,
                method.args = list(start = c(a = 470, b = 460)),
                se=FALSE)+
    xlab(expression(paste("%B/"~B[0])))+
    ylab(expression(paste("Prostaglandin"~ D[2], ~~ " MOX Concentration (pg/ml) ")))+
    
   theme(plot.background =  element_rect(fill = "transparent"),
         panel.background = element_blank(),
         panel.grid.major = element_blank(),
         panel.grid.minor = element_blank(),
         axis.line = element_line(colour = "black"))+
  
   theme(legend.spacing.y = unit(0.01, "cm"))+
   theme(legend.position = c(0.77, .91),
         legend.background = element_rect(colour = NA, fill = NA))+
   theme(plot.title = element_text(size = 12, face = "bold.italic"),
         plot.caption = element_text(hjust = 0))

That produced the following outcome

Before that, I have added a line, but it is not a non-linear regression line tho.

Moreover, I have been thinking about whether the non-linear equation fits my graph, but it fulfills the legibility of the equation, so this is not the case.

DataUsed

Thank you so much for your help.

I believe (but I'm not sure) that for nlm() the starting values are called p rather than start.

Also, are you sure that you want to raise x to the power 460? That's likely to give you either a very small number of a very large number.

1 Like

Thank you for your answer, unfortunately, that is not the case. After changing the starting value from start to p the error changes and says

Warning: Computation failed in `stat_smooth()`:
could not find function "f"

Answering your second question, I am not sure. Therefore, I am trying to find the right equation for my graph. I think I will use the Michaelis-Menten equation.

Sorry that I wasn't more helpful on the main question. On the secondary issue, note that

> 1.1^460
[1] 1.098083e+19
> 0.9^460
[1] 8.944464e-22
1 Like

No worries. The data you are showing to me what should it tell me?

I can just update my question. The equation above that I was certain that is correct is wrong, particularly I must use the four parametric equation: y=d + a-d/1+ (x/c)^2, however after updating my code chunk I am getting the following warning: Warning: Computation failed in stat_smooth(): parameters without starting value in data: 'd'. Any ideas on how to overcome such warning?

In the equation you had, the starting parameters were suggesting very strange values for y. Since you've changed the equation, that probably doesn't matter.

The problem is that stat_smooth() isn't finding the starting values for your nonlinear estimate. Check that d, a, and c are all being fed in properly.

And as a wild guess (so quite likely wrong), are you sure you want to be using nlm rather than nls?

1 Like

I was surprised that I was getting such strange values for y. Nevertheless, it does not matter if I use nls , or nlm in both examples I am getting this same warning, unfortunately. And yes, I have no idea why is that stat_smooth() is not finding the starting values. Probably I could have used Log logistic functions, however, after typing summary(mydata) it does not find b, c, d and e intercepts

As a debugging suggestion, you might try running your nonlinear estimate without embedding it in stat_smooth. That will help identify whether the problem is in feeding instructions to stat_smooth or in the underlying estimate.

Ok, so I have found a solution. I installed the drc package in which the four parametric function is included. I set up my data model <- drm(STD ~ Absorbance, fct = LL.4(), data = STD), then plot(model) , and I got


I know it requires some alternations to make it look more professional, but it is just a cosmetic thing that I should be fine to do. Thank you so much for your time @startz

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.