Re: CURVEFIT.PRO standard deviations? [message #30657 is a reply to message #30656] |
Mon, 13 May 2002 02:09   |
Ralf Flicker
Messages: 19 Registered: October 2001
|
Junior Member |
|
|
Andrew Noymer wrote:
>
>> You can see the discrepancy in the one-sigma lines: can someone tell
>> me what's up with the sigma returned from CURVEFIT, and how I can
>> make them conform?
>
> I'm not sure exactly what's going on, but I take an interest in this because
> I use these sorts of procedures.
>
> I fed your code into IDL and modified it so the data were also written-out.
> I then fed the points into Stata (www.stata.com).
>
> Here is what I found:
>
> LINFIT parameters, sigma, and chi-square :
> -13.7844 2.91336
> 1.32243 0.0944590
> 266.783
> CURVEFIT parameters, sigma, and chi-square :
> -13.7839 2.91333
> 0.388221 0.0277362
> 11.5993
>
> So I cfm. that the parameters are the same (for all intents and
> purposes) between the two procedures, but the ch-sq and sigma
> is different. Here's what Stata gives me:
>
> Source | SS df MS Number of obs = 25
> -------------+------------------------------ F( 1, 23) = 951.27
> Model | 11034.0003 1 11034.0003 Prob > F = 0.0000
> Residual | 266.782989 23 11.5992604 R-squared = 0.9764
> -------------+------------------------------ Adj R-squared = 0.9754
> Total | 11300.7833 24 470.86597 Root MSE = 3.4058
>
> ------------------------------------------------------------ ------------------
> v1 | Coef. Std. Err. t P>|t| [95% Conf. Interval]
> -------------+---------------------------------------------- ------------------
> var2 | 2.913364 .094459 30.84 0.000 2.717961 3.108768
> _cons | -13.78436 1.322426 -10.42 0.000 -16.52 -11.04871
> ------------------------------------------------------------ ------------------
>
> Stata's coefficient's are (of course) the same. What CURVEFIT calls
> chi-sq, Stata calls Residual MSE (mean sq. error). And it looks like
> LINFIT gives the Std. Errors of the coefficients that I would use if
> I were you. The LINFIT ch-sq is what Stata calls the Residual SSE (sum
> sq. error).
>
> I'm not sure how the CURVEFIT sigma values are calculated but I would not
> use them if I were you, without knowing exactly where they come from.
Hi Andrew
No, you're right I can't use these CURVEFIT sigma values as they
come, but I think I've found the culprit. Just for the sake of it, I
also included LMFIT in the test above, which returned exactly the
same numbers as CURVEFIT. Now, I'm very inclined to think that I
just don't understand the numbers rather than that the procedures
are doing something spurious.
A closer inspection reveals something patently absurd with the
CURVEFIT and LMFIT sigmas: they don't vary with the noise in the
data, i.e., they are always the same. This means that they must have
been normalized to the current chi-square (whoever would come up
with such an idea ought to be flogged in public). Futhermore, they
sometimes are and sometimes are not divided by the number of degrees
of freedom (as, indeed, the final value should be). So comparing the
three procedures LINFIT, CURVEFIT and LMFIT, I surmise the following
transformations that need to be applied to have them return the same
numbers (which hopefully are the "right" ones too):
LINFIT : chisq = chisq_0/nfree
CURVEFIT : sigma = sigma_0*sqrt(chisq_0)
LMFIT : chisq = chisq_0/nfree
sigma = sigma_0*sqrt(chisq)
where chisq_0 and sigma_0 denote the values returned by the
procedure, and nfree is the number of degrees of freedom,
nfree = n_elements(data)-n_elements(parameters).
One would think that they could bloody well inform you of these
seemingly arbitrary variations in normalization in the preamble of
the online help descriptions..
cheers
ralf
|
|
|