Announcement

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

  • error in looping

    Dear All,

    Please help me on looping with "foreach".

    I have error message of "too few quotes options not allowed r(101); end of do-file r(101)"

    when I run this syntax:

    Code:
    local allvars1 evolution_mn headsex headage h_size int_access assets ib5.region_sample child017 ib1.country ib1.wave
    quietly mprobit `allvars1', baseoutcome (0)
    outreg2 using "$base\Results\MICS_er_evolution.doc", replace ctitle({\b Total, Total}) title({\b Table 2A. Estimation Results of Multinomial Probit Models on Probability of Income Reduction by Waves (Coefficients)}) stats(coef se) label dec(3) sdec(3) addstat(LR, e(chi2), P-value, e(p), LogLik,e(ll)) addnote(Marginal effects are avalaible upon request)
    
    foreach j of numlist 0/3   {
    quietly mprobit `allvars1', baseoutcome (0)
    quietly margins, dydx(_all) atmeans predict(pr outcome(`j')) post
    outreg2 using "$base\Results\MICS_me_evolution.doc", append label ctitle({\b Total, outcome`j'}) title({\b Table 2. Estimation Results of Multinomial Probit Models on Probability of Income Reduction, Average Marginal Effects}) dec(4) sdec(3) stats(coef se)
    }

    data set is attached
    where is my mistake?


    Thanks,
    Dastan
    Attached Files
    Last edited by Dastan Aseinov; 12 May 2022, 05:37.

  • #2
    ?
    Last edited by Dastan Aseinov; 12 May 2022, 05:38.

    Comment


    • #3
      Originally posted by Dastan Aseinov View Post
      ?
      ?

      Comment


      • #4
        Hi Dastan
        Weirdly enough, the problem is not with the "foreach loop", but with margins.
        Its seems that you may have labels that are two long for your dep variable. Thus one walk around. Create a different variable that has the same info gen new=evolution_mn

        That should fix the problem with the loop. A different problem, tho, you are trying to add country and time fixed effects, given your panel data structure, it is very likely that you will not be getting anything sensible, because of the incidence paramater problem (too many dummies to estimate given the sample size).

        You may want to reconsider your model specification.
        HTH

        Comment


        • #5
          Bumping within 8 minutes is a bad idea. Bumping within 84 minutes is not much better.

          Please see guidance at #1 at https://www.statalist.org/forums/help#adviceextras

          If the bumps were accidents, well there you go.

          Here is something more constructive

          Code:
          foreach j of numlist 0/3   
          is legal, but
          Code:
          forval j = 0/3
          is better.


          Comment


          • #6
            Originally posted by Nick Cox View Post
            Bumping within 8 minutes is a bad idea. Bumping within 84 minutes is not much better.

            Please see guidance at #1 at https://www.statalist.org/forums/help#adviceextras

            If the bumps were accidents, well there you go.

            Here is something more constructive

            Code:
            foreach j of numlist 0/3 
            is legal, but
            Code:
            forval j = 0/3
            is better.

            Hi Nick,
            Sorry for bumps. It was just due to the fact that I could not remove the quotes that appeared as a result of my unsuccessful / erroneous attempts to edit the post.

            is it possible to remove quotes?

            thanks
            Dastan

            Comment


            • #7
              Originally posted by FernandoRios View Post
              Hi Dastan
              Weirdly enough, the problem is not with the "foreach loop", but with margins.
              Its seems that you may have labels that are two long for your dep variable. Thus one walk around. Create a different variable that has the same info gen new=evolution_mn

              That should fix the problem with the loop. A different problem, tho, you are trying to add country and time fixed effects, given your panel data structure, it is very likely that you will not be getting anything sensible, because of the incidence paramater problem (too many dummies to estimate given the sample size).

              You may want to reconsider your model specification.
              HTH
              Hi FernandoRios,
              Thank you very much for your help.

              I will try to fix the problem according to your advice.



              Best Regards,
              Dastan
              Last edited by Dastan Aseinov; 12 May 2022, 16:34.

              Comment


              • #8
                #8 See https://www.statalist.org/forums/help#closure for documentation here. You can edit a post within 1 hour of first posting, but you can't delete any post.

                That's unfortunate if you realise that a post has no content, but it was decided upon by StataCorp because too often people wanted to delete posts for not very good reasons.

                A forum like Statalist is not like say Wikipedia with constant editing to remove out-of-date or incorrect or incomplete or useless material. A certain messiness is a consequence we live with.

                Comment

                Working...
                X