Modelling/testing for dependence between the *times* at which two sets of events occur I have a set of events of type 1, and their start and end times.  And a set of events of type 2, and their start and end times.  I'm struggling to wrap my head around how I can test whether these two event types are occurring independently of each other, or whether one tends to follow the other (in terms of the times at which it happens).  I can think of some fairly simplistic ways of looking into it (e.g. histogramming the time between an event of type 1 and the next one of type 2).  But I wondered if this might fit into some branch of statistics that I'm not familiar with, that someone could point me towards?
EDIT
A little more info: this relates to data from a group of animals feeding from a machine that has space only for one animal at a time.  (So event type 1 is animal 1 going to feed, and event type 2 is animal 2 going to feed, etc).  So lack of independence would probably be seen by one animal feeding fairly shortly after the other.  And it is not possible for them to feed concurrently.  The real question is whether there is some kind of social structure to these young animals' feeding behaviour, or whether they just go to feed when they feel hungry.  (There are also more than two animals in the pen, but I had been trying to keep my question as simple as possible.  Realising now, that the extra detail is probably quite important!  There are seven animals in the pen, so it is manageable to look at it pairwise if that's easier.)

The feeding machine has three possible states:

*

*idle;

*occupied by type A;

*occupied by type B.

If we discretize time, then we can model our problem with a Markov chain with 3 possible states.
We need to estimate a 3x3 transition probability matrix whose entries are the probabilities of switching from one of the 3 states to another one.
The estimation of time-invariant transition probabilities can be done as described in this question.
However, in our case we probably need to make the transition probabilities time-varying and dependent on some observables (e.g., a dummy that tells us whether the machine has been occupied in the last x minutes by A or B). The technology to estimate these models is described in the time-series textbook by James Hamilton and  in several other places (e.g., here).
You can then use the estimated probabilities and the impacts of the observables on the probabilities to answer many interesting questions.
A simpler alternative would be to train a classification model (having as output the probability  distribution of the next state and as input the one-hot encodings of the current state, plus other predictors such as statistics about the occupancy of the feeding machine in the previous minutes).
