Announcement

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

  • Problem of using xtologit

    Dear Professors,
    I am using xtologit for the order logit model. I have four income group countries. Income variable specified as
    1 = low income group
    2 =Lower middle income
    3 = Upper middle income
    4 = high income
    I am trying to asses the impact of urban population on fertility rate

    So I run the following
    xtset income
    xtologit fertilityrate urbanpopulation

    Then I get the following results

    Fitting comparison model:

    J(): 3900 unable to allocate real <tmp>[6660,8935878]
    _gsem_eval_ordinal(): - function returned error
    _gsem_eval_iid__obs(): - function returned error
    _gsem_eval_iid__wrk(): - function returned error
    _gsem_eval_iid(): - function returned error
    mopt__calluser_v(): - function returned error
    opt__eval_nr_v2(): - function returned error
    opt__eval(): - function returned error
    opt__looputil_iter0_common(): - function returned error
    opt__looputil_iter0_nr(): - function returned error
    opt__loop_nr(): - function returned error
    opt__loop(): - function returned error
    _moptimize(): - function returned error
    _gsem_start__fixed(): - function returned error
    _gsem_start_mecmd(): - function returned error
    _gsem_build(): - function returned error
    _gsem_parse(): - function returned error
    st_gsem_parse(): - function returned error
    <istmt>: - function returned error
    r(3900);


    Could you please help me how to solve this problem.

    Thanking you,

    With Kind Regards,
    Sabyasachi Tripathi

  • #2
    Xtsetting on a variable with only 4 possible values doesn’t make much sense. Do you really have panel data, and if so what is the panelid?

    Also how is your dependent variable coded? Is it really ordinal?
    -------------------------------------------
    Richard Williams
    Professor Emeritus of Sociology
    University of Notre Dame
    StataNow Version: 19.5 MP (2 processor)

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

    Comment


    • #3
      Dear Prof. Richard Williams
      Thank you for your reply. Yes I have panel data from 1960 to 2021 and country level data on fertility rate and total urban population. My question is that is there any variation in the results based on their income level. So I coded countries by 4 different orders as explained before.
      I followed the manuals from the following STATA manuals...they also have given similar example.
      https://www.stata.com/manuals13/xtxtologit.pdf

      Thank you for your kind help.

      Comment


      • #4
        Please show us the output of
        Code:
        codebook fertilityrate urbanpopulation income
        To assure maximum readability of results that you post, please copy them from the Results window into a code block in the Forum editor using code delimiters [CODE] and [/CODE], as explained in section 12 of the Statalist FAQ linked to at the top of the page. For example, the following difficlut-to-read text

        [CODE]
        . codebook price weight foreign

        ------------------------------------------------------------------------------------------------
        price Price
        ------------------------------------------------------------------------------------------------

        Type: Numeric (int)

        Range: [3291,15906] Units: 1
        Unique values: 74 Missing .: 0/74

        Mean: 6165.26
        Std. dev.: 2949.5

        Percentiles: 10% 25% 50% 75% 90%
        3895 4195 5006.5 6342 11385

        ------------------------------------------------------------------------------------------------
        weight Weight (lbs.)
        ------------------------------------------------------------------------------------------------

        Type: Numeric (int)

        Range: [1760,4840] Units: 10
        Unique values: 64 Missing .: 0/74

        Mean: 3019.46
        Std. dev.: 777.194

        Percentiles: 10% 25% 50% 75% 90%
        2020 2240 3190 3600 4060

        ------------------------------------------------------------------------------------------------
        foreign Car origin
        ------------------------------------------------------------------------------------------------

        Type: Numeric (byte)
        Label: origin

        Range: [0,1] Units: 1
        Unique values: 2 Missing .: 0/74

        Tabulation: Freq. Numeric Label
        52 0 Domestic
        22 1 Foreign
        [/CODE]

        will be presented in the post as the following, using a more appropriate font
        Code:
        . codebook price weight foreign
        
        ------------------------------------------------------------------------------------------------
        price                                                                                      Price
        ------------------------------------------------------------------------------------------------
        
                          Type: Numeric (int)
        
                         Range: [3291,15906]                  Units: 1
                 Unique values: 74                        Missing .: 0/74
        
                          Mean: 6165.26
                     Std. dev.:  2949.5
        
                   Percentiles:     10%       25%       50%       75%       90%
                                   3895      4195    5006.5      6342     11385
        
        ------------------------------------------------------------------------------------------------
        weight                                                                             Weight (lbs.)
        ------------------------------------------------------------------------------------------------
        
                          Type: Numeric (int)
        
                         Range: [1760,4840]                   Units: 10
                 Unique values: 64                        Missing .: 0/74
        
                          Mean: 3019.46
                     Std. dev.: 777.194
        
                   Percentiles:     10%       25%       50%       75%       90%
                                   2020      2240      3190      3600      4060
        
        ------------------------------------------------------------------------------------------------
        foreign                                                                               Car origin
        ------------------------------------------------------------------------------------------------
        
                          Type: Numeric (byte)
                         Label: origin
        
                         Range: [0,1]                         Units: 1
                 Unique values: 2                         Missing .: 0/74
        
                    Tabulation: Freq.   Numeric  Label
                                   52         0  Domestic
                                   22         1  Foreign
        Compare this to the code you posted in your previous Statalist topic at

        https://www.statalist.org/forums/for...69#post1636469

        which received no reponse, perhaps because it was difficult to read.

        Comment


        • #5
          You may want to include income in the model but you do not want to xtset on it. You probably want something like

          xtset country year
          -------------------------------------------
          Richard Williams
          Professor Emeritus of Sociology
          University of Notre Dame
          StataNow Version: 19.5 MP (2 processor)

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

          Comment


          • #6
            Dear Prof. Richard Williams

            Yes now I used xtset country year
            Now my dependent variable is income group variable "income_group" and independent variable is urban population (urban_p). Then I have ended up with the following problem:

            xtologit income_group ln_urban_p

            Fitting comparison model:

            Iteration 0: log likelihood = -15939.176
            Iteration 1: log likelihood = -15934.806
            Iteration 2: log likelihood = -15934.806

            Refining starting values:

            Grid node 0: log likelihood = -8759.1347

            Fitting full model:

            Iteration 0: log likelihood = -8759.1347
            Iteration 1: log likelihood = -1501.5138
            Iteration 2: log likelihood = -1205.6597
            Iteration 3: log likelihood = -625.09707 (not concave)
            Iteration 4: log likelihood = -552.9766 (not concave)
            Iteration 5: log likelihood = -495.75167 (not concave)
            cannot compute an improvement -- discontinuous region encountered
            r(430);

            Could you please help me.

            With Kind Regards,

            Comment


            • #7
              Info like William requested may help.
              -------------------------------------------
              Richard Williams
              Professor Emeritus of Sociology
              University of Notre Dame
              StataNow Version: 19.5 MP (2 processor)

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

              Comment


              • #8
                As others have commented, you need to provide more information relating to your data. You have asked about gllamm from SSC (via email). Here is the equivalent syntax:


                Code:
                webuse tvsfpors, clear
                xtset school
                *XTOLOGIT
                xtologit thk prethk cc##tv, nolog
                
                *ssc install gllamm
                *GLLAMM
                gen cctv= c.cc#c.tv
                gllamm thk prethk cc tv cctv,  link(ologit) fam(binom) i(school) nolog
                Res.:

                Code:
                . xtologit thk prethk cc##tv, nolog
                
                Random-effects ordered logistic regression      Number of obs     =      1,600
                Group variable: school                          Number of groups  =         28
                
                Random effects u_i ~ Gaussian                   Obs per group:
                                                                              min =         18
                                                                              avg =       57.1
                                                                              max =        137
                
                Integration method: mvaghermite                 Integration pts.  =         12
                
                                                                Wald chi2(4)      =     128.06
                Log likelihood  = -2119.7428                    Prob > chi2       =     0.0000
                
                ------------------------------------------------------------------------------
                         thk |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                      prethk |   .4032892     .03886    10.38   0.000      .327125    .4794534
                        1.cc |   .9237904    .204074     4.53   0.000     .5238127    1.323768
                        1.tv |   .2749937   .1977424     1.39   0.164    -.1125744    .6625618
                             |
                       cc#tv |
                        1 1  |  -.4659256   .2845963    -1.64   0.102    -1.023724    .0918728
                -------------+----------------------------------------------------------------
                       /cut1 |  -.0884493   .1641062                     -.4100916     .233193
                       /cut2 |   1.153364    .165616                      .8287625    1.477965
                       /cut3 |    2.33195   .1734199                      1.992053    2.671846
                -------------+----------------------------------------------------------------
                   /sigma2_u |   .0735112   .0383106                      .0264695    .2041551
                ------------------------------------------------------------------------------
                LR test vs. ologit model: chibar2(01) = 10.72         Prob >= chibar2 = 0.0005
                
                .
                .
                .
                . *ssc install gllamm
                
                .
                . *GLLAMM
                
                .
                . gen cctv= c.cc#c.tv
                
                .
                . gllamm thk prethk cc tv cctv,  link(ologit) fam(binom) i(school) nolog
                 
                number of level 1 units = 1600
                number of level 2 units = 28
                 
                Condition Number = 16.909052
                 
                gllamm model
                 
                log likelihood = -2119.7554
                 
                ------------------------------------------------------------------------------
                         thk |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                thk          |
                      prethk |   .4034971   .0388353    10.39   0.000     .3273814    .4796128
                          cc |   .9099342   .2070142     4.40   0.000     .5041938    1.315675
                          tv |   .2679143   .2018645     1.33   0.184    -.1277329    .6635615
                        cctv |  -.4567022   .2853622    -1.60   0.110    -1.016002    .1025974
                -------------+----------------------------------------------------------------
                _cut11       |
                       _cons |  -.0964273   .1702289    -0.57   0.571    -.4300698    .2372152
                -------------+----------------------------------------------------------------
                _cut12       |
                       _cons |   1.145341   .1713372     6.68   0.000     .8095264    1.481156
                -------------+----------------------------------------------------------------
                _cut13       |
                       _cons |   2.323844   .1785075    13.02   0.000     1.973976    2.673712
                ------------------------------------------------------------------------------
                 
                 
                Variances and covariances of random effects
                ------------------------------------------------------------------------------
                
                 
                ***level 2 (school)
                 
                    var(1): .07305962 (.03834715)
                ------------------------------------------------------------------------------

                To request for adaptive quadrature instead of Newton-Raphson be used in the maximization, add the option -adapt-. In your case, the syntax is:

                Code:
                gllamm income_group ln_urban_p, link(ologit) fam(binom) i(country) adapt
                This does not guarantee that you will get a result, you may have data problems. So follow the advice you have been given in this thread if you still face problems.

                Comment


                • #9
                  Please see the data...

                  codebook ln_fertility ln_urban_p income_group

                  ---------------------------------------------------------------------------------------------------------------------------------------------
                  ln_fertility (unlabeled)
                  ---------------------------------------------------------------------------------------------------------------------------------------------

                  type: numeric (float)

                  range: [-.17793119,2.1355855] units: 1.000e-09
                  unique values: 3,538 missing .: 147/6,660

                  mean: 1.23117
                  std. dev: .534645

                  percentiles: 10% 25% 50% 75% 90%
                  .500775 .738598 1.27508 1.73853 1.90405

                  ---------------------------------------------------------------------------------------------------------------------------------------------
                  ln_urban_p (unlabeled)
                  ---------------------------------------------------------------------------------------------------------------------------------------------

                  type: numeric (float)

                  range: [6.7753663,19.993414] units: 1.000e-07
                  unique values: 6,655 missing .: 0/6,660

                  mean: 14.628
                  std. dev: 2.23151

                  percentiles: 10% 25% 50% 75% 90%
                  11.2924 13.3264 14.9921 16.0573 17.3091

                  ---------------------------------------------------------------------------------------------------------------------------------------------
                  income_group (unlabeled)
                  ---------------------------------------------------------------------------------------------------------------------------------------------

                  type: numeric (float)

                  range: [1,4] units: 1
                  unique values: 4 missing .: 0/6,660

                  tabulation: Freq. Value
                  720 1
                  1,860 2
                  2,940 3
                  1,140 4

                  Comment


                  • #10
                    codebook urban_p income_group fertility


                    urban_p URBAN_P


                    type: numeric (long)

                    range: [876,4.820e+08] units: 1
                    unique values: 6,655 missing .: 0/6,660

                    mean: 1.4e+07
                    std. dev: 3.6e+07

                    percentiles: 10% 25% 50% 75% 90%
                    80209.5 613178 3.2e+06 9.4e+06 3.3e+07


                    income_group (unlabeled)


                    type: numeric (float)

                    range: [1,4] units: 1
                    unique values: 4 missing .: 0/6,660

                    tabulation: Freq. Value
                    720 1
                    1,860 2
                    2,940 3
                    1,140 4


                    fertility FERTILITY


                    type: numeric (float)

                    range: [.837,8.462] units: .0001
                    unique values: 3,538 missing .: 147/6,660

                    mean: 3.91933
                    std. dev: 1.9357

                    percentiles: 10% 25% 50% 75% 90%
                    1.65 2.093 3.579 5.689 6.713

                    Comment


                    • #11
                      Now, I found the following problem
                      gllamm income_group ln_urban_p, link(ologit) fam(binom) i(country1) adapt

                      Running adaptive quadrature
                      Iteration 0: log likelihood = -1.3176213
                      (error occurred in ML computation)
                      (use trace option and check correctness of initial model)

                      .

                      Comment


                      • #12
                        type: numeric (long)

                        range: [876,4.820e+08] units: 1
                        unique values: 6,655 missing .: 0/6,660

                        mean: 1.4e+07
                        std. dev: 3.6e+07

                        percentiles: 10% 25% 50% 75% 90%
                        80209.5 613178 3.2e+06 9.4e+06 3.3e+07

                        I think it has to do with the very large values of this variable. I will simulate some data and get back to you.

                        Comment


                        • #13
                          Some tips for dealing with convergence problems are at

                          https://www3.nd.edu/~rwilliam/xsoc73994/L02.pdf

                          I agree with Andrew — rescaling the variable with the huge values (e.g. divide by 1 million) May help.
                          -------------------------------------------
                          Richard Williams
                          Professor Emeritus of Sociology
                          University of Notre Dame
                          StataNow Version: 19.5 MP (2 processor)

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

                          Comment

                          Working...
                          X