I wish to perform goodness of fit. Currently I use NonLinearModelFit :
nlmSimple =
NonlinearModelFit[data, model, {{a, 20000}, {k1, 300}, {b, 20000}}, t, Weights -> 1/dataErr^2, VarianceEstimatorFunction -> (1 &)];
with $data = \{\{x_1, y_1\},...,\{x_n,y_n\}\}$ and $dataErr = \{w_1,...,w_n\}$. $w_n$ is the standard deviation follow by the $n-th$ distribution (asssume to be a normal distribution) in which $y_n$ is picked up. So each data point is pick up in distribution with different width. This is working fine but I would like to get a Chi Square test (or equivalent, I am "use" to Chi square but I know there are other goodness test, so I am open to any proposal) for the overall goodness of the fit.
I use function from here Performing a chi-square goodness of fit test. I added the degree of Freedom :
pearsonTest[obs_, exp_, dof_] /; Length[obs] == Length[exp] :=
Block[{t}, t = Total[(obs - exp)^2/exp] // N;
{t/(Length[exp] - dof),
SurvivalFunction[ChiSquareDistribution[Length[exp] - dof], t]}];
with $obs = \{y_1,...,y_n\}$ and $exp= \{model[x_1],...,model[x_n]\} $ But this does not take into account the standard deviation of $y_n$ and will output the same $\chi^2$ for any set of $w_n$. $model$ is a function than can be anything from simple exponential to "complicated" function with plenty of parameters.
So my question : does NonLinearMdelFit include some build-in tool for the overall fit's goodness I can use (I used the property of fitted model but this is only for parameters error)? And if no, how to add weighted data in a Pearson test (so this is more a mathematical problem).