title: Finding the elbow/knee in a curve
body: <p>I have these data:</p>
  
  <pre><code>x &lt;- c(6.626,6.6234,6.6206,6.6008,6.5568,6.4953,6.4441,6.2186,6.0942,5.8833,5.702,5.4361,5.0501,4.744,4.1598,3.9318,3.4479,3.3462,3.108,2.8468,2.3365,2.1574,1.899,1.5644,1.3072,1.1579,0.95783,0.82376,0.67734,0.34578,0.27116,0.058285)
  
  y &lt;- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32)
  </code></pre>
  
  <p>which look like:</p>
  
  <pre><code>plot(x,y)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/CtHcw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CtHcw.png" alt="enter image description here"></a></p>
  
  <p>And I want to find a way to get the elbow/knee point at around <code>x=6.5</code></p>
  
  <p>I thought that fitting a <code>loess</code> curve and then taking the second derivative may work but:</p>
  
  <pre><code>plot(x,predict(loess(y ~ x)),type="l")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/h6mW4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h6mW4.png" alt="enter image description here"></a></p>
  
  <p>doesn't look like it'll do the job.</p>
  
  <p>Any idea?</p>