# One sample t-test with Groups?

I wish to find the mean dollar value in my data while properly accounting for different groups.

Say for example I have a set of data as follows:

Customer  |      Date      |   Dollar Value
-------------------------------------------
A       |   05/03/2016   |     50
B       |   05/03/2016   |     3
C       |   05/03/2016   |     40
A       |   06/03/2016   |     80000
B       |   06/03/2016   |     50
C       |   06/03/2016   |     60000
A       |   07/03/2016   |     60
B       |   07/03/2016   |     2
C       |   07/03/2016   |     50


(Please note that this is only a small example subset of the data I'm looking at, the actual data has thousands of rows of data).

From this data, the 'normal' days are 05/03/2016 and 07/03/2016 while the abnormal day is 06/03/2016 since the dollar value for each customer is very high relative to what they normally purchase. In addition, Customer B always purchases a smaller amount relative to Customers A and C.

Now, what I would like to do is find the average dollar value (i.e. obtain a single value by using the Dollar Value column) and determine its significance while properly accounting for the customer and date (since specific dates and specific customers would greatly skew the mean as shown above), however, I'm not sure what sort of t-test I need to conduct in order to obtain this value. I was thinking of using something like clustering standard errors based on Customer and Date but I'm not sure if that's appropriate or how to even set this problem out, so any help would be greatly appreciated, thanks!

• Putting aside the specifics of groups and dates, you do not have very much data which is going to make everything difficult. Moreover, when you split the already-small data into groups and ask for meaningful analysis, that's a very tall order. Jan 6, 2020 at 3:34
• @ebb-earl-co Sorry, I should note that this is only a very small example subset, I actually have over a hundred thousand rows of data, I'll edit my original post with this information Jan 6, 2020 at 3:44
• Ah, good to hear. Then I'll echo what Demetri Pananos below said. Jan 6, 2020 at 3:49

I think your question is incomplete. You write that you are interested in "[the dollar value] significance while properly accounting for the customer and date" but you haven't specified a particular hypothesis.

Are you interested in seeing if there are differences between customers?

Are you interested in assessing date effects?

Are you interested in seeing if the variables themselves offer anything in terms of explaining variance observed?

I think once we understand precisely what it is you are interested in, then we can help.

• I suppose it is a bit of a dumb question, but I was basically wondering if there was a way to find the mean of the dollar value such that skews in the data will be properly weighted/accounted for. For example, on some days the average dollar value might be very high (thereby greatly skewing the data) so I may want less of a weighting on this day. Things like that basically, but I'm not sure how to go about doing it especially since I have so much data etc. But you could be right, I may need to rethink what I'm actually trying to do... Jan 6, 2020 at 4:00
• Perhaps a one sided t-test where I first compute the mean of the Dollar value and then I compare the values in the Dollar value column clustering by Customer and Date? Is such a thing possible? Jan 6, 2020 at 4:03
• @ImNotSureAboutStats Before I can comment on possible methodology, you will need to to phrase your question as a statistical hypothesis. If you are interested in the mean dollar value conditioned on day and customer, this suggests a regression of some sort. However, you need to be more precise about what you want. Jan 6, 2020 at 5:18
• I suppose a regression as you suggested could work, since what you mentioned is basically what I'm after. What sort of equation would be appropriate though? I'm not too sure how to go about conditioning in a regression. Thanks a lot for the help by the way! Jan 6, 2020 at 23:56
• @ImNotSureAboutStats I would start with a linear regression, check model assumptions, and work from there. Jan 7, 2020 at 0:44