Chisquare fit to multiple data sets

In summary: Additionally, you can use the Plot function to visualize your fit and compare it to the data sets. In summary, to perform a chi-squared fit to multiple data sets in Mathematica, you can use the NonlinearModelFit function and specify your model and data sets as arguments.
  • #1
CAF123
Gold Member
2,948
88
I am looking to perform a ##\chi^2## fit to more than one data set in mathematica, I just wondered how one would set this up?

Given some non-linear ansatz function ##F## depending on some parameters ##a,b,c## to describe all sets of data, i.e ##F = F_z(x,a,b,c)## I want to do a ##\chi^2## fit that will take all sets of data into account to get the best fit values of the parameters. So I just wondered how to do this in mathematica?

In the plot attached, the x argument above corresponds to the x-axis and F is the predicted value along the y axis. The upper most band of data corresponds to some value of z and the lower band of data corresponds to another value of z. a,b,c are my parameters that I would like the best estimate for. So essentially I'm looking for some simultaneous non-linear minimisation routine.

I am fairly new to mathematica so still getting to grips with it so apologies if my question is too simple from the outset.

Thanks!
 

Attachments

  • Toyexample2graph.png
    Toyexample2graph.png
    1.5 KB · Views: 485
Physics news on Phys.org
  • #2
The best way to go about this task is to use Mathematica's NonlinearModelFit function. This function allows you to fit nonlinear models to data sets. You can specify the model as a function of your parameters, then pass in your data sets as an argument. The function will then return the best fit values for each of your parameters, along with some additional useful information like the chi-squared value and the covariance matrix.Here is an example of how to use this function:model[x_,a_,b_,c_] := F[x,a,b,c]; data1 = {{x1,y1},{x2,y2},...};data2 = {{x3,y3},{x4,y4},...};fit = NonlinearModelFit[Join[data1,data2],model[x,a,b,c],{a,b,c},x];fit["BestFitParameters"]This should give you the best fit values for your parameters, as well as other useful information.
 

1. What is a Chisquare fit to multiple data sets?

A Chisquare fit to multiple data sets is a statistical method used to determine how well a set of data fits a given model. It involves calculating the difference between the observed data and the expected data based on the model, and then determining the probability that this difference is due to chance.

2. How is the Chisquare value calculated in a multiple data set analysis?

The Chisquare value is calculated by summing the squared differences between the observed data and the expected data, divided by the expected data. This is then compared to a critical value based on the degrees of freedom and the desired level of significance.

3. What is the significance level in a Chisquare fit to multiple data sets?

The significance level in a Chisquare fit to multiple data sets is the probability of obtaining a Chisquare value as extreme or more extreme than the one observed, assuming that the null hypothesis (that the data fits the model) is true. A common significance level is 0.05, meaning that there is a 5% chance of obtaining a Chisquare value as extreme or more extreme than the observed value by chance alone.

4. What is the difference between a good and a poor Chisquare fit?

A good Chisquare fit is one in which the observed data closely matches the expected data, resulting in a low Chisquare value and a high probability (typically greater than 0.05) of obtaining the observed value by chance alone. A poor Chisquare fit is one in which the observed data deviates significantly from the expected data, resulting in a high Chisquare value and a low probability (typically less than 0.05) of obtaining the observed value by chance alone.

5. How can the results of a Chisquare fit to multiple data sets be interpreted?

The results of a Chisquare fit to multiple data sets can be interpreted by comparing the calculated Chisquare value to the critical value based on the desired significance level and the degrees of freedom. If the calculated value is less than the critical value, the data can be considered to fit the model well. If the calculated value is greater than the critical value, the data is not a good fit for the model and further investigation is needed to determine the cause of the discrepancy.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • Calculus and Beyond Homework Help
Replies
6
Views
646
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
  • Programming and Computer Science
Replies
14
Views
639
  • General Math
Replies
6
Views
788
  • STEM Educators and Teaching
Replies
5
Views
663
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
8K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top