title: Sigmoidal Curve Fit in R
body: <p>I'm a beginner to R and I'm trying to fit a curve onto a data set that (for example) might look like the below:</p>
  
  <pre><code>(x- value)  (y-value)
  105 423
  115 471
  125 567
  135 808
  145 921.5
  155 1040
  </code></pre>
  
  <p>The x value's represent the amount of stimulus and the y values represent motor responses (in uV). These are averages over 10 subjects, where the x-values are the same for each subject. </p>
  
  <p>I was told that this data set normally follows a sigmoidal fit. I tried fitting it with the following:</p>
  
  <pre><code>fit &lt;- lm( y ~ poly(x, 3) )
  </code></pre>
  
  <p>But I'm not sure if this is the appropriate way to do this :(</p>
  
  <p>My code looks like this so far:</p>
  
  <pre><code>p &lt;- ggplot (data, aes(x, y)) +
    geom_point(shape= 21, fill= "blue", colour= "black", size=2) +
    xlab("X value") + ylab("Y value") +
    geom_smooth(method= "lm", se= FALSE,  colour= "red", formula=y ~ poly(x, 3, raw=TRUE)) +
    geom_errorbar(aes(ymin=y-SE, ymax=y+SE), width=.9)+ 
    ggtitle ("Title")
  p
  </code></pre>
  
  <p>Additionally: Once I fit the the curve I would also like to obtain the slope (calculated as the value of the tangent at the steepest point of the curve)</p>
  
  <p>Thanks in advance, any help would be greatly appreciated! </p>