# Tips and tricks in fitting

- You know your sample and therefore what models may be appropriate.
- Consult the fitting programs documentation carefully to check if the model is appropriate
- Start by the simplest possible model, then increase complexity only if the simpler model cannot fit your data. E.g. if you can fit the data with a sphere, do not try a polydipserse core-shell particles with interparticle repulsion (this is called
*overfitting*you data). Start simple, and increase complexity only if you need.

**Choosing a model**

- Start by plugging in resonable values for the parameter (if you have an idea)
- You may get an idea about the size from primary data analysis.
- If you do not know you $\mathrm{SLD}$ values, set the $\mathrm{SLD}$ of the solvent to 0, and the $\mathrm{SLD}$ of your sample to unity. Do not fit these if you fit an overall scaling.
- If you have multiple $\mathrm{SLD}$ values in your particle, you need an estimate of these.
- Compute (do not fit yet) your model and compare with your data.
- Adjust scaling and background manually to reasonable values.
- Adjust model parameters to reasonable values. As a rule of thumb, you can move features of the scattering pattern (such as characteristic minima) to lower $q$ by increasing the size of you particle, vice versa.
- Consult the model documentation for understanding all the model parameters. If you do not know your model you may get unrealistic results (these may fit your data well, but are nonsense).
- You should try to manually vary the parameters and compute the model to understand the effect on the scattering curve.

**Before you press Fit**

- When your calculated curve is not too far from the data, it is time to fit the data.
- Try to fix most parameters to begin with and fit one or two at a time, then iteratively release more parameters.
- In the end, you can release all
*non-correlated*parameters (see below) and refine these.

**Fitting the data**

- Two parameters are (partly) correlated if a change of the scattering curve induced by changing one of these parameters can be (partly) cancelled by changing the value of the other parameter.
- If you fit correlated parameters simultanaously, you will observe high uncertainties on the parameters values.
- The $\mathrm{SLD}$ values are generally correlated (due to Babinet's prinicle). That is, you can fit the data equally well with different combinations of $\mathrm{SLD}$ for the particle and $\mathrm{SLD}$ for the solvent - as long as the contrasts (differene) is unchanged.
- The$\mathrm{SLD}$ values are also correlated with the scaling parameter (if used) - so generally you should not fit both (but you may fit the ratio between $\mathrm{SLD}$s in a sample with multiple $\mathrm{SLD}$ values, e.g. core-shell particles).
- Consequently, if you fit multiple $\mathrm{SLD}$ values (and scaling), you will observe large uncertainties on these parameters (example).
- To prevent correlation, you can restrict the fit by
*fixing parameters*(not fitting them).

**Correlated parameters**

- Does the fit look resonable - i.e. does the fitted curve go through the data points, within the errors. Is the fit good in the whole $q$-range?
- Is the $\chi^2$ close to unity? This is a measure for the goodness of fit.
- Does the residuals look alright, or are there visible systematic deviations?
- Are the fitted values in the expected range? For the simulated data you know the answer, but in an experiment these are not known. However, you will usually have some idea about what values are "reasonable".

**Assessing if a fit is good**