Announcement

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

  • Collapse function that calculates product

    Is there a function that does what the collapse function does but calculates the product of the values for the selected variable.

    I need it to calculate the yearly return out of monthly returns.

    Thank you very much in advance!

  • #2
    You can take the logarithm of a variable, use collapse to compute the sum of that variable, and than exponentiate that to get the product. The logic is that :

    \[
    \exp(\ln(a) + \ln(b) + \ln(c)) = \exp(\ln(a \times b \times c)) = a \times b \times c
    \]
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      This is clever! Thanks.

      Comment


      • #4
        Thank you so much, Mr Buis!

        Comment


        • #5
          Duplicate thread at http://www.statalist.org/forums/foru...ulates-product

          Please note the request there to use a full real name as identifier.

          Comment

          Working...
          X