ERROR: index 47 is out of bounds for axis 0 with size 47

14 views
Skip to first unread message

Ingrid Schockaert

unread,
Feb 19, 2019, 4:35:57 AM2/19/19
to liam2-users
Dear all,

I want to simulate the number of emigrants by age, sex and household position to 47 groups of municipalities in Flanders (destinations).
I use the following code

ENTITY=PERSON
internal_migration_target
                - indx: 1
                - indx2: -1
                - int_migrant: False
                - score_male: logit_score(-3.269+0.357*single + 0.0952*in_singleparenthh - 0.4476*in_couplechildhh)
                - score_female: logit_score(-3.301+0.367*single + 0.1376*in_singleparenthh - 0.5183*in_couplechildhh)
                - while indx <= 47:
                    # this is for version 0.11
                    - migr_matM: MIGR_MATM[indx,:,:] 
                    - migr_matF: MIGR_MATF[indx,:,:] 
                    #- qshow(migr_matM)
                    - int_emigrant: if(int_migrant==False,if(ISMALE,
                            logit_regr(score_male, align=migr_matM, filter=age<88),          
                            logit_regr(score_female, align=migr_matF,filter=age<88)),False)  
                    - int_migrant: if(int_emigrant,True,int_migrant)
                    - indx2: if(int_emigrant,indx,indx2)
                    - qshow(count(int_migrant))                            
                    - indx: indx + 1  

This is the structure of MIGR_MATM and MIGR_MATF
indx,age,period
,,2015
1,0,0.00165212602533260
2,0,0.00327526738355410
3,0,0.00770992145155213
4,0,0.00411582272977595
...
44,0,0.00060867800933306
45,0,0.00066664734355526
46,0,0.00049273934088867
47,0,0.00060867800933306
1,1,0.00192052419013189
2,1,0.00367159036348745
3,1,0.00720196571299461
4,1,0.00389753438585590
...
44,1,0.00056486005592115
45,1,0.00067783206710537
46,1,0.00048013104753297
47,1,0.00056486005592115

I don't understand why I get the following message? 
ERROR: index 47 is out of bounds for axis 0 with size 47

Secondly, I overestimate the number of moves: 209001 in stead of about 156000. Any idea?

Thank you in advance for the help!
Ingrid

Mahdi Ben Jelloul

unread,
Feb 19, 2019, 4:39:23 AM2/19/19
to liam2...@googlegroups.com
Hi Ingrid,

You should start at idx = 0 and end at idx = 46 (or while idx < 47). Python ranges start at 0 and the upper bound is open.

Hope it helps,

Mahdi 

--
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.
--
Mahdi Ben Jelloul

Gaëtan de Menten

unread,
Feb 19, 2019, 5:38:41 AM2/19/19
to liam2...@googlegroups.com

In addition to what Mahdi said, you are using logit_score in combination with logit_regr, which is probably not what you meant to do.

 

You should either use a simple expression + logit_regr(), or logit_score() + align().

 

logit_regr(expr) is equivalent to align(logit_score(expr)).

 

Gaëtan



Disclaimer: This e-mail may contain confidential information which is intended only for the use of the recipient(s) named above.
If you have received this communication in error, please notify the sender immediately and delete this e-mail from your system.
Please note that e-mail messages cannot be considered as official information from the Federal Planning Bureau.

Ingrid Schockaert

unread,
Feb 20, 2019, 7:26:07 AM2/20/19
to liam2-users
Dear Mahdi and Gaetan,

It's as simple as that, he...thanks!
Ingrid
Reply all
Reply to author
Forward
0 new messages