I am currently trying to model the amount of people coming to a hospital with a suspicion of some particular disease within period with 0.5 year window.

I plotted the data in the form of cumulative function (summing up these amount of people) and as a result some particular linear regression fits this data really well. By eye.

The problem is: cumulative plot is a monotonically increasing function, same as my linear regression fit. Therefore looking at the correlation doesn't make sense, it's obviously close to 1. Other standard test are probably also not very appropriate.

What would you suggest to assess goodness-of-fit when approximating such cumulative function?

I've also found "gvlma" package in R which perform the Assessment of the Linear Model Assumption. For 4 out of 5 characteristics (Global Stat, Skewness, Kurtosis, Heteroscedasticity) assumption was acceptable, while for last (Link Function) assumption was not satisfied. Does anybody know what it means?


  • 4
    $\begingroup$ The best answers will suggest you don't do this: OLS is inappropriate for the fit and the correlation tells you little if anything. If you want to estimate a distribution, there are myriad better ways to do it, ranging from kernel density estimates through maximum likelihood. $\endgroup$
    – whuber
    Dec 16, 2016 at 21:21
  • $\begingroup$ What is the global stat characteristic? $\endgroup$
    – Galen
    Jul 15, 2021 at 18:46

2 Answers 2


I have a similar problem, and I was thinking that the fairer assessment of fit would be to use the difference function for both the actual number of people and the model - that is, comparing the number of people within some length of time with the predicted number of people within that length of time, over the whole time period. The derivative of the line you fit, and the "derivative" of the raw (not cumulative) data.

If your cumulative data starts with 0,2,3,6,6,7,12..., then convert this to a difference function ("derivative"), i.e. 0,2,1,3,0,1,5... - the number of people arriving in each time step. The line you fit has some slope over the same time step - maybe 2, let's say. Then compare the deviations between the two series 0,2,1,3,0,1,5,... and 2,2,2,2,2,2,2,...

  • $\begingroup$ What do you mean by "The derivative of the line you fit, and the "derivative" of the raw (not cumulative) data."? $\endgroup$
    – utobi
    Nov 27, 2016 at 7:25
  • $\begingroup$ @utobi Means likely the pdf theoretical and the pmf data. However, if the CDF data is linear over a segment, we know that does not generalize as CDF's are sigmoidal. It would be another thing if one plotted CDF theoretical against CDF observed parametrically, but it is not clear that was done in OPs question. $\endgroup$
    – Carl
    Nov 29, 2016 at 3:43
  • $\begingroup$ @user140136 I think that is a great approach. You can make the time window very small if desired. I think of cumulative frequencies as something you get after modeling. For example if using a binary logistic model the expected number of arrivals over any window is the sum of all the small-cell probabilities. The problem can also be dealt with using inter-arrival gap times. $\endgroup$ Mar 17 at 12:19

The OP asks what the link function means. This is actually probably not that important, but, lets get that out of the way first, following which we will answer what the OP needs to see.

1) I did not readily find link function documentation in R. In glm Stata the documentation for a link function probably refers to the same thing. That would be beginning on page 5 of that document

enter image description here

This continues on page 6 so it is worth reading more. Your next question is "What does it mean?" if the link function assumption was not satisfied, and that may be that you need a different link function, or to do the regression in some other way, but it is hard for me to be sure as I use neither R nor Stata, and you did not show enough work for me to know (but maybe someone else does).

2) The above, as pointed out by @whuber, is largely irrelevant. For correlation, it's square, $R^2$ would be the explained fraction within the region of fit from min to max of fitting. It is not useful as it only speaks to how well the CDF of the data and CDF regression model fit in that region.

What is important to note is that admissions to hospital are likely a Poisson process. What needs to be done is to A) plot admissions every half-year to see whatever trend there is in that model, i.e., that is a density function, and not a cumulative density function. Of course one could use a kernel density smooth, but that would complicate things. B) Find a model that fits the time based data. For example, there may be more admissions at certain times of the year so that there may be some periodicity to the half-year data which can be treated in one of two ways, I) One can model the periodicity with ARIMA or II) One can reformat the data into annual admissions to avoid the problem. In either case we should treat the data using a noise function consistent $L_2$ norm for minimization, see below. Then C) some trending model needs to be fit, and the selection process for that can be complicated. In short, lots of functions should be tried but they should all be done with good theoretical reasons for choosing them, and they should fit really well, except for noise. How to find that model is also related to how one does the regression as well, which brings us to the next consideration. The next D) thing is to measure how much noise there is and how much modelling error there is. For a Poisson process, the square root of the admissions per half-year, plotted in time is an image for which the noise and model misregistration can be measured as correlated variables (and they tend to be correlated).

A Poisson consistent minimized norm is ${\mathrm{Min}}_{\mathrm{fit}}= \min \left\Vert \sqrt{\mathrm{data}\left({t}_i\right)}-S\ \frac{\mathrm{pdf}\left({t}_i-{t}_A\right)}{\sqrt{\mathrm{data}\left({t}_i\right)}}\right\Vert,$ where $S$ is the scale factor between the density function found (using much elbow grease), and the data amplitude. In some cases, and likely in yours, the best model may not be a density function, in which case the minimized ($L_2$) norm simplifies to ${\mathrm{Min}}_{\mathrm{fit}}= \min \left\Vert \sqrt{\mathrm{data}\left({t}_i\right)}- \frac{f\left({t}_i-{t}_A\right)}{\sqrt{\mathrm{data}\left({t}_i\right)}}\right\Vert.$

To show what this can mean, let us cite a paper published yesterday under creative commons license. As the image below shows, a pdf was fit to time series data at one minute per data point from a Poisson process. The misregistration of the models was only 0.80% with total fit errors of 1.44%. One can also calculate an $R^2$ value and see the paper for examples, however, $R^2$ alone will not tell us how much error is from modelling, and how much is noise. Finally, how much time should elapse between binned samples will change both the noise and the misregistration so there is an optimum time interval to use for data processing.

enter image description here

  • 1
    $\begingroup$ You seem to have become distracted by the mention of a link function in the question. Your answer does not appear to have anything to do with the question, which concerns fitting an empirical CDF and the issues related to the (extremely high) dependence among the points on that plot. $\endgroup$
    – whuber
    Dec 16, 2016 at 21:19
  • $\begingroup$ @whuber True enough, it would seem. Using jargon without explaining it sent me off on a tangent. I do wish people wouldn't do that. $\endgroup$
    – Carl
    Dec 16, 2016 at 22:33
  • 2
    $\begingroup$ What makes CV different from most, if not all, other SE sites is that we typically need to work hard to make sense of questions and to help their posters improve them to the point they are not confusing. That seems to be an essential part of statistics. I would encourage you to read all questions critically and if they leave anything in doubt, to use our commenting facility to elicit clarification about the question. Otherwise you can waste time and energy producing an answer that might turn out to be irrelevant (or worse, misleading). $\endgroup$
    – whuber
    Dec 16, 2016 at 23:13

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.