3
$\begingroup$

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.

$\endgroup$
8
  • $\begingroup$ Are you saying that you are trying to detect a trend in Inventory as the time stamp increases? Do you have data on more than 1 store? $\endgroup$
    – AdamO
    Commented Mar 13, 2018 at 19:50
  • 1
    $\begingroup$ t-test is definitely not the test you want. It sounds like maybe you want to assess the final number relative to the maximum for the day, maybe as a proportion? $\endgroup$ Commented Mar 13, 2018 at 20:26
  • $\begingroup$ @SalMangiafico Yes perhaps that might be a bit better since I'm checking up further methods now and can't find much :( what sort of method do you believe is appropriate? $\endgroup$
    – badatstats
    Commented Mar 13, 2018 at 20:29
  • $\begingroup$ @AdamO Not really a trend in inventory, but it's more that I want to see whether the Inventory for a particular ID reverts toward zero on a particular day. In my dataset I have a 4 month period and I have about 20 different IDs but I just put a short example above as to what I was after $\endgroup$
    – badatstats
    Commented Mar 13, 2018 at 20:31
  • $\begingroup$ @SalMangiafico I was wondering, regarding the proportion method you suggested would it be better if I did: (Final Inventory)/(Max Day Inventory), or would it better if instead I take the absolute value of the Inventory, and then sum the values together, and then put that in the denominator such that I now write: (Final Inventory)/(sum(abs(Inventory))) ? Sorry if this is a dumb/trivial question, I'm mostly just not sure how best to approach this problem $\endgroup$
    – badatstats
    Commented Mar 13, 2018 at 20:52

2 Answers 2

0
$\begingroup$

You are not likely to find an existing statistical procedure or rule that will correspond to your subjective judgment as to whether a particular number is '"good enough"/close enough to zero.' Rather than experimenting with different ways to calculate p-values that fit a known procedure designed for some other purpose, you would be better off defining your question further.

Perhaps you want to subjectively set a threshold for the final day's inventory such that under that threshold (or under the absolute value of that number) will be considered "close to zero" and over it, "Not close to zero."

Perhaps, as @ Sal Mangiafico suggests, you want to describe the final day's inventory as a proportion of the highest, or of the mean of all the others. Then you could define that proportion in terms of some threshold that you (again, subjectively) assign.

So far, following your lead, I have been talking about assigning labels to individual values. Note how this differs from analyzing with a T-test. In the latter, one compares the mean of one group to the mean of another, taking into account the degree of variability within each group.

And then consider what all of the above means for p-values. A p-value from a T-test would indicate the probability that such a mean difference, or one even larger, would occur purely by chance. Such a statement would have no place in a determination about an individual data point -- at least not with the way we have been exploring.

$\endgroup$
2
  • 1
    $\begingroup$ Yeah, I agree with what you (and Sal Mangiafico) are saying in that I'm approaching the problem the wrong way. I was thinking of two different ways for the proportion so I was wondering if I could get your input - which (in your opinion) do you feel is most appropriate: (Final Inventory)/(Max Day Inventory), or would it better if instead I take the absolute value of the Inventory, and then sum the values together, and then put that in the denominator such that: (Final Inventory)/(sum(abs(Inventory)))? I was thinking that if the proportion is less than 0.05 then it's close enough to 0 $\endgroup$
    – badatstats
    Commented Mar 13, 2018 at 21:29
  • $\begingroup$ Also, regarding taking the mean of all the other inventory values as you mentioned in your post, wouldn't that fail to properly take into account negative inventory numbers? (Or rather, wouldn't negative inventory numbers modify the mean such that the proportion is wrong?) $\endgroup$
    – badatstats
    Commented Mar 13, 2018 at 21:31
0
$\begingroup$

This answer summarizes comments on the question.

A t-test is definitely not the test you want.

There are a few different approaches you might consider to assess the ending inventory relative to the values for the day.

A simple approach would calculate the final inventory as proportion of the maximum inventory during the data. Since you can have negative inventories, you might use the absolute value of the day's inventories. Likewise, if you can end with a negative inventory, you might want to use the absolute value of the ending value as well.

For this approach, and the variants below, you could use an arbitrary cutoff to determine if the ending inventory is sufficiently close to zero. Or you could simply report the proportion for each day, and perhaps look at the data across days at some time later, for example, "Which days' final inventory proportion were outside the 90th percentile of days?"

It may also make sense to use the sum of the absolute values of the inventory values for the day.

Or you may want to use some other statistic to summarize the day's numbers. Like the median, or a trimmed mean. These statistics are less sensitive to outliers, like a single really high value during the day.

There's also a concept of inventory as a percent of sales. With your data, I'm not sure how would get "sales" or if this makes any sense , but it might make sense to categorize the day by the sum of the amounts of change between time stamps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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