Announcement

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

  • 'ambiguous abbreviation"

    Dear forum,

    I hope all is well for you all.

    I'm currently a Master's student in Investment Banking. I'm currently in the process of writing my dissertation on the Fama and French Five-Factor model using the data provided on Kenneth French's website.

    I have downloaded the GRS Test for Stata and successfully ran this through STATA and replicating the results as seen in F&F's 2015 paper.

    I did a 25 portfolio test for a specific time period and the GRS test once again worked for me.

    However, for a 32 portfolio test, I get the error:

    ME2BM ambiguous abbreviation
    r(111);

    I have variables that begin with ME2BM, but no actual variable is with that specific name.
    var list:

    SMALLLoBMLoOP ME1BM1OP2 ME1BM1OP3 SMALLLoBMHiOP ME1BM2OP1 ME1BM2OP2 ME1BM2OP3 ME1BM2OP4 ME1BM3OP1 ME1BM3OP2 ME1BM3OP3 ME1BM3OP4 SMALLHiBMLoOP ME1BM4OP2 ME1BM4OP3 SMALLHiBMHiOP BIGLoBMLoOP ME2BM1OP2 ME2BM1OP3 BIGLoBMHiOP ME2BM2OP1 ME2BM2OP2 ME2BM2OP3 ME2BM2OP4 ME2BM3OP1 ME2BM3OP2 ME2BM3OP3 ME2BM3OP4 BIGHiBMLoOP ME2BM4OP2 ME2BM4OP3 BIGHiBMHiOP

    My code is the following

    version 12
    capture log close
    log using TableA_5_1963_1973, replace
    set more off
    clear all
    import excel 32MEBMOP.xls, firstrow sheet("1963,07-1973,07")
    grstest2 SMALLLoBMLoOP ME1BM1OP2 ME1BM1OP3 SMALLLoBMHiOP ME1BM2OP1 ME1BM2OP2 ME1BM2OP3 ME1BM2OP4 ME1BM3OP1 ME1BM3OP2 ME1BM3OP3 ME1BM3OP4 SMALLHiBMLoOP ME1BM4OP2 ME1BM4OP3 SMALLHiBMHiOP BIGLoBMLoOP ME2BM1OP2 ME2BM1OP3 BIGLoBMHiOP ME2BM2OP1 ME2BM2OP2 ME2BM2OP3 ME2BM2OP4 ME2BM3OP1 ME2BM3OP2 ME2BM3OP3 ME2BM3OP4 BIGHiBMLoOP ME2BM4OP2 ME2BM4OP3 BIGHiBMHiOP, flist(Mkt SMB HML)

    I apologise if this post is scruffy, but i was hoping for some guidance that could help me fix the issue or find an alternative.

    Kind regards,

    Ross


  • #2
    Try this before you run your commands:
    Code:
    set varabbrev off
    And please read the FAQ for advice on using Statalist. For example, please use CODE tags for Stata commands and output.

    Comment


    • #3
      Originally posted by Friedrich Huebler View Post
      Try this before you run your commands:
      Code:
      set varabbrev off
      And please read the FAQ for advice on using Statalist. For example, please use CODE tags for Stata commands and output.
      Hi Friedrich,

      Thank you for your suggestion.

      It appears to have worked, but now I get the error of "variable ME2BM not found", same error code, different error..

      The problem appears to be "ME2BM1OP2" onwards, as running the GRS test up until BIGLoBMLoOP works. I tried
      Code:
      set varabbrev off, permanently
      But this hasn't worked.

      Any more ideas?

      Comment


      • #4
        Thank you for using CODE delimiters. Please also follow other advice in the FAQ. Section 12 is especially useful, here is an excerpt:

        Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly! [...]

        Never say just that something "doesn't work" or "didn't work", but explain precisely in what sense you didn't get what you wanted.
        To narrow down the cause of the problem, you can
        Code:
        set trace on
        and run your commands again.

        Comment


        • #5
          The problem appears to be in grstest2 which is evidently user-written, although you don't tell us where you got it (FAQ Advice #12).

          My guess is that it is using some string manipulation which causes truncation of your varlist. In older Stata versions limits on the length of string expression bit more than they do now.

          I'd try a mass renaming to shorter variable names.

          (You are quite possibly fitting an over-complicated model too, but that is a different issue.)

          Comment


          • #6
            I found this program on SSC. I see problems in the code:

            Code:
            local c = "`varlist'"
            local d = "`flist'"
            These locals are better defined by copying. Evaluation will truncate their arguments.

            Code:
            local c "`varlist'"
            local d "`flist'"
            There are some other details that could be improved. Permanent variable names may clash with existing names, and the summarize calls could all be made summarize, meanonly.

            But those aren't bugs, or rather the variable name problem is not what is biting.

            I am optimistic on your behalf that this use of equals signs may be the problem.

            Comment


            • #7
              Originally posted by Friedrich Huebler View Post
              Thank you for using CODE delimiters. Please also follow other advice in the FAQ. Section 12 is especially useful, here is an excerpt:



              To narrow down the cause of the problem, you can
              Code:
              set trace on
              and run your commands again.
              Thank you, I'll be reading the FAQ more from now as I intend to be a regular. I will update you on the outcome soon.

              Comment


              • #8
                Originally posted by Nick Cox View Post
                I found this program on SSC. I see problems in the code:

                Code:
                local c = "`varlist'"
                local d = "`flist'"
                These locals are better defined by copying. Evaluation will truncate their arguments.

                Code:
                local c "`varlist'"
                local d "`flist'"
                There are some other details that could be improved. Permanent variable names may clash with existing names, and the summarize calls could all be made summarize, meanonly.

                But those aren't bugs, or rather the variable name problem is not what is biting.

                I am optimistic on your behalf that this use of equals signs may be the problem.

                Yes, it was user written - apologies. https://ideas.repec.org/c/boc/bocode/s457786.html is the cote, but I used the command prompt to install it.
                I will try your potential solutions out and I will update you on the outcome.

                Thank you both for taking the time to help me, it is greatly appreciated.

                Comment


                • #9
                  Originally posted by Friedrich Huebler View Post
                  Thank you for using CODE delimiters. Please also follow other advice in the FAQ. Section 12 is especially useful, here is an excerpt:



                  To narrow down the cause of the problem, you can
                  Code:
                  set trace on
                  and run your commands again.
                  After applying
                  Code:
                  set trace on
                  I get the following:

                  Code:
                  - version 12
                    - syntax varlist [if] , flist(string) [alphas nqui]
                    - local a: word count `varlist'
                    = local a: word count SMALLLoBMLoOP ME1BM1OP2 ME1BM1OP3 SMALLLoBMHiOP ME1BM2OP1 ME1BM2OP2 ME1BM2OP3 ME1BM2OP4 ME1BM3OP1 ME1BM3OP2 ME1BM3OP3 ME1BM3OP4 SMALLHiBMLoOP ME1BM4OP2 ME1BM4OP3 S
                  > MALLHiBMHiOP BIGLoBMLoOP ME2BM1OP2 ME2BM1OP3 BIGLoBMHiOP ME2BM2OP1 ME2BM2OP2 ME2BM2OP3 ME2BM2OP4 ME2BM3OP1 ME2BM3OP2 ME2BM3OP3 ME2BM3OP4 BIGHiBMLoOP ME2BM4OP2 ME2BM4OP3 BIGHiBMHiOP
                    - local b: word count `flist'
                    = local b: word count MktRF SMB HML
                    - local c = "`varlist'"
                    = local c = "SMALLLoBMLoOP ME1BM1OP2 ME1BM1OP3 SMALLLoBMHiOP ME1BM2OP1 ME1BM2OP2 ME1BM2OP3 ME1BM2OP4 ME1BM3OP1 ME1BM3OP2 ME1BM3OP3 ME1BM3OP4 SMALLHiBMLoOP ME1BM4OP2 ME1BM4OP3 SMALLHiBMH
                  > iOP BIGLoBMLoOP ME2BM1OP2 ME2BM1OP3 BIGLoBMHiOP ME2BM2OP1 ME2BM2OP2 ME2BM2OP3 ME2BM2OP4 ME2BM3OP1 ME2BM3OP2 ME2BM3OP3 ME2BM3OP4 BIGHiBMLoOP ME2BM4OP2 ME2BM4OP3 BIGHiBMHiOP"
                    - local d = "`flist'"
                    = local d = "MktRF SMB HML"
                    - local i=1
                    - foreach var of varlist `c' {
                    = foreach var of varlist SMALLLoBMLoOP ME1BM1OP2 ME1BM1OP3 SMALLLoBMHiOP ME1BM2OP1 ME1BM2OP2 ME1BM2OP3 ME1BM2OP4 ME1BM3OP1 ME1BM3OP2 ME1BM3OP3 ME1BM3OP4 SMALLHiBMLoOP ME1BM4OP2 ME1BM4OP
                  > 3 SMALLHiBMHiOP BIGLoBMLoOP ME2BM1OP2 ME2BM1OP3 BIGLoBMHiOP ME2BM2OP1 ME2BM2OP2 ME2BM {
                  variable ME2BM not found
                  I can see that
                  Code:
                    = foreach var of varlist SMALLLoBMLoOP ME1BM1OP2 ME1BM1OP3 SMALLLoBMHiOP ME1BM2OP1 ME1BM2OP2 ME1BM2OP3 ME1BM2OP4 ME1BM3OP1 ME1BM3OP2 ME1BM3OP3 ME1BM3OP4 SMALLHiBMLoOP ME1BM4OP2 ME1BM4OP
                  > 3 SMALLHiBMHiOP BIGLoBMLoOP ME2BM1OP2 ME2BM1OP3 BIGLoBMHiOP ME2BM2OP1 ME2BM2OP2 ME2BM {
                  variable ME2BM not found
                  From my understanding, and bear with me; i've only been using Stata since September 2016 - but anything after the variable ME2BM2OP2, it is not being included in the varlist.

                  However, we can see from

                  Code:
                    - local c = "`varlist'"
                    = local c = "SMALLLoBMLoOP ME1BM1OP2 ME1BM1OP3 SMALLLoBMHiOP ME1BM2OP1 ME1BM2OP2 ME1BM2OP3 ME1BM2OP4 ME1BM3OP1 ME1BM3OP2 ME1BM3OP3 ME1BM3OP4 SMALLHiBMLoOP ME1BM4OP2 ME1BM4OP3 SMALLHiBMH
                  > iOP BIGLoBMLoOP ME2BM1OP2 ME2BM1OP3 BIGLoBMHiOP ME2BM2OP1 ME2BM2OP2 ME2BM2OP3 ME2BM2OP4 ME2BM3OP1 ME2BM3OP2 ME2BM3OP3 ME2BM3OP4 BIGHiBMLoOP ME2BM4OP2 ME2BM4OP3 BIGHiBMHiOP"
                  That is in the varlist.

                  I'm quite stumped on ideas, to be honest. I hope the above clears it up.

                  Comment


                  • #10
                    This is the bug guessed at in #6.

                    Comment


                    • #11
                      Originally posted by Nick Cox View Post
                      This is the bug guessed at in #6.
                      Hi Nick,

                      It was indeed, it appears to be the way GRS test truncates the varlist - simplified everything from ME2BMOP2 onwards to literally 'A, B, C...P' and it's now returning values for me.

                      Thank you and Friedrich for your assistance, it is very much appreciated and it's also helping me understand STATA more!

                      I wish you all the best.

                      Comment


                      • #12
                        Originally posted by Nick Cox View Post
                        This is the bug guessed at in #6.
                        Another bug in grstest2 is the "if" statement is not passed into the program (meaning it will allow you to specify it but won't take it into the calculation).

                        There's a new package "grsftest" doing GRS test. It does not adjust for the degrees of freedom when calculating estimator of the sample covariance matrix of the factor portfolios. This approach avoids a common misrepresentation of the GRS paper.

                        Code:
                        ssc install grsftest

                        Comment


                        • #13
                          I am currently facing a similar problem getting the error message of "error ambiguous abbreviation" in the following code. Although I understood the reason behind the error message from this Q&A, I really do not know how to solve the problem! The definition of the local variable "gamblemeasurement" follows up the command "levelsof" meaning that the command gen (to generate a permanent variable) or removing the equal sign do not work in my case. Thanks in advance for any assistance!

                          forvalues ra = 1/100 {
                          local risk=`ra'/100
                          gen eqbid`ra' = round(privatevalue-((`risk'*privatevalue^((N+`risk'-1)/`risk')-`risk'*reserveprice^((N+`risk'-1)/`risk'))/((N+`risk'-1)* privatevalue^((N-1)/`risk')))) if privatevalue>=reserveprice
                          gen error`ra'=bid-eqbid`ra'
                          generate sqrerror`ra'=error`ra'^2
                          bysort gamble:egen mse`ra'=mean(sqrerror`ra')
                          bysort gamble:gen rootmse`ra'=sqrt(mse`ra')
                          }

                          egen minrootmse=rowmin(rootmse*)
                          gen risk=""
                          foreach v of varlist rootmse* {
                          replace risk= "`v'" if `v'==minrootmse
                          }

                          destring risk, replace ignore(rootmse)
                          levelsof gamble, local(gamblemeasurement)
                          foreach g in `gamblemeasurement' {
                          generate risk`g'=risk if gamble==`g'
                          twoway (scatter bid eqbid`riskg' if gamble==`g', sort) (lfit bid eqbid`riskg' if gamble==`g', sort), ytitle (Observed) xtitle(Predicted) name(ScatterGamble`g', replace)
                          twoway (fpfit bid privatevalue if gamble==`g', lcolor(black)) (fpfit eqbid`riskg' privatevalue if gamble==`g', lcolor(red)), name(FittedGamble`g', replace)
                          twoway (scatter error`riskg' eqbid`riskg' if gamble==`g', sort), ytitle (Error) xtitle(Predicted) name(DeviationsGamble`g', replace)
                          }

                          Comment


                          • #14
                            maybe -generate risk`g' = risk if gamble == `g'- should be -local risk`g' = risk if gamble == `g'-

                            Comment


                            • #15
                              Where is the code in #9 failing? If you type first

                              Code:
                              set trace on 
                              that may help you see where it is failing.

                              Comment

                              Working...
                              X