Sorry, I asked a question similar to this yesterday but I realized I may have been wrong in my assumptions so I deleted that question and posted this new one now (I'm fairly new to stats so I'm picking things up while I do them for my work). I have a data set as given below, and I would like to know how to use a t-test (or perhaps any other more relevant test) to determine whether the end of day inventory of a particular ID is significantly different to zero based on the inventory during the day (basically, I want the inventory to 'revert' back to zero as much as possible). For example, let's say I have the following data set:
Date | Inventory
-----------------------------------------------
05-02-2010 10:00:00 | 0
05-02-2010 11:14:43 | 2000000
05-02-2010 12:20:05 | 3000000
05-02-2010 13:56:40 | 5000000
05-02-2010 14:32:19 | 4000000
05-02-2010 15:11:37 | 100
Visually, we see that although 100 is larger than zero, relative to the Inventory
during the day 100 is actually quite small, so it's "good enough"/close enough to zero.
In R
I tried to use the following code to do this:
t.test(ShopResult$Inventory, alternative = "two.sided", mu = 0)
However, this didn't work the way I wanted it to since, for example, if Inventory
changes to negative values during the day, the t-test result will give poor results. For example, let's say I have the data set as follows:
Date | Inventory
-----------------------------------------------
05-02-2010 10:00:00 | 0
05-02-2010 11:14:43 | -20
05-02-2010 12:20:05 | -80
05-02-2010 13:56:40 | 70
05-02-2010 14:32:19 | 80
05-02-2010 15:11:37 | 100
I now get the following output from R
:
t = 0.89631, df = 5, p-value = 0.4112
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
-48.25539 99.92205
sample estimates:
mean of x
25.83333
The p-value
suggests that this data is good since it is larger than 0.05
, however, these results are the opposite of what I want. Similarly if I use the t.test
function for the first data set I get the following results for it:
t = 2.767, df = 5, p-value = 0.0395
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
165668.8 4501031.2
sample estimates:
mean of x
2333350
These results are again the opposite of what I want.
Is there a better way I can model this or implement this in R? Is a t-test even appropriate to use or should I use a different test? Thanks in advance.