# Compare previous month to all other previous months performance

Let's say it's Feb 1st, 2016 and I'm asking the question "Are my results in Jan 2016 statistically different from the results I've seen in the past 11 months."

For example, how statistically different are the results from the Shopping column data from January's result (106).

        Month  Branded  Non-Branded  Shopping  Grand Total
0    2/1/2015     1330          334       161         1825
1    3/1/2015     1344          293       197         1834
2    4/1/2015      899          181       190         1270
3    5/1/2015      939          208       154         1301
4    6/1/2015     1119          238       179         1536
5    7/1/2015      859          238       170         1267
6    8/1/2015      996          340       183         1519
7    9/1/2015     1138          381       172         1691
8   10/1/2015     1093          395       176         1664
9   11/1/2015     1491          426       199         2116
10  12/1/2015     1539          530       156         2225


Jan 2016 data looks like this:

       Month  Branded  Non-Branded  Shopping  Grand Total
11  1/1/2016     1064          408       106         1578


Questions I have

1. Is a Z-score formula appropriate for this?
2. Is this a hypothesis test?
3. Is a T-test more appropriate?
4. Since I'm comparing one sample to 11 others, what is the right statistical procedure?
5. Does it make a different that this data has a time component to it?
• Two questions: 1) is the data seasonally adjusted? 2) if not, why not compare January of 2016 to January of 2015? Commented Feb 29, 2016 at 4:24
• Data is not seasonally adjusted. The above is raw data. Comparing year-over-year is not what I'm interested in because a lot happens in a years time that makes last years result not relevant to this years result. To be clear, I'm interested in the general concept here of comparing performance for one period to previous periods. I don't want to get hung up on or stuck in talking about days, weeks, months, quarters, or years because the same technique should be applicable (I'm guessing) to other time periods, no? Commented Feb 29, 2016 at 4:32

1. Z test is generally used when sample size is more than 30.So it's not recommended to use it in this particular case.
2. Yes. This is a hypothesis test. Where null hypothesis is "There is no significant difference between shopping in February-December and January"
3. t-test is more appropriate. For more details you can read this answer : Power of the t-test under unequal sample sizes
4. Yes. As explained in point 3.
5. I don't think so. As samples are assumed to be independent.

You can use t-test. Here is the result I got :

    > Feb_to_December <- c(161,197,190,154,179,170,183,172,176,199,156)
> Jan <- c(106)
> t.test(Feb_to_December,Jan, var.equal=T)$p.value [1] 0.001453977  So there is significant difference between February to December shopping and January shopping. • I use Python ans scipy. For point 3 - the actual computation - I see your R code does the calculation, but the equivalent function in scipy (ttest_ind) mentions the arrays must have the same shape. For the Shopping columns, we have an array of 11, then a single value (or, an array of 1). I'm not clear on how to compute a ttest with different shapes. Any idea? Commented Mar 1, 2016 at 16:40 • And of course, after I comment, I think I find the solution. This blog post has a good example of using ttest_1samp which is what I think I want. stats.ttest_1samp(df[4], df1[4][0]) Commented Mar 1, 2016 at 16:44 I always favor simplicity over something complex. So, assuming your responses are independent, I'd just pool the data for 11 months that you want to compare to January 2016 and calculate a grand mean. Then compute an independent samples t-test, testing$H_0:\bar{y}_{diff}=\bar{y}_{Jan}-\bar{y}_{Feb-Dec}=0\$. If you are just concerned with testing that January is different than the other months, then you don't really need to worry about the time component. The Z and T-tests would be nearly the same here given your sample sizes.

Carry the test out for the variable you are interested in testing. You could also perform a Hotelling's T-diff test as well if you want to check all the variables simultaneously rather than one by one.