# Markov Chains for Hospital Stays

Suppose I have the following problem:

Suppose you access to the hospital records: you have the history about how different patients passed through the different "stages" of the hospital (each row represents a unique patient).

A patient can enter the hospital, and then meets the triage nurse. From there, they are sent to an examination room. If the condition is not serious, they are discharged from the hospital. If the condition is serious, they are sent to a proper hospital ward where they are kept there until they are discharged. However, if the patient enters the hospital in a very serious condition, then they are immediately sent to a ward and then discharged.

I think that this problem can be modelled as a Markov Chain - either as a discrete time Markov Chain or as a continuous time Markov Chain. Using the available data, you can build a transition matrix which will describe the probabilities from moving between "states" (i.e. "stages") in the hospital. Once you have built the Markov Chain, you can calculate the probability the patient is in any of these "states" on the "n-th" day that they have entered the hospital.

I am interested in something slightly different: When you look at this data, naturally you will see that the hospital does not admit only one patient at a time and then accept the second patient after the first patient has been discharged (i.e. dedicate the hospital to serving one patient at a time) - this would be crazy. Naturally, the hospital serves many patients - there are times when more patients might be transitioning between certain "states", and other times when fewer patients are transitioning between other "states". Naturally, the hospital can be more or less busy, and this will ultimately affect the "speed" at which patients will pass through the different "stages".

Question: Can a Markov Chain be built in such a way that the transition probabilities are contingent on how many patients are in the hospital, how many patients are in each state and the rate at which they are transitioning?

For instance, when a new patient arrives, the analysis could say: seeing as they are currently 100 patients in the hospital, 20 patients are waiting to see the triage nurse and 50 are in the exam room - the Markov Chain estimates you will have to wait approximately 10 hours before you might have your own room in the hospital ward?

Is something like this possible? Would this require survival analysis methods?

The situation you describe seems to be quite amenable to a multi-state survival model. If you have data on "how many patients are in the hospital, how many patients are in each state and the rate at which they are transitioning," then those can be included in the model. The basic ideas are nicely outlined in the multi-state vignette of the R survival package. The complexity of this particular situation could require the more elaborate tools provided by the msm package, illustrated in its own vignette.