title: Nonlinear fits in Octave
body: <p>currently I'm using <code>nonlin_curvefit</code> function from GNU Octave's 'optim' package to fit data with . But this time I did also need the uncertainty of the returned parameters to determine the quality of the fit. After reading through the documentation I tied using the function <code>curvefit_stat</code>. 
  However whenever I alwas get errors using this functiona and I can't make any sense of the error message. I'm using Octave 4.2.2 from Ubuntu 18.04's default repository. </p>
  
  <p>Standalone minimal example and error messages below. Startparameters <code>init_cvg</code> usually produces good result, while using <code>init_dvg</code> usually results in poor fits:</p>
  
  <pre><code>1;
  
  x = linspace(-2*pi, 2*pi, 600);
  ydata = 3.4*sin(1.6*x) + rand(size(x))*1.3;
  
  f = @(p, x) p(1)*sin(p(2).*x);
  function y  = testfun(p ,x)
    y = p(1).*sin(p(2).*x);
  endfunction
  
  init_cvg = [1; 1.1];
  init_dvg = [1; 1.0];
  
  [pc, mod_valc, cvgc, outpc] = nonlin_curvefit(f, init_cvg, x, ydata);
  [pd, mod_vald, cvgd, outpd] = nonlin_curvefit(f, init_dvg, x, ydata);
  
  
  hold off
  plot(x, yd, "b.");
  hold on;
  plot(x, mod_valc, "r-");
  plot(x, mod_vald, "color", [0.9 0.4 0.3]);
  
  settings = optimset("ret_covp", true);
  covpc = curvefit_stat(f, pc, x, ydata, settings);
  covpd = curvefit_stat(f, pd, x, ydata, settings);
  
  puts("sqrt(diag(covpc))")
  sqrt(diag(covpc))
  
  puts("sqrt(diag(covpd))")
  sqrt(diag(covpd))
  </code></pre>
  
  <p>The first error message occurs when I use <code>f</code> as a model function, the second occurs when I use <code>testfun</code> instead:</p>
  
  <blockquote>
  <pre><code>&gt;&gt; curvefit_stat_TEST
  error: label of objective function must be specified
  error: called from
      __residmin_stat__ at line 566 column 7
      curvefit_stat at line 56 column 7
      curvefit_stat_TEST at line 25 column 7
  &gt;&gt; curvefit_stat_TEST
  error: 'p' undefined near line 8 column 7
  error: called from
      testfun at line 8 column 5
      curvefit_stat_TEST at line 25 column 7
  &gt;&gt;
  </code></pre>
  </blockquote>
  
  <p>Could somebody confirm this error ?</p>
  
  <p>I would appreciate any help.</p>