duration

9 views
Skip to first unread message

Alexis EidelMan

unread,
May 9, 2013, 7:30:18 AM5/9/13
to liam...@googlegroups.com
Just a point about duration.
I think an user can want two different things,
     - to know the duration of a expression beeing true
    -  to know duration of consecutive period the expression was true before the period .
If I understand well only the latter is implemented in "duration" function.

The first one could be interesting.
The documentation could also be more explicit on that point. It ;ay be a translation issue in my case but I still confused reading the doc.

Alexis EidelMan

unread,
May 9, 2013, 10:50:34 AM5/9/13
to liam...@googlegroups.com
Update my previous post.
In fact, in my case I want more. I need a function duration( condition, for_period) which return how many times the condition is true for the previous for_period periods.

Gaëtan de Menten

unread,
May 13, 2013, 9:34:07 AM5/13/13
to liam...@googlegroups.com

On 09/05/2013 13:30, Alexis EidelMan wrote:

> Just a point about duration.
> I think an user can want two different things,
> - to know the duration of a expression beeing true
> - to know duration of consecutive period the expression was true
> before the period.
> If I understand well only the latter is implemented in "duration" function.

Indeed, it is the number of consecutive periods the expression was true.
I will just add that if for some period there is no value, but there is
one in an earlier period, the expression is assumed to keep the
"earlier" value for the missing data point.

> The first one could be interesting.

Indeed, but see below.

> The documentation could also be more explicit on that point. It ;ay be a
> translation issue in my case but I still confused reading the doc.

The documentation is incomplete, but the current implementation is
rather dumb too. In fact, we do not use it ourselves for performance
reasons (it goes back in time until the expression evaluates to False
for all individuals -- which means that for most expressions, it will
get slower with each simulated period). What we do instead in our model
is to simply store the duration in a field and increment it at each
period. This way, the modellers has full control over what is being
counted (consecutive or not, etc.).

In fact, duration should really only be used in the init section when
you have historic data. Using duration during the simulation (at least
in its current implementation does not make much sense).

At some point, I might rewrite duration to add an hidden field
automatically and simply increment the value of the last period, but
that is not a top priority at the moment.

Ga�tan


----------------------------------------------------------------------------

Disclaimer: please see "www.plan.be/disclaimer.html"

Please consider your environmental responsibility before printing this email

----------------------------------------------------------------------------

Alexis EidelMan

unread,
May 13, 2013, 9:59:05 AM5/13/13
to liam...@googlegroups.com, g...@plan.be
Thank you for these specifications.
If i want at period T, to know how much time a person had been in a given status between periods, says, T-8 ans T-1, I will create a field status_8 and run something like this :
status_8 = status_8 - ( lag( status, 8)) + ( status)
if I run it at the end of period T-1
or
status_8 = status_8 - ( lag( status, 9)) + (lag( status, 1))
 if at the beginning of period T.

Does it look like what you're doing ?
Is it the good way to have what I want ?
I'm not clear about the lag function, what does it return if there is no value at that period ? In the status_8 case, False or zero would be fine.
Ga�tan
Reply all
Reply to author
Forward
0 new messages