I'm trying to plot 3 non-linear models in ggplot2. It's working in automatic scale but not in log10 scale where I get the "singular gradient error". What could be the problem(s)?
The data I'm trying to fit (df1):
x y
4.17 0.55
10.08 0.48
40.25 0.38
101.17 0.32
400.33 0.24
The code I tried:
plot <- ggplot(df1, aes(x=x, y=y))+
stat_smooth(method="nls",
formula=y~I(a*x^(-n)),
data=df1,
start=list(a=1,n=1),
se=FALSE,
colour="red")+
stat_smooth(method="nls",
formula=y~m*(x+m^(1/n))^(-n),
data=df1,
start=list(m=0.7, n=0.17),
se=FALSE,
colour="blue")+
stat_smooth(method="nls",
formula=y~m*(x+m^(1/n))^(-n)+b,
data=df1,
start=list(m=0.7, n=0.17, b=1),
se=FALSE,
colour="green")+
geom_point()+
scale_x_log10()+
scale_y_log10()+
theme_bw()
plot