how to get a geom_smooth for an nls assymptote function using SSasympOff
<p>I have the following dataframe: </p>

<pre><code>df1&lt;- structure(list(Site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("ALT01"), class = "factor"), Nets = 1:18, Cumulative.spp = c(12L,13L, 15L, 17L, 17L, 17L, 17L, 19L, 19L, 19L, 19L, 20L, 22L, 22L, 22L, 22L, 22L, 22L)), .Names = c("Site", "Nets", "Cumulative.spp"), row.names = c(NA, 18L), class = "data.frame")
</code></pre>

<p>and I am trying to get a ggplot2 plot with the geom_smooth response of this function:</p>

<pre><code>Model1&lt;-nls(Cumulative.spp ~ SSasympOff(Nets, A, lrc, c0), data = df1)
</code></pre>

<p>Typically if I had a model like this:</p>

<pre><code>Model2 &lt;- lm(Cumulative.spp ~ I(log(Nets), data = df1)
</code></pre>

<p>I tried two methods</p>

<p><strong>Method 1</strong></p>

<p>I would do this:</p>

<pre><code> library(ggplot2)

 ggplot(df1, aes(x=Nets, y = Cumulative.spp)) + geom_point() + geom_smooth(method="lm", formula=y~log(x), fill="blue", fullrange=T) 
</code></pre>

<p><a href="https://i.stack.imgur.com/pCxbm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pCxbm.png" alt="enter image description here"></a></p>

<p>but when I try to do the same with the assymptote it does not work:</p>

<pre><code>ggplot(df1, aes(x=Nets, y = Cumulative.spp)) + geom_point() + geom_smooth(method="nls", formula=y~SSasympOff(x, A, lrc, c0), color="blue", fullrange=T) 
</code></pre>

<p>but I got this error and this plot:</p>

<pre><code>Warning message:
Computation failed in `stat_smooth()`:
$ operator is invalid for atomic vectors 
</code></pre>

<p><a href="https://i.stack.imgur.com/vvNf3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vvNf3.png" alt="enter image description here"></a></p>

<p><strong>Method2</strong></p>

<p>I tried predicting over the original dataframe to get a confidence interval and using <code>geom_line</code> over the predicted values and <code>geom_ribbon</code> on the interval, but when I do</p>

<pre><code>predict(Model1, df1, interval = "confidence")
</code></pre>

<p>but I do not get the confidence interval, only the predicted values</p>

<p>any help would be appreciated</p>