Announcement

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

  • maximum likelihood

    hello!
    i'm trying to run maximum likelihood:
    program firmentry

    args lnf v f gamma2 gamma3 gamma4 gamma5
    tempvar p2 p3 p4 p5
    qui gen double ‘p2’=normal(‘v’-‘f’-‘gamma2’)
    qui gen double ‘p3’=normal(‘v’-‘f’-‘gamma2’-‘gamma3’)
    qui gen double ‘p4’=normal(‘v’-‘f’-‘gamma2’-‘gamma3’-‘gamma4’)
    qui gen double ‘p5’=normal(‘v’-‘f’-‘gamma2’-‘gamma3’-‘gamma4’-‘gamma5’)

    quietly replace ‘lnf’=ln('p2') if $ML_y1==2
    quietly replace ‘lnf’=ln('p3'-'p4') if $ML_y1==3
    quietly replace ‘lnf’=ln(‘p4’-‘p5’) if $ML_y1==4
    quietly replace ‘lnf’=ln('p5’) if $ML_y1>=5
    end

    ml model lf firmentry (beta:flights=pop tour busi) (gamma2:flights=) (gamma3:flights=) (gamma4:flights=) (gamma5:flights=)
    ml search gamma2 0 1 gamma3 0 1 gamma4 0 1 gamma5 0 1
    ml max

    but something got wrong because the message i recieved: invalid syntax r(198);
    someone can help me???
    thanks!


  • #2
    The most obvious detail here is that the same character is being used for open and close single quotation marks in macro references.

    That's wrong. See e.g. 18.3.1 within http://www.stata.com/manuals13/u.pdf

    Please note our strong preference here for full real names, meaning given name and family name. See FAQ Advice Section 6.

    Comment


    • #3
      thanks. i will correct my name.
      the error is given for the ml model, ml search and ml max:

      ml model lf firmentry12 (beta:flights=pop tour busi) (gamma2:flights=) (gamma3:flights=) (gamma4:flights=) (gamma5:flights=)
      invalid syntax
      r(198);

      .
      . ml search gamma2 0 1 gamma3 0 1 gamma4 0 1 gamma5 0 1
      varlist not allowed
      r(101);

      .
      . ml max
      invalid syntax
      r(198);

      so i'm confused..

      Comment


      • #4
        I've given you one specific suggestion and a reference to read. Did you correct your code?

        Comment


        • #5
          yes.. but it seems that something in the last 3 sentences is wrong..
          maybe a typographical mistake?
          i have little experience in really programming in stata..

          Comment


          • #6
            Please show us the exact code you are now using. We can't see your program from where we sit.

            Comment


            • #7
              program firmentry

              args lnf v f gamma2 gamma3 gamma4 gamma5
              tempvar p2 p3 p4 p5
              qui gen double `p2'=normal(`v’-`f’-`gamma2’)
              qui gen double `p3’=normal(`v’-`f’-`gamma2’-`gamma3’)
              qui gen double `p4’=normal(`v’-`f’-`gamma2’-`gamma3’-`gamma4’)
              qui gen double `p5’=normal(`v’-`f’-`gamma2’-`gamma3’-`gamma4’-`gamma5’)

              quietly replace `lnf’=ln(`p2') if $ML_y1==2
              quietly replace `lnf’=ln(`p3'-`p4') if $ML_y1==3
              quietly replace `lnf’=ln(`p4’-`p5’) if $ML_y1==4
              quietly replace `lnf’=ln(`p5’) if $ML_y1>=5
              end



              ml model lf firmentry12 (beta:flights=pop tour busi) (gamma2:flights=) (gamma3:flights=) (gamma4:flights=) (gamma5:flights=)
              ml search gamma2 0 1 gamma3 0 1 gamma4 0 1 gamma5 0 1
              ml max

              Comment


              • #8
                Thanks for posting the code. I can't see an error on reading through.

                Comment


                • #9
                  what is the global macro ($ML_y1)?

                  Comment


                  • #10
                    thanks. maybe i have old stata version and this is the reason its dont work?

                    Comment


                    • #11
                      Hi, I think the problem is with this line:
                      ml model lf firmentry12 (beta:flights=pop tour busi) (gamma2:flights=) (gamma3:flights=) (gamma4:flights=) (gamma5:flights=)
                      try this:
                      ml model lf firmentry12 (beta:flights=pop tour busi)/gamma2 /gamma3 /gamma4 /gamma5
                      hope this works.

                      Comment

                      Working...
                      X