Martin
Martin

Reputation: 13

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

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

The main problem is that with the linear regression line I could use a simple command like:

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)+

And the equation for the linear regression line with an a, and b values appear. In this case after using the following:

stat_smooth(method= "nlm", 
                formula = y~a*x/(b+x),
                method.args = list( start = c(a = 3.8, b = 1457.2)),
                se=FALSE)+

I am getting the above error. You may ask where I got the a, and b values? I got them from:

nls(y~a*x/(b+x))

That has shown:

I do not know where I am making mistakes.

This is the entire code for my graph

library(tidyverse)
library(tidyr)
library(dplyr)
library(readr)
library(ggplot2)
library(ggpubr)
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+x),
                method.args = list( start = c(a = 3.8, b = 1457.2)),
                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 gives the following outcome

And this is DataUsed

Upvotes: 0

Views: 582

Answers (1)

Martin
Martin

Reputation: 13

So, I think I have found a solution to my problem. I installed the install.packages(drc) 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 @stefan for your time.

Upvotes: 1

Related Questions