Announcement

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

  • #31
    I used the exact same code as your last posted code, however, instead of dropping the first 2 months I changed the 2 values into a . so that it resembled my dataset

    Code:
     clear all
    input str20 date chg
    31jan2006     .
    28feb2006     .
    31mar2006     .0356
    28apr2006    -.0124
    31may2006    -.0304
    30jun2006    -.0054
    31jul2006    -.0399
    31aug2006     .0083
    29sep2006    -.0123
    31oct2006     .0164
    30nov2006     .0077
    29dec2006    -.0089
    end
     
    gen date2 = date(date, "DMY")
    format date2 %td
    gen year = year(date2)
    gen idcode = 1
    sort idcode date2
    list
     
    set type double
     
    *Lydia code
    gen chgdec1 = chg+1
    //Take log
    gen logchgdec1 = log(chgdec1)
    //Sum them up
    gen sumchg1 = sum(logchgdec1)
    //Exp
    gen expsumchg1 = exp(sumchg1)
    //Annualize
    gen annual1 = expsumchg1^(12/_N)-1
     
    * RW Code
    bysort idcode year: egen numvalid = total(!missing(chg))
    bysort idcode year: egen sumchg = total(log(chg + 1))
    bysort idcode year: gen annual = exp(sumchg) ^ (12/numvalid) - 1
    list date2 chg numvalid annual1 annual
    Last edited by LydiaSmit; 16 Aug 2014, 20:42.

    Comment


    • #32
      Then you need to change the _N in your code. It equals 12 when it should equal 10.
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      StataNow Version: 19.5 MP (2 processor)

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

      Comment


      • #33
        Thank you very much for all the help you have given me Richard. In some cases there's only 1 month of data and your method with numvalid seems to be correct without any further adjustments, so I'll stick to your method.

        Comment


        • #34
          Same topic new problem.
          The annualchg of 4.7786 based on the 3 months of data is impossible, so what could be the mistake and the solution?




          Code:
          bysort idcode year: egen numvalid = total(!missing(chg))
          
          
          sort idcode year month
          bysort idcode year: egen double sumchg = total(chg)
          bysort idcode year: gen double annualchg = exp(sumchg)^(12/numvalid)-1
          Last edited by LydiaSmit; 20 Aug 2014, 07:59.

          Comment


          • #35
            Given your formulas, that is the correct answer. So the question is, are your formulas correct? The formulas you are using now are somewhat different than the formulas you started off with, e.g. Early on you were dividing chg by 100. Note too that this Cullen case has much bigger values for chg than the other cases you have shown. Maybe he was doing fantastically well for a few months but wouldn't have been able to sustain that for an entire year.
            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            StataNow Version: 19.5 MP (2 processor)

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

            Comment


            • #36
              Then the formulas probably need a little adjustment, even though I'm not sure which kind of adjustment they need.
              The chg in my previous post is already
              Code:
              log(1+chg/100)
              Cullen indeed appears to have fantastically results for those 3 months, however, annually it's impossible for him to have that return based on those 3 months. At least I think so at the moment. His maximum return in those specific 3 months was 21.35%....even 12 months of 21%=12x21=251% of course compounding adds more %, however, his lowest return was 9.31% so that would compensate the compounding a lot.

              Maybe, it's indeed his correct annualized return. Then I must reconsider if annualizing would be a good method for my project because cases like Cullen can probably bias my results and conclusions

              Comment


              • #37
                You don't multiply 12 by 21, you compound. Cullen is averaging about 14% a month. So, 1.14 ^ 12 = 4.82. Which is about what the more precise calculation got. So, the results you are getting are not impossible; they are correct given the formulas being used. Whether the formulas are right or the best way to do things is another matter.

                Is there any research or theory on how best to annualize? The fewer months there are, the shakier it seems to annualize. A few exceptionally good/bad months could seem to have a big impact on the results. I can't help you there though because I know nothing about what the preferred practices are.
                -------------------------------------------
                Richard Williams, Notre Dame Dept of Sociology
                StataNow Version: 19.5 MP (2 processor)

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

                Comment


                • #38
                  You're correct. Compounding has a much bigger effect than I previously thought at that moment. The effect of education on returns based on annualization would give biased results apparently due to the fact that some persons only have 1-6 months of data. It's not about comparing person A with person B. So annualizing might not be a good idea after all.

                  Annualization of returns seems to be the most common practice, however, in this case it might not be a good idea. An annual return of 4.78 is highly likely an outlier. Outliers must be removed, so that would be a waste of data for more cases like Cullen, for people with a few months of exceptionally good/bad data

                  Comment


                  • #39
                    You might limit it to some minimum number of months, e.g. 9 or 10. Perhaps there are some commonly accepted practices with this.
                    -------------------------------------------
                    Richard Williams, Notre Dame Dept of Sociology
                    StataNow Version: 19.5 MP (2 processor)

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

                    Comment

                    Working...
                    X