Skip to main content
added 197 characters in body
Source Link
Glen_b
  • 290.5k
  • 37
  • 652
  • 1.1k

In cases where your expected values in some cell or cells may be small (on the order of 1 or 2, say), Yates' continuity correction can help somewhat with improving the chi-square approximation.

[In your example where A and B only occur 15 times together and A only occurs 25 times, the expecteds might be a bit too small to apply the chi-square approximation.]

[In your example where A and B only occur 15 times together and A only occurs 25 times, the expecteds might be a bit too small to apply the chi-square approximation.]

In cases where your expected values in some cell or cells may be small (on the order of 1 or 2, say), Yates' continuity correction can help somewhat with improving the chi-square approximation.

[In your example where A and B only occur 15 times together and A only occurs 25 times, the expecteds might be a bit too small to apply the chi-square approximation.]

added 1088 characters in body
Source Link
Glen_b
  • 290.5k
  • 37
  • 652
  • 1.1k

In that case we can use a test for independence. The most commonly used one is the chi-squared testchi-squared test, though I mention some other possibilities later.

$\dagger$ [This may be too strong an assumption, in which case some alternative analysis that deal with the time dependence needs to be used]


1 occurs 250 times in the year, and the other event occurs 50 times in a year. The second event occurs every single day the first event occurred. Can I say that there is a relationship between the two events?

Let's cast this in the above framework. Given a 365 day year, it's possible to work out every combination from that information (it takes a little thinking but you can get there):

                (not-B)   (B)       Tot
                 Y=0      Y=1     
(not-A) X=0      115        0       115
  (A)   X=1      200       50       250
 
Tot.             315       50       365

This yields a chi-square of around 25.0 or 26.7 depending on whether a continuity correction is applied, which (unless you had chosen an incredibly small significance level to start with) would lead to rejection of the null of no association between occurrence of A and occurrence of B.

[In your example where A and B only occur 15 times together and A only occurs 25 times, the expecteds might be a bit too small to apply the chi-square approximation.]

In that case we can use a test for independence. The most commonly used one is the chi-squared test.

$\dagger$ [This may be too strong an assumption, in which case some alternative analysis that deal with the time dependence needs to be used]

In that case we can use a test for independence. The most commonly used one is the chi-squared test, though I mention some other possibilities later.

$\dagger$ [This may be too strong an assumption, in which case some alternative analysis that deal with the time dependence needs to be used]


1 occurs 250 times in the year, and the other event occurs 50 times in a year. The second event occurs every single day the first event occurred. Can I say that there is a relationship between the two events?

Let's cast this in the above framework. Given a 365 day year, it's possible to work out every combination from that information (it takes a little thinking but you can get there):

                (not-B)   (B)       Tot
                 Y=0      Y=1     
(not-A) X=0      115        0       115
  (A)   X=1      200       50       250
 
Tot.             315       50       365

This yields a chi-square of around 25.0 or 26.7 depending on whether a continuity correction is applied, which (unless you had chosen an incredibly small significance level to start with) would lead to rejection of the null of no association between occurrence of A and occurrence of B.

[In your example where A and B only occur 15 times together and A only occurs 25 times, the expecteds might be a bit too small to apply the chi-square approximation.]

Source Link
Glen_b
  • 290.5k
  • 37
  • 652
  • 1.1k

In respect of a single day, day $i$, consider the four compound events:

  1. A occurred and B occurred.
  2. A occurred and B did not.
  3. A didn't occur and B did.
  4. Neither A nor B occurred.

For each day, one of those four situations occurs.

Knowledge of all four can be used to decide whether the occurrence of A and B are dependent (either positively related or negatively).

To clarify notation, let $X_i=1$ if $A$ occurs on day $i$ and $=0$ otherwise. Let $Y_i=1$ if $B$ occurs on day $i$ and $=0$ otherwise.

If we further assume that there's independence across days -- that $P(X_i=1|X_j=1)=P(X_i|X_j=0)$ for all $j\neq i$, and similarly for conditioning on $Y_j$ and for conditioning on combinations of $X_j$ and $Y_k$.$^\dagger$

In that case we can use a test for independence. The most commonly used one is the chi-squared test.

Let $Z_{lm}(i)=1$ if $X_i=l$ and $Y_i=m$ for $l=(0,1)$ and $m=(0,1)$.

That is, let $Z_{00}(i)=1$ if $X_i=0$ and $Y_i=0$, and so on.

Further, let $O(l,m) = \sum_i Z_{lm}(i)$, so that the $O$ values represent the counts of how often each combination of A or not-A co-occurs with B or not-B

Then construct a contingency table:

               (not-B)    (B)
                 Y=0      Y=1     
(not-A) X=0     O(0,0)  O(0,1)
  (A)   X=1     O(1,0)  O(1,1)

Then this data is in suitable form for a chi-square, or a G-test or a Fisher-Irwin test (of which the chi-square is the best-known). An alternative would be a two-sample proportions test (say as a Z-test).

$\dagger$ [This may be too strong an assumption, in which case some alternative analysis that deal with the time dependence needs to be used]