Hi Ingrid,
Assuming your municipalities ids range from 0 to N-1 (where N is the total number of municipalities) and each group of municipalities corresponds to a contiguous range of ids, this is not too hard:
# define arrays which represent the first and "last" ID for each group
# these could be defined as global arrays instead to load that information from an external file
# In the example below, group 0 will "generate" ids between 0 and 9, group 1 will have ids 10 to 24, etc…
- MUNGROUP_FIRSTID: array([ 0, 10, 25])
- MUNGROUP_LASTID: array([ 9, 24, 29])
# if you prefer, you could just define a MUNGROUP_LENGTHS global array and compute FIRST and LAST ids automatically:
- MUNGROUP_LENGTHS: array([ 10, 15, 5])
- MUNGROUP_LASTID: MUNGROUP_LENGTHS.cumsum() - 1
- MUNGROUP_FIRSTID: MUNGROUP_LASTID - MUNGROUP_LENGTHS + 1
# sadly, randint, does not support bounds which are different per-individual, so this does not work:
# - mun_id: randint(first_id, last_id + 1)
# luckily uniform does, so we can emulate that:
- mun_id: trunc(uniform(MUNGROUP_FIRSTID[group_id], MUNGROUP_LASTID[group_id] + 1))
- show(dump(group_id, MUNGROUP_FIRSTID[group_id], MUNGROUP_LASTID[group_id], mun_id))
If your municipalities groups do not represent contiguous range of ids, this is also possible but trickier…
Hope it helps,
Gaëtan
--
You received this message because you are subscribed to the Google Groups "liam2-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
liam2-users...@googlegroups.com.
To post to this group, send email to
liam2...@googlegroups.com.
Visit this group at https://groups.google.com/group/liam2-users.
Dear Ingrid,
Sorry, but I realize now I never answered this message. As you may know, the Federal Planning Bureau is extremely busy these days to evaluate the consequences of political parties programs for the next Belgian elections. I will not have time to do anything not related to that project before mid May. And at that point I will have a lot of catching up to do for all the projects that I have put aside for several months now (such as LIAM2). In short, I am truly sorry but I will probably only have time to throw together some example code to answer this email properly somewhere in late May or June.
Sorry again,