Announcement

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

  • convergence issues with nlsur (parameters constrained to zero or tending to infinity)

    Hi all,

    I am running nlsur estimations and I am experiencing some difficulty in convergence. Out of 26 parameters to be estimated, 1 is constrained by Stata to zero (ra0) and another one (ck0) tends to infinity (no standard error is estimated). I am joining the estimation output ( nlsur.pdf ). Have some of you an idea of what could be the reason behind these problems?

    Thanks in advance,
    Luca
    Attached Files

  • #2
    The better way to show your output is to paste it into your post and surround it by code delimiters. If you are not familiar with code delimiters, read Forum FAQ #12. Attachments are discouraged. Moreover, they limit the range of people who might respond to you because some of us are unwilling to risk downloading attachments from strangers.

    Comment


    • #3
      Further, what you re doing there is a Function evaluator program version of -nlsur-. And you are not showing the function program/file itself, you are just showing the command line that executed the function.

      Without knowing the function itself, nobody can guess what goes wrong. Or rather anybody can guess anything, and any guess will be just as good as any other.

      Comment


      • #4
        Thanks for your inputs. Here are the full codes I used:

        Code:
        cap program drop nlsurroth
        program nlsurroth
        version 10
        
             
             syntax varlist(min=13 max=13) if , at(name)
             tokenize `varlist'
             args shexcl_a shexcl_k age edu avage_k prom_k nkid part_f urban lnexp  nuclear type resid_lnexp
             marksample touse
            qui {
             tempname ca0 ca1 ca2 ca3 ca4 ca5 ca6 ca7
             scalar `ca0' = `at'[1,1]
            scalar `ca1' = `at'[1,2]
             scalar `ca2' = `at'[1,3]
             scalar `ca3' = `at'[1,4]
             scalar `ca4' = `at'[1,5]
             scalar `ca5' = `at'[1,6]
             scalar `ca6' = `at'[1,7]
             scalar `ca7' = `at'[1,8]
             
             tempname ck0 ck1 ck2 ck3 ck4 ck5 ck6 ck7 ck8
             scalar `ck0' = `at'[1,9]
            scalar `ck1' = `at'[1,10]
             scalar `ck2' = `at'[1,11]
             scalar `ck3' = `at'[1,12]
             scalar `ck4' = `at'[1,13]
             scalar `ck5' = `at'[1,14]
             scalar `ck6' = `at'[1,15]
             scalar `ck7' = `at'[1,16]
             scalar `ck8' = `at'[1,17]
        
             tempname ra0 ra1 rk
             scalar `ra0' = `at'[1,18]
            scalar `ra1' = `at'[1,19]
             scalar `rk' =  `at'[1,20]
        
             tempname z0 z1 z2 z3 z4 z5
             scalar `z0' = `at'[1,21]
             scalar `z1' = `at'[1,22]
             scalar `z2' = `at'[1,23]
             scalar `z3' = `at'[1,24]
             scalar `z4' = `at'[1,25]
             scalar `z5' = `at'[1,26]
             
             tempname deflatdem_a deflatexp_a deflatexp_a2
            scalar     `deflatdem_a' = 1 
            gen double `deflatexp_a' = (`lnexp' - `deflatdem_a') if `type'==20
            gen double `deflatexp_a2' = `deflatexp_a'^2 if `type'==20
           
            tempvar shexcl_k20
            gen double `shexcl_k20'= 0 if `type'==20
            
            tempvar shexcl_a20
            gen double `shexcl_a20'= (`ca0' + `ca1'*`nkid' + `ca2'*`age' + `ca3'*`edu' + `ca4'*`urban' + `ca5'*`nuclear' + `ca6'*`deflatexp_a' + `ca7'*`deflatexp_a2') + `ra0'*`resid_lnexp' if `type'==20
            
            cap drop `deflatexp_a' `deflatexp_a2' 
            
                tempvar zk 
                 gen double `zk' = `z0' + `z1'*`nkid' + `z2'*`avage_k' + `z3'*`prom_k' + `z4'*`nuclear' + `z5'*`urban' if `type'>20
                 tempvar gneta_k
                gen double `gneta_k' = exp(`zk')/(1+exp(`zk')) if `type'>20
                tempvar gneta_a
                gen double `gneta_a' = 1 - `gneta_k' if `type'>20
                 
                scalar deflatdem_k = 0
                scalar deflatdem_a = 1
                scalar scale =       1 
        
                 tempvar deflatexp_k deflatexp_a deflatexp_a2
                gen double `deflatexp_k' = (`lnexp' + log(`gneta_k') - deflatdem_k) if `type'>20
                
                gen double `deflatexp_a' = (`lnexp' + log(`gneta_a') - log(scale) - `deflatdem_a') if `type'>20
                
                gen double `deflatexp_a2' = `deflatexp_a'^2 if `type'>20
        
            tempvar shexcl_k21
            gen double `shexcl_k21'= `gneta_k'*(`ck0' + `ck1'*`nkid' + `ck2'*`age' + `ck3'*`avage_k' + `ck4'*`edu' + `ck5'*`urban' + `ck6'*`nuclear' + `ck7'*`deflatexp_k' + `ck8'*`deflatexp_k'^2) + `rk'*`resid_lnexp' if `type'>20
            tempvar shexcl_a21
            gen double `shexcl_a21'= `gneta_a'*(`ca0' + `ca1'*`nkid' + `ca2'*`age' + `ca3'*`edu' + `ca4'*`urban' + `ca5'*`nuclear' + `ca6'*`deflatexp_a' + `ca7'*`deflatexp_a2') + `ra1'*`resid_lnexp' if `type'>20
            drop `deflatexp_k' `deflatexp_a' `deflatexp_a2'
        
            qui replace `shexcl_a20' = 0 if `shexcl_a20'==.
            qui replace `shexcl_a21' = 0 if `shexcl_a21'==.
            qui replace `shexcl_k20' = 0 if `shexcl_k20'==.
            qui replace `shexcl_k21' = 0 if `shexcl_k21'==.
            
            qui replace `shexcl_a' = `shexcl_a20'+`shexcl_a21'
            qui replace `shexcl_k' = `shexcl_k20'+`shexcl_k21'
           
            }
        
         end
        
         #delimit;
        nlsur roth @ shexcl_k shexcl_a age edu avage_k prom_k nkid part_f urban lnexp nuclear type resid_lnexp , 
        parameters(
        ca0 ca1 ca2 ca3 ca4 ca5 ca6 ca7  
        ck0 ck1 ck2 ck3 ck4 ck5 ck6 ck7 ck8 
        ra0 ra1 
        rk 
        z0 z1 z2 z3 z4 z5
        ) 
        neq(2) ifgnls;
        And here are the results (I avoid posting the initial - many - iteration lines, and start from the last ones):

        Code:
        Iteration 450:  Residual SS =  1.551043
        Calculating FGNLS estimates...
        Iteration 0:  Scaled RSS =  1400.243
        Iteration 1:  Scaled RSS =  1397.388
        Iteration 2:  Scaled RSS =  1394.933
        Iteration 3:  Scaled RSS =  1393.551
        Iteration 4:  Scaled RSS =  1393.541
        Iteration 5:  Scaled RSS =  1393.541
        Iteration 6:  Scaled RSS =  1393.541
        Iteration 7:  Scaled RSS =  1393.541
        FGNLS iteration 2...
        Iteration 0:  Scaled RSS =  1403.974
        Iteration 1:  Scaled RSS =   1403.97
        Iteration 2:  Scaled RSS =   1403.97
        Iteration 3:  Scaled RSS =   1403.97
        Parameter change         =  4.616e-02
        Covariance matrix change =  2.004e-06
        FGNLS iteration 3...
        Iteration 0:  Scaled RSS =      1404
        Iteration 1:  Scaled RSS =      1404
        Iteration 2:  Scaled RSS =      1404
        Parameter change         =  2.438e-03
        Covariance matrix change =  1.093e-07
        FGNLS iteration 4...
        Iteration 0:  Scaled RSS =      1404
        Parameter change         =  1.378e-11
        Covariance matrix change =  1.643e-16
        
        FGNLS regression 
        -----------------------------------------------------------------------
               Equation |        Obs   Parms       RMSE      R-sq     Constant
        ----------------+------------------------------------------------------
         1     shexcl_k |        702       .   .0224392    0.7071*      (none)
         2     shexcl_a |        702       .   .0415583    0.7917*      (none)
        -----------------------------------------------------------------------
        * Uncentered R-sq
        
        ------------------------------------------------------------------------------
                     |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                /ca0 |  -.3051822   .2398337    -1.27   0.203    -.7752475    .1648831
                /ca1 |    .002509   .0014185     1.77   0.077    -.0002711    .0052892
                /ca2 |   .0077702   .0018975     4.09   0.000     .0040512    .0114892
                /ca3 |   .0031885   .0020149     1.58   0.114    -.0007606    .0071375
                /ca4 |   .0023744    .001951     1.22   0.224    -.0014495    .0061983
                /ca5 |   .0025963   .0018702     1.39   0.165    -.0010692    .0062618
                /ca6 |   .0499677   .0500723     1.00   0.318    -.0481723    .1481076
                /ca7 |  -.0016288   .0026128    -0.62   0.533    -.0067497    .0034921
                /ck0 |   24.23925          .        .       .            .           .
                /ck1 |   .4162623   1.200133     0.35   0.729    -1.935955    2.768479
                /ck2 |   .1877039    .572713     0.33   0.743    -.9347929    1.310201
                /ck3 |   -.525344   .5650662    -0.93   0.353    -1.632853    .5821655
                /ck4 |    1.56704    1.59704     0.98   0.326    -1.563102    4.697181
                /ck5 |  -1.710966   2.475146    -0.69   0.489    -6.562164    3.140232
                /ck6 |  -6.320843   7.214809    -0.88   0.381    -20.46161    7.819924
                /ck7 |  -7.029256   1.561098    -4.50   0.000    -10.08895   -3.969561
                /ck8 |   1.012668   .5090902     1.99   0.047     .0148694    2.010466
                /ra0 |          0  (constrained)
                /ra1 |  -.0232098   .0042488    -5.46   0.000    -.0315374   -.0148823
                 /rk |  -.0437428   .0077543    -5.64   0.000     -.058941   -.0285445
                 /z0 |  -4.591388   1.031125    -4.45   0.000    -6.612356   -2.570419
                 /z1 |  -.3063783   .0739427    -4.14   0.000    -.4513033   -.1614532
                 /z2 |  -.0013501   .0103837    -0.13   0.897    -.0217017    .0190015
                 /z3 |  -.0528968   .0287243    -1.84   0.066    -.1091954    .0034019
                 /z4 |   .4749318   .1175396     4.04   0.000     .2445583    .7053053
                 /z5 |   .1823993   .0908538     2.01   0.045     .0043291    .3604695
        ------------------------------------------------------------------------------
        Thanks again,
        Luca

        Comment

        Working...
        X