Hi Maria, It looks like dmgroup adds the errors of the grouped bins in quadrature. I believe ISIS defaults to Poisson errors upon rebinning. If you do: set_rebin_error_method(1,"quadsum"); rebin_data(1,25); and set the fit parameters to your best fit in XSPEC, do you get the same chi^2 in ISIS? Cheers, Joey On Apr 30, 2014, at 3:48 AM, María Díaz Trigo <mdiaztri_at_email.domain.hidden > Hi... > > thanks to all of you for your advice. See some details below: > > - I haven't added any systematic error > - I get the same result whether I rebin the spectra within ISIS or outside of ISIS > - For rebinning outside of ISIS I use the CIAO task dmgroup and set: > > pset dmgroup grouptype=NUM_CTS > pset dmgroup grouptypeval=25 > pset dmgroup xcolumn=channel > pset dmgroup ycolumn=counts > > - For rebinning inside ISIS I use 'rebin_data(1,25);' > - I have checked that the problem is not related to finding different local minima when fitting with XSPEC and ISIS > > Now, going to the error per bin: > > - I used get_data_counts in ISIS and I get indeed an error of sqrt(num_cts) for each value, which seems OK. > These values are also the ones that appear in the data fits file in columns grp_data and grp_stat_err. So > it seems that XSPEC doesn't take these values and calculates them in a different way, otherwise there shouldn't be any > difference... > > - So maybe the problem is how xspec interprets a file created by dmgroup: I see a column called stat_err in the file, which > is not sqrt(num_cts). I presume that xspec is adding that error to whatever error is calculated on the number of counts and > therefore the errors are bigger than they should (and consequently the chi2 smaller)... > > Does this make sense? > > Cheers, > > Maria > > From: Michael Nowak [mnowak_at_email.domain.hidden> Sent: 29 April 2014 16:54 > To: María Díaz Trigo > Cc: isis-users_at_email.domain.hidden> Subject: Re: isis-users: Chi2 calculation for rebinned spectra in ISIS > > > On Apr 29, 2014, at 5:44 AM, María Díaz Trigo <mdiaztri_at_email.domain.hidden> >> I have realised that the chi2 value for rebinned spectra is very different when calculated by ISIS and XSPEC. The chi2 is exactly the same when I use non-binned spectra, so the difference must arise with the way of calculating errors after rebinning. >> >> I am using the default fitting method (which seems to be the same for XSPEC and ISIS) and rebin the HEG spectra to have a minimum of 25 cts/bin. Before rebinning, a simple power law fit gives me a chi2 of 838.37 for 2362 dof both in ISIS and XSPEC. After rebinning, I get: >> >> XSPEC: Chi2 of 217.90 (460) >> ISIS: Chi2 of 420.46 (460) >> >> So the difference is almost a factor of two, and the parameters of the fit are also different. >> >> Do you know why am I getting such a difference? > > Hi Maria- > > We'd need a few more details, but here's where the differences can arise: > > * If you read in a spectral file into ISIS and *don't* rebin, then the error will be > whatever is in the error column of the file, and this will depend upon how you > made the file. (This is also true in ISIS if one uses define_counts to create > the data – it defaults to whatever you set the err column to be originally.) > > * The one modification to the above is that ISIS will set a lower limit on the error > via the Minimum_Stat_Err variable (which defaults to 1, *unless* you are using > my .isisrc routines, in which case I set it to 1.e-30). So, any bins with 0 counts > in them very well might be an issue, and be treated differently in ISIS vs. XSPEC. > > * If you rebin the data *within* ISIS, then it follows whatever was set by > set_rebin_error_method, which defaults to poisson == sqrt(grouped_counts), > with the caveat that Minimum_Stat_Err still applies. > > * Errors are further modified by whether or not systematic errors were set. In > ISIS, they will only be applied if you set them within the program, regardless of > what the spectral file says. > > In the end, ISIS and XSPEC should always give the same answer to several > decimal places, once we verify that things have been set up the same. > (I honestly don't remember what the defaults are for XSPEC when it comes > to errors – I think it also defaults to what's in the error column of the file, > which possibly might not be following sqrt(summed counts), depending upon > how the binned file was made.) > > Did you bin the data outside of ISIS and then read it in, or is this a case of > binning one outside for XSPEC, and one inside for ISIS? > > The ISIS function get_data_counts will retrieve the data into a structure, and > then you can just see directly what you have for the value and errors for the > data. That would likely help you figure out where any differences are coming > from. > > You can feel free to directly send me data & script, and I can help explain further > based upon what you did. > > -Mike > > > ------------------------------------------------------------------------- Dr. Joey Neilsen Einstein Postdoctoral Fellow Institute for Astrophysical Research, Boston University 725 Commonwealth Avenue, 416D Boston, MA 02215, USA Email: neilsenj_at_email.domain.hiddenWeb: people.bu.edu/neilsenj Phone: (617) 353-1533 ------------------------------------------------------------------------- ---- You received this message because you are subscribed to the isis-users list. To unsubscribe, send a message to isis-users-request_at_email.domain.hiddenwith the first line of the message as: unsubscribeReceived on Wed Apr 30 2014 - 11:49:15 EDT
This archive was generated by hypermail 2.3.0 : Fri May 02 2014 - 08:35:48 EDT