Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • -gllamm- for dynamic multinomial logit model with random effects

    Dear all,
    I am working on household survey panel data (3 waves) to analyse the dynamic between 4 states in labour market. My data looks like:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double(IDI year) float mobil_4 double age float(agesq female)
    1 2012 4 50 2500 1
    1 2013 4 51 2601 1
    1 2015 1 53 2809 1
    2 2012 1 20  400 1
    2 2013 1 21  441 1
    2 2015 1 23  529 1
    3 2012 3 17  289 1
    3 2013 1 18  324 1
    3 2015 3 20  400 1
    4 2012 4 10  100 1
    4 2013 1 11  121 1
    4 2015 1 13  169 1
    My dependent variable is mobil_4 which contain 4 states in labour market. I tried to use -gllamm- to fit a dynamic multinomial logit model with random effects. The code used is adapted from the code in GLLAMM Manual, Rabe-Hesketh, Skondal, and Pickles (2004) and in Uhlendorff and Haan (2006):

    Code:
    global varx1 age agesq urban fondamental secondaire superieur form_prof
    
    mlogit     mobil_4 $varx1 , base(1)
    matrix b=e(b)
    matrix list b
    scalar var=exp(0.5)
    matrix start=b,var,var, var, 0.5, 0.5, 0.5
    matrix colnames start= age agesq urban fondamental secondaire superieur form_prof _cons ///
    age agesq urban fondamental secondaire superieur form_prof _cons ///
    age agesq urban fondamental secondaire superieur form_prof _cons ///
    infs other out _cons1 _cons2 _cons3
    matrix coleq start= c2 c2 c2 c2 c2 c2 c2 c2 c2 ///
    c3 c3 c3 c3 c3 c3 c3 c3 c3 ///
    c4 c4 c4 c4 c4 c4 c4 c4 c4 ///
    V2 V3 V4 COV12 COV13 COV23
    
    sort IDI year age agesq urban fondamental secondaire superieur form_prof mobil_4
    gen patt=_n
    expand 4
    sort patt
    qui by patt:gen alt=_n
    gen chosen=alt==mobil_4
    sort patt alt
    tab alt, gen(a)
    gen dum=1
    replace dum=0 if a1==1
    eq dum:dum
    eq a2:a2
    eq a3:a3
    eq a4:a4
    
    gllamm alt $varx1 , expand(patt chosen m) i(IDI) link(mlogit) family(binom) nrf(3) ///
    eq(a2 a3 a4) nip(4) trace from(b) skip
    The code didn't converge and took more than 12 hours in iteration 0, which means, I guess, that is something wrong in the code!
    Could someone please give me some insights on how to fix this issue? I will be grateful!

    I am using Stata 15.
    Rferences:
    Rabe-Hesketh, S., A. Skrondal, and A. Pickles. 2004.GLLAMM Manual. University of California–Berkeley, Division of Biostatistics, Working Paper Series. Paper No. 160.
    http://www.bepress.com/ucbbiostat/paper160/.
    Haan, P. and Uhlendorff, A. (2006), ‘Estimation of multinomial logit models with unobserverd heterogeneity using maximum simulated likelihood’, The Stata Journal 6(2), 229–245.
    Last edited by mustapha ziroili; 09 May 2019, 18:24.

  • #2
    Is this the ENTIRE data set that you have posted? If so it seems like you are trying to do some pretty complicated things with very few cases.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 19.5 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://academicweb.nd.edu/~rwilliam/

    Comment


    • #3
      Mustapha: check whether you can fit your model using gsem (rather than gllamm). Start with Example 41g in the Stata 15 SEM manual

      Comment


      • #4
        Your dataex code does not include all the variables needed to replicate your analysis, e.g. urban. Using dataex is often very helpful but verify that it actually works, e.g. it includes all the variables needed.

        Along the lines Stephen suggests, this post tells you how to improvise an xtmlogit command with gsem.

        https://www.stata.com/stata-news/news29-2/xtmlogit/
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://academicweb.nd.edu/~rwilliam/

        Comment


        • #5
          Thank you Professors Richard and Stephen for your feedbacks;
          For data, what I presented is a sample of variables (mainly human capital ones) to see how the command -gllamm- works and then expand my model to other variables like industry and characteristics of jobs and also lagged variables and initial situation as well as averages of independent variables to deal with the issue of initial conditions problem. Because my primary goal is to look for state dependence to informality (one of the 4 states in labour market).

          I run the -gsem-command as suggested by Stephen and so far the program is in iteration 4 after 18 hours!
          The code used is:

          Code:
          gsem (2.mobil_4 <- age agesq i.chefmen  i.urban i.fondamental i.secondaire i.superieur i.form_prof M1[id]) ///
          (3.mobil_4 <- age agesq i.chefmen  i.urban i.fondamental i.secondaire i.superieur i.form_prof M2[id]) ///
          (4.mobil_4 <- age agesq i.chefmen  i.urban i.fondamental i.secondaire i.superieur i.form_prof M3[id]) ///
          ,cov(M1[id]*M2[id]) cov(M1[id]*M3[id]) cov(M2[id]*M3[id]) mlogit

          here I give an extract of the data:

          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input float id double(year age) float(agesq urban fondamental secondaire superieur form_prof mobil_4)
           1 2012 20  400 1 0 1 0 0 4
           1 2013 21  441 1 1 0 0 0 4
           1 2015 23  529 1 0 1 0 0 4
           2 2012 17  289 1 0 1 0 0 4
           2 2013 18  324 1 1 0 0 0 4
           2 2015 20  400 1 0 1 0 0 4
           3 2012 10  100 1 0 0 0 0 4
           3 2013 11  121 1 0 0 0 0 4
           3 2015 13  169 1 1 0 0 0 4
           4 2012  7   49 1 0 0 0 0 4
           4 2013  8   64 1 0 0 0 0 4
           4 2015 10  100 1 0 0 0 0 4
           5 2012 28  784 1 1 0 0 0 4
           5 2013 29  841 1 1 0 0 0 4
           5 2015 31  961 1 1 0 0 0 4
           6 2012 24  576 1 0 0 0 0 3
           6 2013 25  625 1 0 0 0 0 4
           6 2015 27  729 1 0 0 0 0 2
           7 2012 22  484 1 0 1 0 0 2
           7 2013 24  576 1 1 0 0 0 4
           7 2015 26  676 1 1 0 0 0 1
           8 2012 44 1936 1 1 0 0 0 1
           8 2013 44 1936 1 1 0 0 0 2
           8 2015 46 2116 1 1 0 0 0 3
           9 2012 16  256 1 1 0 0 0 4
           9 2013 17  289 1 1 0 0 0 4
           9 2015 19  361 1 0 1 0 0 4
          10 2012 41 1681 1 0 0 1 0 1
          10 2013 42 1764 1 0 1 0 0 1
          10 2015 44 1936 1 0 1 0 0 2
          11 2012 20  400 1 1 0 0 0 1
          11 2013 22  484 1 1 0 0 0 2
          11 2015 25  625 1 0 0 1 0 4
          12 2012 46 2116 1 0 0 0 0 3
          12 2013 47 2209 1 0 0 0 0 3
          12 2015 49 2401 1 0 0 0 0 3
          13 2012 22  484 1 0 1 0 0 4
          13 2013 23  529 1 1 0 0 0 4
          13 2015 25  625 1 1 0 0 0 3
          14 2012 19  361 1 0 1 0 0 4
          14 2013 20  400 1 1 0 0 0 4
          14 2015 22  484 1 1 0 0 0 4
          15 2012 16  256 1 1 0 0 0 4
          15 2013 17  289 1 1 0 0 0 4
          15 2015 19  361 1 1 0 0 0 4
          16 2012 12  144 1 1 0 0 0 4
          16 2013 14  196 1 1 0 0 0 4
          16 2015 15  225 1 1 0 0 0 4
          17 2012 17  289 1 1 0 0 0 4
          17 2013 18  324 1 1 0 0 0 4
          17 2015 19  361 1 1 0 0 0 4
          18 2012 19  361 1 0 1 0 0 4
          18 2013 20  400 1 1 0 0 0 4
          18 2015 22  484 1 0 1 0 0 4
          19 2012 11  121 1 0 0 0 0 4
          19 2013 13  169 1 1 0 0 0 4
          19 2015 15  225 1 1 0 0 0 4
          20 2012  9   81 1 0 0 0 0 4
          20 2013 10  100 1 0 0 0 0 4
          20 2015 12  144 1 0 0 0 0 4
          21 2012  5   25 1 0 0 0 0 .
          21 2013  7   49 1 0 0 0 0 4
          21 2015  8   64 1 0 0 0 0 4
          22 2012 34 1156 1 0 1 0 0 4
          22 2013 35 1225 1 1 0 0 0 4
          22 2015 37 1369 1 1 0 0 0 .
          23 2012 32 1024 1 1 0 0 0 4
          23 2013 34 1156 1 1 0 0 0 4
          23 2015 35 1225 1 1 0 0 0 4
          24 2012 14  196 1 1 0 0 0 4
          24 2013 15  225 1 1 0 0 0 4
          24 2015 17  289 1 1 0 0 0 4
          25 2012  5   25 1 0 0 0 0 .
          25 2013 12  144 1 0 0 0 0 4
          25 2015  8   64 1 0 0 0 0 4
          26 2012 11  121 1 0 0 0 0 4
          26 2013  7   49 1 0 0 0 0 4
          26 2015 12  144 1 0 0 0 0 4
          27 2012 42 1764 1 0 1 0 0 3
          27 2013 43 1849 1 1 0 0 0 2
          27 2015 45 2025 1 1 0 0 0 4
          28 2012 32 1024 1 0 0 1 0 4
          28 2013 33 1089 1 0 0 1 0 4
          28 2015 35 1225 1 0 1 0 0 4
          29 2012 48 2304 1 1 0 0 0 1
          29 2013 50 2500 1 1 0 0 0 1
          29 2015 52 2704 1 1 0 0 0 1
          30 2012 26  676 1 1 0 0 0 4
          30 2013 27  729 1 0 0 0 0 4
          30 2015 29  841 1 1 0 0 0 4
          31 2012  9   81 1 0 0 0 0 4
          31 2013 12  144 1 0 0 0 0 4
          31 2015 14  196 1 1 0 0 0 4
          32 2012 40 1600 1 0 0 1 0 1
          32 2013 41 1681 1 0 0 1 0 1
          32 2015 43 1849 1 0 0 1 0 1
          33 2012 29  841 1 0 1 0 0 1
          33 2013 30  900 1 1 0 0 0 1
          33 2015 32 1024 1 1 0 0 0 4
          34 2012 26  676 1 0 0 1 0 4
          end
          label values mobil_4 mobil_4
          label def mobil_4 1 "Formal Salaried", modify
          label def mobil_4 2 "Informal Salaried", modify
          label def mobil_4 3 "Other employment", modify
          label def mobil_4 4 "Out of employment", modify
          I tested also the -mixlogit-command, the program converged (with at least these human capital variables) but I am not sure if I did it well!
          Unfortunately all these programs (-gllamm-, -gsem-, -mixlogit- and the Haan, P. and Uhlendorff's code) don't converge easily! My be it's my fault that I miss or didn't understand something !

          Comment

          Working...
          X