We have 10 years of data and Monday is the busiest (most visits to the hospital) on average. If we wanted to assess whether that is true and report a p-value, what is the appropriate statistic?

We believe the answer is chi-square as we found a peer-reviewed medical article from the Annals of Emergency Medicine (highest circulating journal for that specialty) that used chi-square for this very calculation.

If chi-square is appropriate, what values do we use for observed and expected values for chi-square? One approach would be to list all the values for Monday as observed values, or all the means for Mondays averaged across a month, or all the means for Mondays averaged across a year.

If there were no busiest or least busy days, we would assume that the visits would be the same every day of the week. That means our "expected values" for Chi-Square would be the mean of the visits for any given week.

  • $\begingroup$ Odd things get published so something having been used in a published paper may not be the best criterion to pick what to do. It would probably help if you told people how you measure "busy". Is it e.g. number of visitors, cars on the road or clicks on a website? Or litres of coffee consumed in a canteen? Or Internet traffic volume in MB? An answer probably depends on that. $\endgroup$ – Björn Jan 24 '16 at 8:09
  • $\begingroup$ Related question here. $\endgroup$ – Richard Hardy Jan 24 '16 at 14:22

Before asking what the appropriate statistic is, you need a model. Perhaps the simplest model to facilitate a test could be

$$ y_t = \beta_0 + \gamma_1 Monday_t + \varepsilon_t $$

where $y_t$ is the number of visits on day $t$, $Monday_t$ is a dummy variable that is unity of Mondays and zero on all other days, and $\varepsilon_t$ is an $i.i.d.$ random noise. The model says that the number of visits to the hospital is $i.i.d.$ except for a level shift on Mondays. You could test a null hypothesis $\text{H}_0: \gamma_1=0$ using a $t$-test, and you would be happy to reject the null.

(If I am not mistaken, squaring the $t$-test statistic would make it have a $\chi^2$ distribution under the null, so you could formulate the same idea in terms of a $\chi^2$ test.)

However, the number of visits may have more structure to it. Perhaps there are other seasonal effects (time of year, holidays, etc.). Perhaps there are some other factors (regressors $x_{i,t}$) affecting the number of visits.

To find a satisfactory answer to your question, you need a good model (that well describes the number of visits) which allows for a Monday effect so that you could test whether it is zero or not.

| cite | improve this answer | |
  • $\begingroup$ Thank you for the thoughts. When you say we "need a good model...in which there IS a Monday effect"...don't we actually need a model in which there is no Monday effect? Our hypothesis is that there is no Monday effect - but it is our that observations reject it. Wouldn't it then follow that the values we would place in a test like Chi-Square for "expected values" is our model - and that model would put values in there that show no Monday variation. Then our observations would deviate from that. So in sum, doesn't that mean we need a model without a Monday effect? $\endgroup$ – Praxiteles Jan 24 '16 at 11:50
  • $\begingroup$ I presented a way of testing in a regression setting; you would not use "expected values" or the like here, just the significance of $\gamma_1$. Now within the regression setting, the clean way of testing for presence of Monday effect is including it into the model and testing its relevance: the null hypothesis $\gamma_1=0$ ("no Monday effect") is just what you need. If the effect is not included, you cannot test whether it should be there. You might have some different framework in mind, I am not sure. $\endgroup$ – Richard Hardy Jan 24 '16 at 11:59
  • $\begingroup$ @Praxiteles, I was going through my old answers and noticed this one was not accepted. Do you perhaps need further clarification? $\endgroup$ – Richard Hardy Feb 12 '17 at 10:58

My suggestion would be to run a goodness-of-fit (GOF) chi square test - as you initially suggested, followed by pairwise comparisons between weekdays, applying the Bonferroni correction.

  1. Goodness-of-fit test:

If we pretend the following data to be the average number of visits per day of the week observed:

week <- c(Mon = 401, Tue = 199, Wed = 187, Thur = 202, Fri = 240, Sat = 212, Sun = 244)

We can calculate the expected to follow a uniform distribution, where the daily frequency of visits is $1/7$ of the weekly total:

names(week) <- NULL
observed <- week
expected <- rep(1/length(week), length(week))

And we run the test:

    chisq.test(week, p = expected)

The result is highly significant:

    Chi-squared test for given probabilities

data:  week
X-squared = 135.6439, df = 6, p-value < 2.2e-16
  1. Pairwise comparisons:

This poses a significant problem. If it were only three groups it would be more straightforward, as in this post, but with seven days the pairwise comparisons will amount to ${7 \choose 2} = 21.$ The Bonferroni correction with an initial risk alpha of $0.05$ would be $0.002380952$.

We can run a loop:

mat <- combn(1:length(observed),2)
vec <- apply(mat, 2, function(x) chisq.test(observed[x], p=rep(1/2,2))$p.value)
mat[,c(vec < (0.05/(choose(length(observed), 2))))]

And the output in this case will always include $1$, which is Monday - I set it up so that it was the only pairwise comparison with a "significant" p value.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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