To quantitatively discuss the relationship between experimentally measured results and a fitted curve, is obtaining the Chi-Square value for my data relevant? By that I mean if I obtain the Chi-square value from the following figure (using the mean points) and compare it using the respective degrees of freedom (2, since i used the equation $ a/(bx+c) $ to obtain the fit) on a Chi-square table, is the resulting probability value at all relevant for discussion? Also how would I more quantitatively explain this value.

Reciprocal Curve Fitted To Experimental Data

In addition, if this strategy is not applicable to my case, could someone suggest another method of quantitatively discussing my fitted curve and data?

Here is the data table used to plot the figure: Data Table

  • $\begingroup$ The variance is estimated at each x-value? $\endgroup$
    – Glen_b
    Mar 18, 2020 at 2:25
  • $\begingroup$ Or is it based on some previously established size of error? $\endgroup$
    – Glen_b
    Mar 18, 2020 at 3:27
  • $\begingroup$ The errorbars shown in the figure represent the standard deviation for each 'set' of points. Where a 'set' would mean all data points collected during transmission % of 20, 40, 60, 80 and 100. For example, the standard deviation on the 40% transmission data is 0.62. If I am interpreting you're question correctly, could I not just square this value to obtain variance at each transmission %? $\endgroup$
    – user456654
    Mar 18, 2020 at 16:32
  • $\begingroup$ Yes. Given a model with a,b and c all being free parameters is not identifiable, how did you resolve that non-identifiability? Also how is the fitting done? Note that ordinary nonlinear least squares assumes constant spread, which you don't have, so what did you do instead? [You might consider instead looking at Recharge speed (recharge rate) rather than recharge time as your response; it might make life easier] $\endgroup$
    – Glen_b
    Mar 19, 2020 at 2:25
  • $\begingroup$ Using python (numpy package) I used .optimize.curve_fit() which uses the non-linear least squares to fit coefficients. I am unfamiliar with the necessary requirement of constant spread, can you elaborate? In addition, looking at recharge rate I assume means taking this reciprocal relationship and turning it into a linear one. If so, I have done this and fitted the curve using the linear least squares approach. Would I be able to take this fitted curve and quantitatively explain it using the chi-square approach as I reference in my original post? $\endgroup$
    – user456654
    Mar 19, 2020 at 16:32

1 Answer 1


The answer is "kind of". Many goodness of fit tests boil down to computing a test statistic which is chi-squared distributed. The most notable example is the deviance goodness of fit test for a poisson regression. In the case where the poisson regression is used to model contingency tables, then the two test statistics are the same. But, I digress. Let's discuss goodness of fit for your model.

Your data looks to be continuous, and the variance of the outcome seems to change with the conditional mean (variance of outcome gets smaller as the predictions get smaller). One possible way of assessing this model would be through a lognormal regression. However, since you posit the conditional mean is an inverse function (looks like 1/x) a gamma glm with the a canonical link function might be better. Let's simulate some data I made up.

enter image description here

I can fit a gamma regression to this data using

model = glm(y~x, family = Gamma())

Here is the predicted model in red as compared to the true conditional mean in black

enter image description here

Because we are using a glm, we can use the deviance goodness of fit test to determine how well our model fits. You are free to read up on the rationale behind the test, but I will show you how it can be computed.

d = deviance(model)
pchisq(d, df = model$df.residual, lower.tail = F)

This returns a p value. We want this value to be larger than 0.05 because the null of the deviance goodness of fit test is that the proposed model does just as well as a model which perfectly predicts the data (I'm paraphrasing and you really should look at the details). Because we fail to reject the null of this test, we can conclude our model fits the data.

Now, I'm being a bit fast and loose, not only with the deviance goodness of fit test, but also with the choice of a gamma glm. You will have to determine which likelihood is most appropriate for you given your understanding of the data generating process.

Using the data you provide...


y = c(14.62, 7.35, 11.19, 8.57, 12.19,
      7.25, 5.81, 5.96, 5.75, 6.37,
      4.75, 5.50, 5.91, 5.00, 4.34,
      4.81, 5.13, 3.63, 4.28, 4.94,
      3.47, 3.95, 3.84, 4.30, 3.44)

x = sort(rep(c(20,40,60,80,100),5))

d = tibble(x = x, y = y)

model = glm(y~x, data = d, family = Gamma())

d %>% 
  stat_summary(fun.data = function(x) mean_se(x,1.96))+
  geom_smooth(method = 'glm', method.args = list(family = Gamma()), aes(color = 'Inverse Link'), se = F)

The deviance goodness of fit test returns a large p value (essentially 1) so we conclude this model fits well (again, being fast and loose).

enter image description here

  • $\begingroup$ Fantastic explanation, I'll definitely have to read up on most terms you recited in this but this helps a lot. My only other question is that if I transform the x-axis by taking its reciprocal, the data becomes linear (as I said in my last comment). Are there any techniques that are more simplified in applying a goodness of fit test to this, now, linear model? $\endgroup$
    – user456654
    Mar 20, 2020 at 1:13
  • $\begingroup$ @NewToStats The data are linear now, but the show heterogeneity of variance. You could just do linear regression and compute R squared, but I would not do any hypothesis tests. Let me do this example with the data you've provided. Can you tell me a little more about the design of the experiment and what you are measuring (i.e. the outcome)? $\endgroup$ Mar 20, 2020 at 1:30
  • $\begingroup$ The experiment starts with the splitting of monochromatic light into the visible light spectra (i.e violet, blue, green, yellow etc.). An apparatus with a photodiode is then placed in a position such that the desired choice of spectral light shines into the 'mask'. Within the mask is a cathode and anode, photoelectrons are excited due to the material's low work function and the measurement of the stopping potential is possible. A transmission filter is then placed over the spectral light's entrance to the mask, so that 20%, 40%, 60% etc of the spectral light is able to pass through. $\endgroup$
    – user456654
    Mar 20, 2020 at 17:02
  • $\begingroup$ The 'recharge time' measurement was made as follows: The photodiode apparatus is able to 'discharge', meaning that the spectral light must then excite an amount of photoelectrons to once again reach the recorded stopping potential. The time it takes for the electrons to reach this stopping potential at each 20% increment of transmission was recorded for green spectral light. $\endgroup$
    – user456654
    Mar 20, 2020 at 17:05
  • $\begingroup$ Now that the explanation is out of the way, the 'outcome' of this section of the experiment is to support the quantum model of light. 'Do the results support the quantum model prediction that increased intensity would increase the number of photoelectrons emitted (photoelectric current) but not the energy of the photoelectrons?' The answer is obviously yes because at higher transmission percentages, the faster the the apparatus is able to come back from a discharge while still staying at the approximately similar stopping potential. $\endgroup$
    – user456654
    Mar 20, 2020 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.