<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Le 03/22/2016 09:54 PM, Samuel Gougeon
      a écrit :<br>
    </div>
    <blockquote cite="mid:56F1B0F2.30407@free.fr" type="cite">Hi,
      <br>
      <br>
      Le 22/03/2016 10:55, Stéphane Mottelet a écrit :
      <br>
      <blockquote type="cite">Hello,
        <br>
        <br>
        Le 22/03/2016 10:41, <a class="moz-txt-link-abbreviated" href="mailto:antoine.monmayrant@laas.fr">antoine.monmayrant@laas.fr</a> a écrit :
        <br>
        <blockquote type="cite">Hi everyone,
          <br>
          <br>
          I have a very general and naive question concerning leastsq:
          what am I to do with "gopt", the "gradient of f at xopt"?
          <br>
          <br>
          Is there a way to link it to the confidence interval for each
          parameter of my fit?
          <br>
        </blockquote>
        Not really, but since leastsq is a wrapper for optim, which
        returns the gradient at returned "optimal" solution, it is also
        returned. However, if the final gradient is seen to be far from
        the zero vector, then all confidence intervals based on the
        inverse of the Fisher matrix (computed with the Jacobian) will
        not have any sense, since these "linear" statistics are based on
        a development where the first term (using the gradient) is
        supposed to vanish... Hence, having access to the final gradient
        can be of interest.
        <br>
      </blockquote>
      <br>
      We may guess that, if bounds constraints are set for x, a non-zero
      gradient could as well be returned whether xopt reaches a point on
      the boundary, where fun() has not a true minimum, just a negative
      interrupted slope leading it to a low value.
      <br>
    </blockquote>
    <br>
    Right.<br>
    I usually check whether a given parameter is equal to one of its
    boundaries to avoid this kind of issues.<br>
    <blockquote cite="mid:56F1B0F2.30407@free.fr" type="cite">
      <br>
      <blockquote type="cite">
        <blockquote type="cite">For the moment, I know how to estimate
          these confidence intervals when I have access to the Jacobian
          matrix of my fit function.
          <br>
        </blockquote>
      </blockquote>
      I am not sure that we are speaking about the same jacobian.
      <br>
    </blockquote>
    Well, I am talking about the dfun() function as described in the
    help page of leastsq.<br>
    I use it to get an estimate of the confidence interval for each
    parameter of my fit based on "Least Squares Estimation", SARA A. VAN
    DE GEER<br>
    Volume 2, pp. 1041-1045,  in Encyclopedia of Statistics in
    Behavioral Science, ISBN-13: 978-0-470-86080-9.<br>
    <blockquote cite="mid:56F1B0F2.30407@free.fr" type="cite">On one
      hand, we have some c(i) coordinates (say of spaces: c(1)=x,
      c(2)=y, etc))
      <br>
      on which fun() depends. On the other hand, we have p(j) parameters
      on which fun() also depends.
      <br>
      As good quiet parameters, p(j) have fixed values, whereas c(i) are
      varied by leastsq().
      <br>
    </blockquote>
    <br>
    Well, I am not sure I follow you here.<br>
    I usually describe my fit functions as yfit=myfit(x,param) and try
    to find the best param to fit some experimental measurements
    {yexp,xexp}, ie such that |yexp-myfit(xexp,param)| is minimized (in
    the least square sense).<br>
    Are my xexp your p(j) and my param your c(i)?<br>
    <br>
    <blockquote cite="mid:56F1B0F2.30407@free.fr" type="cite">
      <br>
      AFAIU, Stephane's answer assumes that the x "passed" to leastqr()
      is the full set gathering {c(i)} AND {p(j)}.
      <br>
      Whereas, still afaiu, you look interested in somewhat getting the
      sensitivity of fun() with respect to each
      <br>
      parameter p(j) around the minimum value of fun({c(i)}) (parameters
      p(i) being fixed in the fun()
      <br>
      definition).
      <br>
    </blockquote>
    Nope, I don't think.<br>
    I just want, in my case, to see how much I can vary each param(i)
    without really altering the minimization of yfit-yexp.<br>
    The idea is to get grasp of how sharp is the minimization with
    respect to each param(i), in order to determine how to interpret and
    later use the param(i) given by the fit. (if
    param(1)=12.235658+/-1.0, it does not make sense to look too closely
    at the decimal part).<br>
    <br>
    This can be achieved using Jackknifing or Bootstrapping (see for
    example
    <a class="moz-txt-link-freetext" href="http://www.jstor.org/stable/2289075?seq=1#page_scan_tab_contents">http://www.jstor.org/stable/2289075?seq=1#page_scan_tab_contents</a>),
    but these methods are resource intensive.<br>
    Using dfun() and some assumptions give a way faster estimate.<br>
    <blockquote cite="mid:56F1B0F2.30407@free.fr" type="cite">Here, i
      don't think that we can speak more than about sensitivity.
      "Confidence" is not the proper term,
      <br>
      since parameters values p(j) are deterministic and fixed. They are
      not random variables.
      <br>
      To assess this sensitivity, you will need the fun() jacobian, BUT
      with respect to p(j), not wrt to c(i) !
      <br>
      <br>
      To get what you want, i could suggest to run leastsq() with
      x={c(i)} U {p(j)}
      <br>
      Then, unless the optimum is reached on a boundary, the absolute
      value of the derivative of order
      <br>
      *2* of fun() along each p(j) direction evaluated at xopt will be
      related to the "confidence interval",
      <br>
      Unless the derivative of order 2 vanishes as well... (so then of
      order 3... etc)
      <br>
    </blockquote>
    Well, that is how I understood the calculation of the confidence
    interval as described in "Least Squares Estimation".<br>
    The scaling factor depends on the kind of interval of confidence you
    choose (90,95,99%, ...).<br>
    <blockquote cite="mid:56F1B0F2.30407@free.fr" type="cite">A more
      pragmatic way to get this interval could be to evaluate fun()
      around xopt, just varying
      <br>
      (with grand()) the p(j) component of xopt you want to get the
      confidence, and measuring the
      <br>
      spread of fun()'s answers.
      <br>
    </blockquote>
    Well, I am not sure to see how to use what you propose in practice.<br>
    In particular, how do I measure the width of the spread around the
    optimum value?<br>
    It's easier with jackkniffing where this width is the sigma of the
    distribution of param(i) across the various fits.<br>
    <blockquote cite="mid:56F1B0F2.30407@free.fr" type="cite">
      <br>
      <blockquote type="cite">
        <blockquote type="cite">Could "gopt" be of some use to estimate
          the confidence intervals when the Jacobian matrix is not
          known?
          <br>
        </blockquote>
      </blockquote>
      As Stephane said, in no way.
      <br>
    </blockquote>
    Yep, I was totally wrong there...<br>
    <br>
    Thanks,<br>
    <br>
    Antoine<br>
    <blockquote cite="mid:56F1B0F2.30407@free.fr" type="cite">
      <br>
      HTH
      <br>
      Samuel
      <br>
      <br>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">

</pre>
  </body>
</html>