Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can not provide a complete answer. The only ad hoc idea I had was to provide better starting points for the optimization algorithm - hoping you are closer to the local minimum of the function you try to optimize.</p> <p>Estimating a rough first version is fairly simple. If you write your parabola as <code>b*(x-a)^2+c</code> you can estimate </p> <pre><code>a &lt;- data$x[which.min(data$y)] c &lt;- min(data$y) b1 &lt;- (data$y[which.min(data$x)] - c) / (min(data$x) - a)^2 b2 &lt;- (data$y[which.max(data$x)] - c) / (max(data$x) - a)^2 b &lt;- mean(c(b1, b2)) </code></pre> <hr> <h2>EDIT</h2> <p>I had another intensive testing session with my suggestion and the method "BFGS". I could not find a counter example with the following approach:</p> <pre><code>seed &lt;- floor(runif(1,1,1000)) set.seed(seed) a = 1 b = 2 c = 3 parabola &lt;- function(x) { b * (x-a)^2 + c } N = 10000 x &lt;- runif(N, -4, 3) y &lt;- runif(N, 0, 10) data &lt;- data.frame(x, y) data &lt;- subset(data, y &gt;= parabola(x)) plot(data, xlim = c(-5, 5), ylim = c(0, 10), col = "grey") fr &lt;- function(x) { PAR = x[2] * (data$x - x[1])^2 + x[3] # sum((PAR - data$y)^2 + 100 * plogis(PAR - data$y, scale = 0.00001)) } a &lt;- data$x[which.min(data$y)] c &lt;- min(data$y) b1 &lt;- (data$y[which.min(data$x)] - c) / (min(data$x) - a)^2 b2 &lt;- (data$y[which.max(data$x)] - c) / (max(data$x) - a)^2 b &lt;- mean(c(b1, b2)) par = optim(c(a, b, c), fr, method="BFGS")$par a = par[1] b = par[2] c = par[3] curve(parabola, add = TRUE, lty = "dashed") </code></pre> <p>However, correct convergence is not guaranteed. I tried about 50 cases and all went well. Is your result reviewed or does it have to work correctly on an automated basis?</p> <hr> <h2>EDIT 2</h2> <p>I had a few thoughts on how you could update your objective function to be more reliable. Right now I do not have the time to work out a complete solution, but maybe this thoughts may help you:</p> <p>We have date within <code>range(data$x)</code>. Now we want to find a parabola that fits the lower boundary of this data as good as possible - or, in other words, find values a,b,c that maximize</p> <pre><code>\int_{\range(x)} ax^2 + bx+c dx </code></pre> <p>(Please excuse the clumsy LaTeX - writing formulas sometimes just is better).</p> <p>Now, penalizing points below the parabola could be done using a penalty function like</p> <pre><code>\lambda (ax_i^2+bx_i+c - y_i)^2 if below parabola, 0 otherwise </code></pre> <p>Subtracting that function from the interval should give you a suitable, smooth objective function. Simplifying the function as good a possible seems to be a better model than using the least squares approach, which tries to fit a line through the <em>middle</em> of the datapoints. </p> <p>You will still have to chosse a suitable lambda, though. But that is typical: You need a compromise between two different objectives (fitting data, maximizing the parabola). The weight which one is more important has to be submitted by you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload