Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equivalent width uncertainties #122

Open
alexji opened this issue Jun 14, 2016 · 9 comments
Open

Equivalent width uncertainties #122

alexji opened this issue Jun 14, 2016 · 9 comments
Assignees
Milestone

Comments

@alexji
Copy link
Collaborator

alexji commented Jun 14, 2016

When the equivalent width uncertainties are large, the uncertainty changes significantly every time you refit the same line. It's especially bad for degree 2 or higher continuum polynomials. I think this is due to insufficient samples from the covariance posterior?

@andycasey
Copy link
Owner

This is probably the correct behaviour, but it might be worth providing an example for me to check.

We're just optimizing the model (profile) parameters so we don't have a formal posterior on any parameter. The covariance matrix is estimated at fitting time by multiplying the residual variance of the fit with the Jacobian, so it's a good estimate of the formal fitting errors but is probably underestimated. If the EW is very large and the EW uncertainty is ~10-20% then the uncertainty value will change a lot with repeated fits. And with a high degree polynomial there's more flexibility to account for crazy things in the data (e.g., nearby strong lines) so I could imagine it gives large uncertainties until things are well-fit.

I don't know if any of that helps explain the particular example you saw. Is it worth posting an example of a line?

@alexji
Copy link
Collaborator Author

alexji commented Jun 15, 2016

Yes, I think it happens when the EW uncertainty becomes O(10%) though I did not test that rigorously.

Here's an example, all I did here was push "Fit One" twice (i.e. call spectral_model.fit() twice). The uncertainty changes between 6 mA to 8.5 mA (there is a small visual effect in the plot as well). This is large enough that it could affect weighted stellar parameter fits depending on what value you draw.

screen shot 2016-06-14 at 11 05 13 pm

screen shot 2016-06-14 at 11 05 05 pm

@andycasey
Copy link
Owner

Interesting!

Can you save the session (or just the normalized spectrum) and post a link here so I can investigate?

@alexji
Copy link
Collaborator Author

alexji commented Jun 15, 2016

Here's a link:
https://www.dropbox.com/s/q7ycaiouii05n9b/test.smh?dl=0

Fitting some more, it turns out the numbers I said turn out to be the two extremes. Most of the time it gets 7.something.

@alexji
Copy link
Collaborator Author

alexji commented Aug 12, 2017

@andycasey this is still happening a lot. The reason appears to be that the EW uncertainty is estimated by taking 100 samples from the covariance matrix and integrating 100 times. It is also actually calculating a 2 sigma (95 percentile) error by default, rather than a 1 sigma (68 percentile). When the fit uncertainty is large, this is quite unstable.

I think it's probably more correct to calculate a 68 percentile when doing weighted minimization of the stellar parameter slopes, right? That should also improve the stability.
We can also create a session setting for the number of covariance draws.
This will apply to both profile and synthesis models.

[This is a separate issue from having too-small fitting error when fitting strong lines in blended regions; that still exists and is a bigger problem for high S/N data.]

@alexji alexji modified the milestone: v0.2 Aug 13, 2017
@alexji alexji closed this as completed in 5c701fc Aug 13, 2017
alexji added a commit that referenced this issue Aug 13, 2017
@alexji
Copy link
Collaborator Author

alexji commented Aug 13, 2017

I have made it so the EW uncertainty is 68 percentile and that you can modify this and the number of draws in the smh defaults file. However, for low S/N (~20-30), I have found that you need REALLY large numbers (>1e6) of draws in order to get an EW to within ~0.1 mA.

I'm not totally sure what to do here; maybe this is good enough for the interactive part, and final errors can be reported with a full covariance sampling? Or perhaps it's better to use a deterministic formula to calculate this even if it slightly underestimates the error during the interactive part?

@alexji alexji reopened this Aug 13, 2017
@andycasey
Copy link
Owner

andycasey commented Aug 13, 2017 via email

@alexji
Copy link
Collaborator Author

alexji commented Aug 15, 2017

That sounds like a good idea.

@alexji
Copy link
Collaborator Author

alexji commented Sep 9, 2017

After some more searching, I have found that Chris Churchhill's thesis gives a good description of how to calculate this analytically.
http://astronomy.nmsu.edu/cwc/Research/thesis/Pages/ch2.html
In particular the appendix of Sembach and Savage 1992 gives the best treatment of EQW errors I have yet seen.
http://adsabs.harvard.edu/abs/1992ApJS...83..147S

Since we calculate the EQW by integrating an analytic profile, it might be best to redo the calculation and implement that. At least for fitting profiles, I think this will be much better than randomly sampling the covariance matrix.

One thing is that we should consider moving from a simple polynomial basis to a Legendre (or other finite-domain) polynomial basis for the continuum, both for profiles and synthesis. The main benefit is this gives better coefficient stability as you increase the order, and probably better covariances as well. The more fancy numpy polynomial fitting does this automatically.

@alexji alexji mentioned this issue Sep 10, 2017
8 tasks
@alexji alexji modified the milestones: v0.2, v0.3 Jul 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants