0
$\begingroup$

I'm trying to understand what is the right way to create density functions for time variables (e.g., hour).

When I'm building a density function for hour, I'm getting values which exceeds 0 and 24 (which has no meaning in my case, where I want to check the probabilty that new data point where "taken" from my distribution.

Is there a good approach to handle this problem?

I"ll be happy to hear of implementations of your answer in r

$\endgroup$
1
$\begingroup$

If your variable is on a circle (hours of a day, or months of the year, or directions... or many other possibilities), you should generally use a distribution on a circle for it.

Beside the problem that you have, another problem with setting some arbitrary boundary is that the two ends won't necessarily "meet smoothly" -- you'll introduce a discontinuity at whatever place you choose to break your circle to make it an interval, unless you force the function to be periodic (in which case, you have a distribution on the circle and that's fine).

In the case of nonparametric density estimation, there are periodic kernels and periodic splines that can be used. Another alternative that might be considered is to use mixtures of parametric densities on the circles. [Kernel density estimates could even be regarded as falling into that class, if you see the kernel (with the observation point being a shift parameter) as the parametric density]

$\endgroup$
  • $\begingroup$ Thank you very much for your answer. Can you please give me some more detail on how to implement it. I have transactions' data of cusomers with only one variable (time of transaction) and I'd like to check whether a new transacion is "normal" or not. $\endgroup$ – staove7 Apr 23 '17 at 8:40
  • $\begingroup$ There's some references in this answer; I don't know the extent to which any of this is useful for checking whether a single new transaction is normal, though. $\endgroup$ – Glen_b -Reinstate Monica Apr 23 '17 at 8:47
  • $\begingroup$ So, you think that in my case it is more reasonable to work with intervals? If so, again, how should I handle the time "borders"? $\endgroup$ – staove7 Apr 23 '17 at 9:01
  • $\begingroup$ I don't see how ignoring the circularity helps at all; again, I don't know the extent to which any of this is useful for checking whether a single new transaction is normal, including your original proposal (nothing is lost by dealing with it properly). What was your intended manner of figuring out if a new transaction was not normal? $\endgroup$ – Glen_b -Reinstate Monica Apr 23 '17 at 9:07
  • $\begingroup$ If you're able to outline what you had in mind it might be possible to say more. (I'm not really an expert on this stuff, though.) $\endgroup$ – Glen_b -Reinstate Monica Apr 23 '17 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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