Page 1 of 1

Delay with dispersion AND leakage

Posted: Wed Apr 06, 2022 11:33 am
by kleemax
Conveyor is a delay function with leakage
Delay N is a delay function with dispersion/variance, i.e. a pulse input of one DT gives a curved output, which is more dispersed than the input.

As far as I know, there is no built-in delay function that allows for both.
Is there a smart way of combining the two to get a function that combines both properties?

I know I could build a function like this using subscripts, but comes with its own disadvantages...

Re: Delay with dispersion AND leakage

Posted: Wed Apr 06, 2022 10:59 pm
by tomfid
I did something like this recently by splicing together a pipeline delay and a delay3 in a macro. It worked surprisingly well. I'm not on the same machine at the moment, but happy to share if useful.

Re: Delay with dispersion AND leakage

Posted: Thu Apr 07, 2022 8:14 am
by kleemax
Would be great if you could share that Tom. I hadn't thought of a macro yet, yours may inspire me.

Re: Delay with dispersion AND leakage

Posted: Thu Apr 07, 2022 8:17 am
by kleemax
Is there another place where to enter feature requests? DelayNL would be a feature request for a built-in function of a higher-order delay with leakage. It could e.g. differ from a normal DelayN in the way taht a conveyor differs from DelayFixed.

Re: Delay with dispersion AND leakage

Posted: Fri Apr 08, 2022 10:01 pm
by tomfid
I'll dig it up.

What do you need N to be? If it's 3 or 5 or something, it's fairly easy to write a macro (though the initial conditions are rather complicated). If it's 40, that gets messy.

Re: Delay with dispersion AND leakage

Posted: Wed Apr 20, 2022 10:59 pm
by tomfid
I've attached the explicit version of the model. I thought it would be good to clean things up a bit before redoing the macro for public consumption.

I built this for an SEIR model for Chronic Wasting Disease (CWD) in deer. In the literature, a lot of models use rather high-order delays (e.g. 44) for the various phases. As a side note, I think this may be technically correct, but wasted horsepower, because the dispersion of delay durations across models has more variation than the duration of the delay within any given model.

Anyway, it's easy enough to replicate arbitrary delay structures with arrays, but rather inconvenient to have 44th order for the E phase, 38th for the I phase, etc. So I wanted something with roughly the right arrival distribution, but a simpler structure. As an experiment, I created a hybrid delay with two phases: a pipeline delay (DELAY FIXED) followed by a DELAY3.

The complication in all this is that there is leakage in the delay structure. Deer progression through CWD has a high order structure, but deer are also subject to ordinary mortality (getting shot, hit by a car, etc.) that is basically first order. Computing this leakage is complicated for arbitrary delays, but it turns out that it can be solved analytically for DELAY FIXED and computed explicitly for DELAY3.

The result is the attached structure:
leaky delay explicit 1.mdl
(14.35 KiB) Downloaded 107 times
There's one key limitation: the delay duration is fixed. There's also one point to ponder: the delay duration is specified for the no-leak case. Leakage shortens the effective delay duration, because it affects the age distribution across the delay structure. In my case, this is OK, because the CWD progression timing is known from experimental situations where there is no hunting or other mortality, i.e. no leakage. In other cases, you'd have to correct for this (I think it can be done analytically without much difficulty, but I haven't tried).