Announcement

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

  • Mathematics in stata /stock return / change in log stock prices

    Hello everyone,
    I have 400 firms and I have closing prices for 5 months ( Nov 2018 ,Dec 2018, and Jan,Feb,march 2019). I would like to know how can I compute 1- ) the change in log stock prices from December 31, 2018 to March 31, 2019 and 2-) the change in log of average stock prices of November 30, 2018 and December 31, 2018 and average stock prices of February 28, 2019 and March 31, 2019. Please, how can I got /generate these TWO VARIABLES in stata ? Thanks a lot.

  • #2
    Welcome to Statalist.

    How are your data structured? Depending on the structure the procedures can be different. If you have a few minutes, please read the FAQ (http://www.statalist.org/forums/help), and follow the advice of #12 to use -dataex- command to provide some sample data of 1 or 2 companies. Without looking at that, it'd be hard to help.

    Comment


    • #3
      input byte Firms double(Nov2018 Dec2018 jan2019 feb2019 March2019)
      1 17.4400014429002 17.7066681234747 16.5066680608898 14.346667148237 16.5066680608898
      2 17.4400014429002 17.7066681234747 16.5066680608898 14.346667148237 16.5066680608898
      3 1.5003403493762 1.55479916423559 1.47038800120354 .991150430440903 1.47038800120354
      4 1.5003403493762 1.55479916423559 1.47038800120354 .991150430440903 1.47038800120354
      Hello Ken Chui,
      Thanks a lot for your welcome and advice.
      Please, this is an example of my data. Each number refer to the closing price for each firm and month. Thanks in advance.

      Comment


      • #4
        If I understood the order correctly, this should get what you want. Check the calculation to see if they match:

        Code:
        * The differenece in log(price). Notice that it's natural log. If you need common log with base 10, use log10():
        gen v1 = log(March2019) - log(Dec2018)
        
        * For the second variable:
        egen m1 = rowmean(Nov2018 Dec2018)
        egen m2 = rowmean(feb2019 March2019)
        gen v2 = log(m2) - log(m1)

        Comment


        • #5
          Hi Ken Chui,
          Thank you so much. Yes, its works . Thanks. Please, I have a following question: because I need the change in log stock prices from December 31, 2018 to March 31, 2019 ( ∆P), there is must be divided by March 31,2019) ? or just like as you have mentioned gen v1 = log(March2019) - log(Dec2018) ? Thanks a lot

          Comment


          • #6
            Originally posted by Saad Mohrabi View Post
            Hi Ken Chui,
            Thank you so much. Yes, its works . Thanks. Please, I have a following question: because I need the change in log stock prices from December 31, 2018 to March 31, 2019 ( ∆P), there is must be divided by March 31,2019) ? or just like as you have mentioned gen v1 = log(March2019) - log(Dec2018) ? Thanks a lot
            It's more of an English expression of mathematical process. When you say "change in log stock prices", what is that "change?" If it's absolute change, use subtraction (-), if it's relative change, use division (/). You will have to check the methods and make a decision.

            I know very little about finance data analysis, but I found the concept of dividing a log-transformed number by another log-transformed number hard to grasp.

            Comment

            Working...
            X