Announcement

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

  • #16
    Dear Nick Cox and Clyde Schechter

    I am calculating the stock price crash risk. The crash variable is measured as: An indicator variable that equals one if a firm experiences one or more firm-specific weekly returns exceeding 3.09
    standard deviations below the mean firm-specific weekly returns over the fiscal year and zero otherwise, with 3.09 chosen to generate frequencies of 0.1% in a normal distribution. I am having the firm-specific weekly returns and i have calculated the standard deviation and mean by the following commands:

    egen sd=sd(rret), by(permno year)

    egen mean=mean(rret), by(permno year)

    I want to ask that how I will generate the indicator variable to 1 if a firm experiences one or more firm-specific weekly returns exceeding 3.09 standard deviations below the mean firm-specific weekly returns. Kindly assist me in this regard.

    Regards

    Comment


    • #17
      If I understand you correctly:
      Code:
      by permno year, sort: egen crash_variabe = max(return < mean - 3.09*sd)
      Replace "return" by the actual name of the variable containing the weekly return.

      Comment


      • #18
        Thank you so much, Clyde, for your assistance. It really worked for me. I need some further help in the generation of another variable. It is as follows:

        DturnT: The difference between the average monthly share turnover over fiscal year T−1 and the average monthly share turnover over fiscal year T, where monthly share turnover is calculated as the monthly trading volume divided by the total number of shares outstanding over the month.

        I have used the following commands for generating this variable.

        gen month=mofd(date)
        format month %td
        bys month (date): keep if _n==_N
        tsset month
        **gen monthly share turnover
        gen mst= vol/ shrout
        **change in monthly share turnover
        gen d_mst=d.mst

        Kindly let me know whether the commands that I am using are correct enough for creating my desired variable.

        Comment


        • #19
          I can't comment on #18's correctness except that a monthly date variable would be better formatted as %tm not %td.

          Comment


          • #20
            Dear Nick Cox and Clyde Schechter

            I have daily data of stock returns and I want to convert its frequency to weekly returns. can you please help me out in this regard by telling the appropriate code for it?

            Comment


            • #21
              Example data using -dataex-, please.

              Comment


              • #22
                The following two blog posts discuss the conversion of daily data to a weekly or monthly frequency, both for stock prices and stock returns

                https://fintechprofessor.com/ascol-s...y-and-monthly/

                https://fintechprofessor.com/2017/10...ct-of-returns/
                Regards
                --------------------------------------------------
                Attaullah Shah, PhD.
                Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                FinTechProfessor.com
                https://asdocx.com
                Check out my asdoc program, which sends outputs to MS Word.
                For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                Comment


                • #23
                  Dear Clyde/Nick/Attaullah

                  In reference to comment # 18 I am sharing my data.

                  * Example generated by -dataex-. To install: ssc install dataex
                  clear
                  input double permno long date double(vol shrout) float year
                  10001 16072 9470 2596 2004
                  10001 16075 7516 2596 2004
                  10001 16076 5743 2596 2004
                  10001 16077 6825 2596 2004
                  10001 16078 33624 2596 2004
                  10001 16079 11707 2596 2004
                  10001 16082 11026 2596 2004
                  10001 16083 15360 2596 2004
                  10001 16084 22025 2596 2004
                  10001 16085 5946 2596 2004
                  10001 16086 5425 2596 2004
                  10001 16090 6360 2596 2004
                  10001 16091 7845 2596 2004
                  10001 16092 12150 2596 2004
                  10001 16093 12200 2596 2004
                  10001 16096 11743 2596 2004
                  10001 16097 7200 2596 2004
                  10001 16098 4192 2596 2004
                  10001 16099 3625 2596 2004
                  10001 16100 5042 2596 2004
                  10001 16103 11650 2596 2004
                  10001 16104 9585 2596 2004
                  10001 16105 7250 2596 2004
                  10001 16106 3800 2596 2004
                  10001 16107 3300 2596 2004
                  10001 16110 2780 2596 2004
                  10001 16111 4800 2596 2004
                  10001 16112 950 2596 2004
                  10001 16113 5100 2596 2004
                  10001 16114 3400 2596 2004
                  10001 16118 4670 2596 2004
                  10001 16119 24030 2596 2004
                  10001 16120 7100 2596 2004
                  10001 16121 6055 2596 2004
                  10001 16124 3000 2596 2004
                  10001 16125 4725 2596 2004
                  10001 16126 800 2596 2004
                  10001 16127 2342 2596 2004
                  10001 16128 2328 2596 2004
                  10001 16131 7695 2596 2004
                  10001 16132 1100 2596 2004
                  10001 16133 9000 2596 2004
                  10001 16134 7100 2596 2004
                  10001 16135 4186 2596 2004
                  10001 16138 2713 2596 2004
                  10001 16139 6950 2596 2004
                  10001 16140 3584 2596 2004
                  10001 16141 900 2596 2004
                  10001 16142 11640 2596 2004
                  10001 16145 1800 2596 2004
                  10001 16146 19850 2596 2004
                  10001 16147 13600 2596 2004
                  10001 16148 1500 2596 2004
                  10001 16149 900 2596 2004
                  10001 16152 6400 2596 2004
                  10001 16153 7293 2596 2004
                  10001 16154 1550 2596 2004
                  10001 16155 4620 2596 2004
                  10001 16156 5550 2596 2004
                  10001 16159 10000 2596 2004
                  10001 16160 6150 2596 2004
                  10001 16161 915 2598 2004
                  10001 16162 330 2598 2004
                  10001 16163 3309 2598 2004
                  10001 16166 400 2598 2004
                  10001 16167 2009 2598 2004
                  10001 16168 1220 2598 2004
                  10001 16169 1600 2598 2004
                  10001 16173 400 2598 2004
                  10001 16174 1099 2598 2004
                  10001 16175 4200 2598 2004
                  10001 16176 2000 2598 2004
                  10001 16177 0 2598 2004
                  10001 16180 9828 2598 2004
                  10001 16181 5200 2598 2004
                  10001 16182 10911 2598 2004
                  10001 16183 7855 2598 2004
                  10001 16184 3800 2598 2004
                  10001 16187 4977 2598 2004
                  10001 16188 3659 2598 2004
                  10001 16189 3700 2598 2004
                  10001 16190 2418 2598 2004
                  10001 16191 600 2598 2004
                  10001 16194 300 2598 2004
                  10001 16195 6800 2598 2004
                  10001 16196 5000 2598 2004
                  10001 16197 900 2598 2004
                  10001 16198 3850 2598 2004
                  10001 16201 2300 2598 2004
                  10001 16202 1900 2598 2004
                  10001 16203 538 2598 2004
                  10001 16204 2730 2598 2004
                  10001 16205 1240 2598 2004
                  10001 16208 1800 2598 2004
                  10001 16209 9945 2598 2004
                  10001 16210 1650 2598 2004
                  10001 16211 2106 2598 2004
                  10001 16212 1500 2598 2004
                  10001 16215 100 2598 2004
                  10001 16216 8782 2598 2004
                  end
                  format %d date
                  [/CODE]

                  I have the data in a daily format and through commands mentioned in comment #18, I am converting it monthly frequency. with those commands, the data is converted into monthly form but the issue is my no of observations are reduced to a very small number. I have to use this monthly share turnover variable with other variables that are on an annual basis. The observations of other variables are around 18000 while this variable only has 132 observations which are not achieving my goals.

                  I need some suggestions from you people that what should I do in this regard. In addition, I have to calculate the average value of the monthly share turnover in order to merge it with the other annual variables of my estimations. Kindly assist me in this regard.

                  Comment

                  Working...
                  X