Announcement

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

  • Matching on size, sector and bookvalue

    Dear Statalisters,

    I have unbalanced panel data in which I ran the following regression:

    xtreg return1 sales bmv size, fe robust

    I want to estimate the effect of the sales variable using the control firm approach. I am looking to match all firms (gvkey) based on size, bmv and sector for which I want to use the following criteria:

    1. An exact match on sector
    2. A match on size in which the companies do not deviate more than 20%. That is; the bigger company should not exceed the size of the smaller one with more than 20%.
    3. A match on bmv with a maximal difference in bmv of 1.

    Ideally, I want to match on all of the criteria above. If this leaves too few cases I want to match for example only on size and sector, or only size.

    I am aware of the program vmatch, but I cant figure out how to implement the above. Furthermore, I would like to know how to run a regression after the firms have been matched.

    Data:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long gvkey double(year sector) float(return1 size sales bmv)
    1010 1978 600   6.345826    280.32  6.781209  .8813903
    1010 1976 600  -6.699375  299.7015  8.808118 1.0953922
    1010 1979 600    53.6258 283.33688  5.879218   .813289
    1010 1981 600  2.1186163   313.072  6.537877  .7747696
    1010 1982 600   50.55416 263.76563  8.582885  .7027547
    1010 1977 600   11.55988 265.26486  7.374261  .9017768
    1034 1990 905   29.85151 291.04175  20.55946 2.6216435
    1034 1993 905   36.55426    344.96  40.02413 1.8663535
    1036 1996 925  29.658934 1104.5775  11.46314 1.3449283
    1036 1995 925  1.4802907  1095.906 14.481897 1.7737268
    1036 1999 925   16.87666  711.5314  8.134807  .7740389
    1040 1982 976 -13.743507  381.3062  30.71273  .9000438
    1040 1977 976   6.278054  322.8062  7.531488  .9499554
    1040 1980 976 -31.605017 590.03314 10.405457 1.3220668
    1040 1979 976   81.03148  252.5861  4.786434  .6126553
    1075 2001 700 -26.151974 3845.9976 12.320755 1.5388157
    1075 1997 700 -17.095808  3768.613 16.097134 1.8588073
    1075 1974 700  30.650696   231.625  6.599003  .7669473
    1075 1972 700   -6.13595  216.5625   9.00655 1.0318102
    1075 1985 700   12.18468   2279.43  7.901998 1.2089298
    1075 2006 700 -26.751545  4830.549  14.68854  1.401737
    1075 1999 700   52.29184 2388.3833 14.220503 1.0828071
    1075 1976 700   16.97484  424.9895  7.647134   .915117
    1075 2002 700   21.73949  3033.283 18.886158 1.1292294
    1075 1983 700  37.957085   1214.64  5.262281  .7655273
    1075 1986 700 -2.9878926  2571.548 10.563104  1.242687
    1075 1981 700  27.329445 1201.8815  6.395172  .9421918
    1075 2007 700  -21.53413  3525.049 11.464052  .9981419
    1075 1982 700 -19.257174   1541.67  7.427938 1.0686457
    1075 1998 700  -21.78406 3085.4365 12.673917 1.4262302
    1075 1980 700  35.081047  797.9834  6.068846  .7595133
    1075 1979 700   20.62846  645.4715  5.829506  .7430674
    1075 2004 700  -3.845828 4180.8584  17.12278  1.417146
    1075 1987 700  -52.68477  2363.229   8.07476 1.0313256
    1075 2005 700   25.58473  3878.603  21.39632 1.1324507
    1075 1977 700    9.67778  542.0769  6.754051  .9343415
    1075 1973 700 -19.913095   228.125  6.939164  .8799455
    1075 2003 700  12.215794 3594.9766 14.916895  1.270409
    1075 1978 700 -19.900465  669.3187   6.48266  .9052812
    1075 2000 700  2.4303315  3886.703 12.834804 1.6312082
    1075 1984 700  37.643986 1616.9423  7.072704  .9534296
    1076 2003 976  20.556307  823.1372  22.42392 2.5708096
    1076 2007 976   21.12721 1146.8973 14.455772  1.703195
    1076 2004 976   32.44091    995.46 18.872475 2.6533005
    1076 2005 976 -1.7322134 1371.7046 23.637316 3.1571834
    1076 2002 976   52.77767  442.5517 15.557252 1.5774714
    1076 2006 976  -23.15816 1432.3606 17.638062  2.359679
    1078 1976 905  26.339006  1283.337  13.35397 2.2327292
    1078 2004 905  -6.905262  72292.56   22.3868  5.046325
    1078 1984 905   51.11526  6367.579 15.856254 3.9730325
    end

  • #2
    Well, your problem is incompletely posed because you have given no indication of which firms are cases and which are controls. Also, forming matched pairs in panel data is tricky because a pair of gvkeys could be a good match in one year but not in another. So you need to specify which year's variables to use for the purposes of deciding what's a good match. (I realize that sector probably won't vary by year, but size certainly can, and may be bmv to [whatever that is].)

    Comment


    • #3
      The firms that score low on the variable sales are the cases. Firms that score higher on the variable sales are controls. Do I need to specify an exact value of sales under which a firm is considered as a case (lets say 10)? I thought I could just match on the other factors and regress the return of the pairs on the variable sales, maybe this is incorrect. BMV is book to market value. Furthermore, As for the years, I would like to use yearly rebalancing so that two companies can be a match in certain years but not in others. Is that achievable?
      Last edited by Simon Fischer; 25 Jun 2017, 13:58.

      Comment


      • #4
        Yes, you have to specify some cutoff which distinguishes cases vs controls. As for allowing different firm pairings in different years, it is possible, but it doesn't make a lot of sense to me. To be honest, I don't think I would do this, and I certainly would be queasy trying to interpret the results. But here is how it could be done, if you decide to go through with it.

        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input long gvkey double(year sector) float(return1 size sales bmv)
        1010 1978 600   6.345826    280.32  6.781209  .8813903
        1010 1976 600  -6.699375  299.7015  8.808118 1.0953922
        1010 1979 600    53.6258 283.33688  5.879218   .813289
        1010 1981 600  2.1186163   313.072  6.537877  .7747696
        1010 1982 600   50.55416 263.76563  8.582885  .7027547
        1010 1977 600   11.55988 265.26486  7.374261  .9017768
        1034 1990 905   29.85151 291.04175  20.55946 2.6216435
        1034 1993 905   36.55426    344.96  40.02413 1.8663535
        1036 1996 925  29.658934 1104.5775  11.46314 1.3449283
        1036 1995 925  1.4802907  1095.906 14.481897 1.7737268
        1036 1999 925   16.87666  711.5314  8.134807  .7740389
        1040 1982 976 -13.743507  381.3062  30.71273  .9000438
        1040 1977 976   6.278054  322.8062  7.531488  .9499554
        1040 1980 976 -31.605017 590.03314 10.405457 1.3220668
        1040 1979 976   81.03148  252.5861  4.786434  .6126553
        1075 2001 700 -26.151974 3845.9976 12.320755 1.5388157
        1075 1997 700 -17.095808  3768.613 16.097134 1.8588073
        1075 1974 700  30.650696   231.625  6.599003  .7669473
        1075 1972 700   -6.13595  216.5625   9.00655 1.0318102
        1075 1985 700   12.18468   2279.43  7.901998 1.2089298
        1075 2006 700 -26.751545  4830.549  14.68854  1.401737
        1075 1999 700   52.29184 2388.3833 14.220503 1.0828071
        1075 1976 700   16.97484  424.9895  7.647134   .915117
        1075 2002 700   21.73949  3033.283 18.886158 1.1292294
        1075 1983 700  37.957085   1214.64  5.262281  .7655273
        1075 1986 700 -2.9878926  2571.548 10.563104  1.242687
        1075 1981 700  27.329445 1201.8815  6.395172  .9421918
        1075 2007 700  -21.53413  3525.049 11.464052  .9981419
        1075 1982 700 -19.257174   1541.67  7.427938 1.0686457
        1075 1998 700  -21.78406 3085.4365 12.673917 1.4262302
        1075 1980 700  35.081047  797.9834  6.068846  .7595133
        1075 1979 700   20.62846  645.4715  5.829506  .7430674
        1075 2004 700  -3.845828 4180.8584  17.12278  1.417146
        1075 1987 700  -52.68477  2363.229   8.07476 1.0313256
        1075 2005 700   25.58473  3878.603  21.39632 1.1324507
        1075 1977 700    9.67778  542.0769  6.754051  .9343415
        1075 1973 700 -19.913095   228.125  6.939164  .8799455
        1075 2003 700  12.215794 3594.9766 14.916895  1.270409
        1075 1978 700 -19.900465  669.3187   6.48266  .9052812
        1075 2000 700  2.4303315  3886.703 12.834804 1.6312082
        1075 1984 700  37.643986 1616.9423  7.072704  .9534296
        1076 2003 976  20.556307  823.1372  22.42392 2.5708096
        1076 2007 976   21.12721 1146.8973 14.455772  1.703195
        1076 2004 976   32.44091    995.46 18.872475 2.6533005
        1076 2005 976 -1.7322134 1371.7046 23.637316 3.1571834
        1076 2002 976   52.77767  442.5517 15.557252 1.5774714
        1076 2006 976  -23.15816 1432.3606 17.638062  2.359679
        1078 1976 905  26.339006  1283.337  13.35397 2.2327292
        1078 2004 905  -6.905262  72292.56   22.3868  5.046325
        1078 1984 905   51.11526  6367.579 15.856254 3.9730325
        end
        
        gen long obs_no = _n
        gen byte case = (sales < 10)
        
        preserve
        keep if case
        tempfile cases
        save `cases'
        restore
        keep if !case
        tempfile controls
        save `controls'
        
        //    DO THE MATCHING
        use `cases', clear
        rangejoin bmv -1 1 using `controls', by(sector year) suffix(_control)
        drop if missing(gvkey_control)
        keep if inrange(size/size_control, 1/1.20, 1.20)
        
        //    NOW SET IT UP FOR THE MATCHED-PAIR REGRESSION
        rename (gvkey year return1 size sales bmv obs_no) =_case
        gen long pair_num = _n
        reshape long gvkey year return1 size sales bmv obs_no, i(pair_num) j(_case_status) string
        encode _case_status, gen(case_status)
        drop _case_status
        xtset pair_num case_status
        
        //    AND DO THE PAIRED REGRESSION
        xtreg return1 sales, fe robust
        Notes:

        1. This code has been tested to the extent that it is known not to contain syntax errors. However, the example data you gave does not actually contain any pairs of observations that meet all of your matching criteria (or even just two of the three.) Consequently everything after the -rangejoin- command is, for practical purposes, untested.

        2. The -rangejoin- command is not part of official Stata. It was written by Robert Picard. Install it by running -ssc install rangejoin-. For full instructions and worked examples, so you understand what the code is doing, read -help rangejoin-.
        Last edited by Clyde Schechter; 25 Jun 2017, 14:39.

        Comment


        • #5
          Thanks a lot. Could you maybe clarify what makes you think that you would not do this yourself? If so, what do you think would be a better alternative given that I want to employ a control-firm approach for measuring the effect of the sales characteristic on stock returns?

          I am not able to run this code in Stata at this moment, I will do this tomorrow and report back if there are any errors.

          Comment


          • #6
            What makes me uncomfortable with it is the matched-pairs where the same case firm can be matched to different control firms in different years. The result of that is that while the matching will largely control for extraneous variance due to size and bmv, it completely abandons any pretense of control for other attribute of specific firms (gvkeys), including time-invariant unmeasured ones. Indeed, it appears to go out of its way to introduce precisely this kind of extraneous variance.

            Now, I am an epidemiologist and I know very little about finance. If you are persuaded that variation in your outcome (return1) attributable to size and bmv are far greater than all variation attributable to other observed and unobserved characteristics of firms combined, then I suppose this approach would be OK. But I can tell you that in epidemiology it is vanishingly rare in observational studies that we can identify just two or a small handful of variables so important that we can abandon attempting to adjust for anything else. In fact, I can't recall a single such situation in my entire career.

            But finance is a different kettle of fish in many ways. So I think you could use some guidance from somebody with expertise in your field. You could ask some of your colleagues about this. Also there are several economists, econometricians, and finance people who frequently respond on this Forum, and perhaps some of them will chime in.

            Comment


            • #7
              Originally posted by Clyde Schechter View Post
              What makes me uncomfortable with it is the matched-pairs where the same case firm can be matched to different control firms in different years. The result of that is that while the matching will largely control for extraneous variance due to size and bmv, it completely abandons any pretense of control for other attribute of specific firms (gvkeys), including time-invariant unmeasured ones. Indeed, it appears to go out of its way to introduce precisely this kind of extraneous variance.

              .
              I discussed this with my supervisor and he agrees with your concerns. He asserted that that this is also one of the reasons why empirical finance papers take years before they eventually get published, because the model is always almost too simplistic and fails to capture other sources of variance. However, he agreed that when I thoroughly document the drawbacks of using this approach, I should go through with it.

              As for your code, it worked and didnt return any syntax errors. However, I noticed that sample firms as well as control firms get matched several times in a specific year. Ideally, I want to match a specific firm only once per year (either as a control or a sample firm). How do I modify your code to accomplish that?

              Code:
              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input long pair_num double(fyrc sector) byte case long gvkey double fyrc_control float(return1 size sales bmv) long obs_no byte case_control double year long case_status
               1 12 600 1  1010 12  -6.699375  299.7015  8.808118 1.0953922     1 0 1976 1
               1 12 600 1  4941 12 -13.787356  357.0063 11.484618  .8109263  7509 0    . 2
               2 12 600 1  1010 12   6.345826    280.32  6.781209  .8813903     3 0 1978 1
               2 12 600 1  5865 12    9.46705  335.6365 36.105087   .555928  9291 0    . 2
               3 12 600 1  1010 12   50.55416 263.76563  8.582885  .7027547     6 0 1982 1
               3 12 600 1  9819 12  -21.61522 252.53375 16.540112 1.1104827 16871 0    . 2
               4 12 600 1  1010 12   50.55416 263.76563  8.582885  .7027547     6 0 1982 1
               4 12 600 1 13322 12  -21.61522 252.53375 16.540112 1.1104827 21185 0    . 2
               5 12 600 1  1010 12   50.55416 263.76563  8.582885  .7027547     6 0 1982 1
               5 12 600 1  4790 12  30.044947 223.66287 17.738972 1.1821817  7260 0    . 2
               6 12 700 1  1075 12   -6.13595  216.5625   9.00655 1.0318102    16 0 1972 1
               6 12 700 1  9445 12  -19.27787 252.86113  10.93481 1.2528608 16297 0    . 2
               7 12 700 1  1075 12   -6.13595  216.5625   9.00655 1.0318102    16 0 1972 1
               7 12 700 1  2858 12 -13.092242  189.6015   10.3125 1.2922764  3281 0    . 2
               8 12 700 1  1075 12   -6.13595  216.5625   9.00655 1.0318102    16 0 1972 1
               8 12 700 1  5870 12 -4.5969577 219.58125 11.277928  1.399953  9306 0    . 2
               9 12 700 1  1075 12   -6.13595  216.5625   9.00655 1.0318102    16 0 1972 1
               9 12 700 1  6825 12  -23.08905  231.4687  12.36012 1.4798937 11108 0    . 2
              10 12 700 1  1075 12   -6.13595  216.5625   9.00655 1.0318102    16 0 1972 1
              10 12 700 1 23465 12  -23.08906 231.46875 12.360122  1.479894 23630 0    . 2
              11 12 700 1  1075 12   -6.13595  216.5625   9.00655 1.0318102    16 0 1972 1
              11 12 700 1 10277 12 -13.963923 219.72713 11.530116  1.558503 17828 0    . 2
              12 12 700 1  1075 12   -6.13595  216.5625   9.00655 1.0318102    16 0 1972 1
              12 12 700 1 10327 12 -13.963923 219.72713 11.530116  1.558503 17921 0    . 2
              13 12 700 1  1075 12   -6.13595  216.5625   9.00655 1.0318102    16 0 1972 1
              13 12 700 1  7537 12  -4.624447   259.026 12.905877   1.70283 12446 0    . 2
              14 12 700 1  1075 12 -19.913095   228.125  6.939164  .8799455    17 0 1973 1
              14 12 700 1 12612 12  -22.35911  233.7855 10.427808 1.0455009 20860 0    . 2
              15 12 700 1  1075 12 -19.913095   228.125  6.939164  .8799455    17 0 1973 1
              15 12 700 1  8684 12 -11.151217     229.5 10.714286 1.2223963 14947 0    . 2
              16 12 700 1  1075 12 -19.913095   228.125  6.939164  .8799455    17 0 1973 1
              16 12 700 1  4189 12   27.79185  217.8049  13.31072  1.235422  5984 0    . 2
              17 12 700 1  1075 12 -19.913095   228.125  6.939164  .8799455    17 0 1973 1
              17 12 700 1  7537 12 -21.180563  231.1785 10.687034 1.4420177 12447 0    . 2
              18 12 700 1  1075 12   16.97484  424.9895  7.647134   .915117    19 0 1976 1
              18 12 700 1  9445 12   7.472079  369.0986  10.50576 1.2098738 16301 0    . 2
              19 12 700 1  1075 12   16.97484  424.9895  7.647134   .915117    19 0 1976 1
              19 12 700 1  9828 12   7.472079  369.0986  10.50576 1.2098738 16877 0    . 2
              20 12 700 1  1075 12   16.97484  424.9895  7.647134   .915117    19 0 1976 1
              20 12 700 1  3039 12   7.928319   464.625 12.024457 1.2352645  3809 0    . 2
              21 12 700 1  1075 12   16.97484  424.9895  7.647134   .915117    19 0 1976 1
              21 12 700 1  8113 12   6.044675  434.0543 11.854838 1.4089195 13826 0    . 2
              22 12 700 1  1075 12    9.67778  542.0769  6.754051  .9343415    20 0 1977 1
              22 12 700 1  4103 12  -3.079461  567.5312  11.18288  .8381706  5816 0    . 2
              23 12 700 1  1075 12    9.67778  542.0769  6.754051  .9343415    20 0 1977 1
              23 12 700 1 11052 12  11.772552 520.28925 10.388996  1.025039 19326 0    . 2
              24 12 700 1  1075 12 -19.900465  669.3187   6.48266  .9052812    21 0 1978 1
              24 12 700 1  4240 12  17.465143  788.6182 15.285378 1.1225467  6086 0    . 2
              25 12 700 1  1075 12 -19.900465  669.3187   6.48266  .9052812    21 0 1978 1
              25 12 700 1  4393 12  35.150795  614.5112 12.845436 1.1823002  6198 0    . 2
              end
              label values case_status case_status
              label def case_status 1 "_case", modify
              label def case_status 2 "_control", modify



              Given that panel data is deciared as xtset pair_num case_status, my interpretation of the xtreg return1 sales regression is that the coefficient of sales represents the effect of a 1 unit increase in the variables sales on the 1-year return, controlled for the factors size, bmv and sector. Is this correct? Lastly, I would like to know how to measure the absolute difference in return1 between case and control firm and how to test if that difference is statistically significant.

              I almost feel bad for asking all of this. Thanks for helping me out here, much appreciated.

              Comment


              • #8
                As for your code, it worked and didnt return any syntax errors. However, I noticed that sample firms as well as control firms get matched several times in a specific year. Ideally, I want to match a specific firm only once per year (either as a control or a sample firm). How do I modify your code to accomplish that?
                OK, that wasn't specified in the original problem, so the code was written to pair each case with all suitable controls. So, now you want to trim this down to just a single control per case. It's just a brief addition to the code:

                Code:
                gen long obs_no = _n
                gen byte case = (sales < 10)
                
                preserve
                keep if case
                tempfile cases
                save `cases'
                restore
                keep if !case
                tempfile controls
                save `controls'
                
                //    DO THE MATCHING
                use `cases', clear
                rangejoin bmv -1 1 using `controls', by(sector year) suffix(_control)
                drop if missing(gvkey_control)
                keep if inrange(size/size_control, 1/1.20, 1.20)
                
                //    NOW REDUCE TO ONE CONTROL PER CASE
                set seed 1234 // OR YOUR FAVORITE RANDOM NUMBER SEED
                gen double shuffle1 = runiform()
                gen double shuffle2 = runiform()
                by gvkey year (shuffle1 shuffle2), sort: keep if _n == 1
                drop shuffle*
                
                //    NOW SET IT UP FOR THE MATCHED-PAIR REGRESSION
                rename (gvkey year return1 size sales bmv obs_no) =_case
                gen long pair_num = _n
                reshape long gvkey year return1 size sales bmv obs_no, i(pair_num) j(_case_status) string
                encode _case_status, gen(case_status)
                drop _case_status
                xtset pair_num case_status
                
                //    AND DO THE PAIRED REGRESSION
                xtreg return1 sales, fe robust
                Given that panel data is deciared as xtset pair_num case_status, my interpretation of the xtreg return1 sales regression is that the coefficient of sales represents the effect of a 1 unit increase in the variables sales on the 1-year return, controlled for the factors size, bmv and sector. Is this correct?
                Yes. I would say "adjusted for" rather than "controlled for." Really, you only "control" for variables if you have actually set their values in an experimental setting. I realize that people use "control" in this context all the time. but it isn't really accurate.

                Lastly, I would like to know how to measure the absolute difference in return1 between case and control firm and how to test if that difference is statistically significant.
                So what you want is a paired t-test here. To do that directly would require going back to wide layout. However, you can emulate it with the following command on the data as it is after the above:

                Code:
                xtreg return1 i.case_control, fe
                That is, the t-statistic and p-value for 2.case_status in the output of this -xtreg, fe- are identical to what you would get with the paired ttest.

                I almost feel bad for asking all of this.
                Don't feel bad. If I felt it were excessive, I would either respond by saying as much and suggesting other ways to get help that exceeds what's reasonable in the forum, or if I felt it were truly abusive, I would just not respond at all, perhaps sending a private message explaining why. Remember that nobody is forced, or even paid, participate in this Forum. We all do this because we want to, plain and simple.

                Comment


                • #9
                  Hello members of Stata list,

                  I want to momentarily revived the content of this post by appending an additional question. I am doing something similar to Simon (postĀ“s creator) but, in my case, I am working with stocks (each differentiated by a distinct number in the variable "cusip").

                  - The case group is formed by IPO stocks (those stocks for which I have IPO date) whose value in the var "IPO" is set in 1.
                  - The control group is formed by all other stocks in the market for which I have no IPO date or it took place sooner than my sample period. Their value for the var "IPO" is set in 0.

                  The control should comply with the following rules (and, thereafter, I describe when the match should happen):

                  - Same economic sector (var "gsector"). Each "cusip" has assigned a distinct "gsector" for the whole sample period.
                  - A range of size of 30% (var "me").
                  - The minimized book-to-market ratio dispersion (var "btm").

                  Basically, I want to match each IPO stock (case) with one control at the end of the year when the IPO takes place. So, for example, if the IPO happens in 1982, the case and control should be matched at the end of December in that year. In other words, using "me" and "btm" observations at the date "year(IPOdate)m12".

                  I do not ever need to change the control unless the control stops trading (meaning: no more observations for that particular "cusip" after then). In that case, at the time that happens, a new control should be drawn from the original list of candidates with the next minimized book-to-market dispersion.



                  This is what the dataset looks like ...


                  Click image for larger version

Name:	Screenshot (353).png
Views:	1
Size:	38.7 KB
ID:	1489691






                  So far, applying the code displayed n this post, I have the following:

                  Code:
                  gen long obs_no = _n
                  gen byte case = (IPO==1)
                  
                  preserve
                  keep if case
                  tempfile cases
                  save `cases'
                  restore
                  keep if !case
                  tempfile controls
                  save `controls'
                  
                  *DO THE MATCHING (here is where btm should be minimized and the date when that happens set to year(IPOdate)m12 )
                  use `cases', clear
                  rangejoin btm -.10 .10 using `controls', by(gsector year) suffix(_control)
                  drop if missing(cusip_control)
                  keep if inrange(me/me_control, 1/1.30, 1.30)
                  
                  *NOW REDUCE TO ONE CONTROL PER CASE (I need to reduce this to only one control per case forever, and only change if the control disappears i.e. no more obs for that "cusip" )
                  set seed 1234
                  gen double shuffle1 = runiform()
                  gen double shuffle2 = runiform()
                  by cusip year (shuffle1 shuffle2), sort: keep if _n == 1
                  drop shuffle*



                  So, in sum, I am still stuck in minimizing btm, matching the cases and control only once in m12 of year(IPOdate), and substituting one control for the next best control if the former stops trading (meaning: no more observations for that "cusip").



                  Thank you for your time. I really appreciate it.

                  Comment


                  • #10
                    This is too complicated to do without example data to work with. And, as is pointed out in the Forum FAQ, screenshots of data are not helpful and you are asked not to use them when posting. The helpful way to give example data is with the -dataex- command. If you are running version 15.1 or a fully updated version 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

                    Please make sure that your example data includes some cases and controls that could be matched together.

                    When asking for help with code, always show example data. When showing example data, always use -dataex-.

                    Comment


                    • #11
                      Thank you for helping me understand how important is dataex. I hope that the following samples help in solving this puzzle.

                      Below I post the data on four companies (four different "cusip"). One is a case, three are controls. I post data on all their trading months. I hope that it is not too much; nonetheless, now that I now the dataex function I want to provide you with the right info.


                      These are the case followed by three controls. I post their history of trading from the IPO date of the case company (cusip "00077R10").

                      The way I have found the controls is the following:

                      Code:
                      gen x=0
                      replace x=1 if me<49.381*1.3 & me>49.381*0.65 & gsector=="40" & month==6 & year==1994 & IPO==0
                      Wherein the company with cusip "00077R10" has a me of 49.381 (and in this case I had to set the boundaries at +30% and -35% because I did not find controls otherwise), "IPO" equals 0 if it is a control, and 1994m6 is the IPO date.


                      For the case ...

                      Code:
                      * Example generated by -dataex-. To install: ssc install dataex
                      clear
                      input long date str10 cusip double(ret year) str2 gsector float(me btm) long IPOdate float(IPO x month fulldate)
                      413 "00077R10"  -6.122449040412903 1994 "40"    49.381   .3244783 12564 1 1  6 12570
                      414 "00077R10"                   0 1994 "40"    49.381   .3244783 12564 1 0  7 12600
                      415 "00077R10"  30.434781312942505 1994 "40"     64.41  .24876665 12564 1 0  8 12631
                      416 "00077R10"   1.666666753590107 1994 "40"   65.4835  .24468854 12564 1 0  9 12662
                      417 "00077R10"  1.6393441706895828 1994 "40"    66.557  .24074194 12564 1 0 10 12692
                      418 "00077R10"   6.451612710952759 1994 "40"    70.851  .22615153 12564 1 0 11 12723
                      419 "00077R10"  22.727273404598236 1994 "40"   86.9535   .1842716 12564 1 0 12 12753
                      420 "00077R10"   4.938271641731262 1995 "40"    91.715  .20684634 12564 1 0  1 12784
                      421 "00077R10"    2.35294122248888 1995 "40"    93.873  .20209123 12564 1 0  2 12815
                      422 "00077R10"  13.793103396892548 1995 "40"   106.821  .17759533 12564 1 0  3 12843
                      423 "00077R10"  2.0202020183205605 1995 "40"   109.181  .17375652 12564 1 0  4 12874
                      424 "00077R10"   4.950495064258575 1995 "40"   114.586  .16556047 12564 1 0  5 12904
                      425 "00077R10"  11.320754885673523 1995 "40"   127.558  .14872381 12564 1 0  6 12935
                      426 "00077R10"   6.779661029577255 1995 "40"   136.458  .13902381 12564 1 0  7 12965
                      427 "00077R10"    8.33333358168602 1995 "40"  147.8295  .12832966 12564 1 0  8 12996
                      428 "00077R10"  10.989011079072952 1995 "40"  164.0745  .11562376 12564 1 0  9 13027
                      429 "00077R10"   16.83168262243271 1995 "40"  192.7235   .0984359 12564 1 0 10 13057
                      430 "00077R10"   15.25423675775528 1995 "40"   222.122  .08540762 12564 1 0 11 13088
                      431 "00077R10"  29.411765933036804 1995 "40"   287.452 .065996796 12564 1 0 12 13118
                      432 "00077R10"   9.090909361839294 1996 "40"   313.584   .5776754 12564 1 0  1 13149
                      433 "00077R10"            17.96875 1996 "40"    369.95   .4896601 12564 1 0  2 13180
                      434 "00077R10"  23.178808391094208 1996 "40"     455.7   .3975198 12564 1 0  3 13209
                      435 "00077R10"   34.40860211849213 1996 "40"  838.5625   .2160242 12564 1 0  4 13240
                      436 "00077R10"   .4000000189989805 1996 "40"  841.9167  .21516353 12564 1 0  5 13270
                      437 "00077R10" -19.920319318771362 1996 "40"  674.2042   .2686868 12564 1 0  6 13301
                      438 "00077R10"   .9950248524546623 1996 "40"   689.591  .26269162 12564 1 0  7 13331
                      439 "00077R10"  11.330049484968185 1996 "40"   767.722  .23595753 12564 1 0  8 13362
                      440 "00077R10"   27.43362784385681 1996 "40"   978.336   .1851611 12564 1 0  9 13393
                      441 "00077R10"   -3.81944440305233 1996 "40"  943.5313   .1919913 12564 1 0 10 13423
                      442 "00077R10" -37.906137108802795 1996 "40"   585.875   .3091953 12564 1 0 11 13454
                      443 "00077R10"  -8.430232852697372 1996 "40"  536.4844   .3376609 12564 1 0 12 13484
                      444 "00077R10"  11.428571492433548 1997 "40"  597.7969   .3246853 12564 1 0  1 13515
                      445 "00077R10"   6.552706658840179 1997 "40"  636.9688    .304718 12564 1 0  2 13546
                      446 "00077R10"  -22.99465239048004 1997 "40"     490.5   .3957102 12564 1 0  3 13574
                      447 "00077R10"   11.80555522441864 1997 "40"  550.9219    .352311 12564 1 0  4 13605
                      448 "00077R10"   59.62733030319214 1997 "40"  879.4219  .22070844 12564 1 0  5 13635
                      449 "00077R10"  -9.727626293897629 1997 "40"   793.875   .2444917 12564 1 0  6 13666
                      450 "00077R10"  -6.034482643008232 1997 "40"   745.996  .26018348 12564 1 0  7 13696
                      451 "00077R10"  -1.376146823167801 1997 "40"    735.73  .26381397 12564 1 0  8 13727
                      452 "00077R10"  2.7906976640224457 1997 "40"   756.262  .25665158 12564 1 0  9 13758
                      453 "00077R10" -14.932127296924591 1997 "40"  643.5945    .301581 12564 1 0 10 13788
                      454 "00077R10"  2.1276595070958138 1997 "40"   657.288    .295298 12564 1 0 11 13819
                      455 "00077R10"  -.5208333488553762 1997 "40"  653.8646  .29684407 12564 1 0 12 13849
                      456 "00077R10"   3.141361102461815 1998 "40"   674.134  .34209135 12564 1 0  1 13880
                      457 "00077R10"  15.228426456451416 1998 "40"   776.794  .29688102 12564 1 0  2 13911
                      458 "00077R10"  -.8810572326183319 1998 "40"    769.95     .29952 12564 1 0  3 13939
                      459 "00077R10"   2.888888865709305 1998 "40"  830.3326  .27773857 12564 1 0  4 13970
                      460 "00077R10" -11.447083950042725 1998 "40"  735.2838   .3136414 12564 1 0  5 14000
                      461 "00077R10"   -7.31707289814949 1998 "40"  681.4825   .3384025 12564 1 0  6 14031
                      462 "00077R10"  -26.31579041481018 1998 "40"   502.285   .4591326 12564 1 0  7 14061
                      463 "00077R10" -17.142857611179352 1998 "40"   416.179  .55412555 12564 1 0  8 14092
                      464 "00077R10"  -5.603448301553726 1998 "40"  392.8586  .58701885 12564 1 0  9 14123
                      465 "00077R10"   37.89954483509064 1998 "40"  541.9579   .4255227 12564 1 0 10 14153
                      466 "00077R10"  -9.933774918317795 1998 "40"   488.121   .4724554 12564 1 0 11 14184
                      467 "00077R10"  15.441176295280457 1998 "40"  563.4926  .40926075 12564 1 0 12 14214
                      468 "00077R10"   16.56050980091095 1999 "40"  656.8099          . 12564 1 0  1 14245
                      469 "00077R10"  -22.95081913471222 1999 "40"  506.0666          . 12564 1 0  2 14276
                      470 "00077R10" -1.4184396713972092 1999 "40"  498.8884          . 12564 1 0  3 14304
                      471 "00077R10"   .7194244768470526 1999 "40"  502.4775          . 12564 1 0  4 14335
                      472 "00077R10"  44.285714626312256 1999 "40"  725.0032          . 12564 1 0  5 14365
                      473 "00077R10"   256.6831588745117 1999 "40" 2585.9646          . 12564 1 0  6 14396
                      end
                      format %tm date
                      format %td IPOdate
                      format %td fulldate

                      For the controls ...

                      Code:
                      * Example generated by -dataex-. To install: ssc install dataex
                      clear
                      input long date str10 cusip double(ret year) str2 gsector float(me btm) long IPOdate float(IPO x month fulldate)
                      413 "00130310" -19.314927877022015 1994 "40" 33.644463 . . 0 1  6 12570
                      414 "00130310"                   0 1994 "40"         . . . 0 0  7 12600
                      415 "00130310"  -5.427980790998221 1994 "40"         . . . 0 0  8 12631
                      416 "00130310"   17.29217564264114 1994 "40" 37.328285 . . 0 0  9 12662
                      417 "00130310"   7.841906265890253 1994 "40"         . . . 0 0 10 12692
                      418 "00130310"  12.681747348601814 1994 "40"         . . . 0 0 11 12723
                      419 "00130310" -16.107361387034814 1994 "40" 38.135487 . . 0 0 12 12753
                      420 "00130310"   2.892314878487756 1995 "40"         . . . 0 0  1 12784
                      421 "00130310"  6.5190251968493484 1995 "40"         . . . 0 0  2 12815
                      422 "00130310"  -22.79608362636809 1995 "40"  32.27537 . . 0 0  3 12843
                      423 "00130310"   -9.09091345454579 1995 "40"         . . . 0 0  4 12874
                      424 "00130310" -22.479998077439756 1995 "40"         . . . 0 0  5 12904
                      425 "00130310"   9.597455066816817 1995 "40"  24.92831 . . 0 0  6 12935
                      426 "00130310"  -8.757005407621621 1995 "40"         . . . 0 0  7 12965
                      427 "00130310" -3.3023801137647246 1995 "40"         . . . 0 0  8 12996
                      428 "00130310" -13.340445180865789 1995 "40" 19.060074 . . 0 0  9 13027
                      429 "00130310"   -30.7881827422415 1995 "40"         . . . 0 0 10 13057
                      430 "00130310"  -50.00001601423829 1995 "40"         . . . 0 0 11 13088
                      431 "00130310"   33.45198849749875 1995 "40"  10.69875 . . 0 0 12 13118
                      432 "00130310"  30.000000000000004 1996 "40"         . . . 0 0  1 13149
                      433 "00130310"   7.692307692307687 1996 "40"         . . . 0 0  2 13180
                      434 "00130310"  -4.761904761904756 1996 "40"    14.265 . . 0 0  3 13209
                      435 "00130310" -15.000000000000014 1996 "40"         . . . 0 0  4 13240
                      436 "00130310"   -5.88235294117646 1996 "40"         . . . 0 0  5 13270
                      437 "00130310"  -18.75000000000001 1996 "40"     9.698 . . 0 0  6 13301
                      438 "00130310"  -19.23076923076923 1996 "40"         . . . 0 0  7 13331
                      439 "00130310" -23.809523809523803 1996 "40"         . . . 0 0  8 13362
                      440 "00130310"  -12.50000000000001 1996 "40"   7.54425 . . 0 0  9 13393
                      441 "00130310"  -17.88575314285714 1996 "40"         . . . 0 0 10 13423
                      442 "00130310"  137.02162781816764 1996 "40"         . . . 0 0 11 13454
                      443 "00130310"   5.519692462169079 1996 "40" 15.493733 . . 0 0 12 13484
                      444 "00130310"  11.296609788960875 1997 "40"         . . . 0 0  1 13515
                      445 "00130310"               3.125 1997 "40"         . . . 0 0  2 13546
                      end
                      format %tm date
                      format %td IPOdate
                      format %td fulldate
                      Code:
                      * Example generated by -dataex-. To install: ssc install dataex
                      clear
                      input long date str10 cusip double(ret year) str2 gsector float(me btm) long IPOdate float(IPO x month fulldate)
                      413 "00142G10"   .4307692404836416 1994 "40"  56.60688 . . 0 1  6 12570
                      414 "00142G10"   .4307692404836416 1994 "40"  56.60688 . . 0 0  7 12600
                      415 "00142G10"  1.9692307338118553 1994 "40"  57.56025 . . 0 0  8 12631
                      416 "00142G10"   .5151515360921621 1994 "40"  57.56025 . . 0 0  9 12662
                      417 "00142G10"   .5454545840620995 1994 "40"  57.56025 . . 0 0 10 12692
                      418 "00142G10"  3.5757575184106827 1994 "40"   59.3045 . . 0 0 11 12723
                      419 "00142G10"   -4.05176468193531 1994 "40"    55.816 . . 0 0 12 12753
                      420 "00142G10"   .6250000093132257 1995 "40"    55.816 . . 0 0  1 12784
                      421 "00142G10"   3.750000149011612 1995 "40"  57.56025 . . 0 0  2 12815
                      422 "00142G10"   -.909090880304575 1995 "40"  56.68813 . . 0 0  3 12843
                      423 "00142G10"  -.9230769239366055 1995 "40"    55.816 . . 0 0  4 12874
                      424 "00142G10"   .6250000093132257 1995 "40"    55.816 . . 0 0  5 12904
                      425 "00142G10"   2.968749962747097 1995 "40"  57.12419 . . 0 0  6 12935
                      426 "00142G10"   .6106870248913765 1995 "40"  57.12419 . . 0 0  7 12965
                      427 "00142G10"   3.664122149348259 1995 "40"  58.86844 . . 0 0  8 12996
                      428 "00142G10"  2.8148148208856583 1995 "40"  60.17662 . . 0 0  9 13027
                      429 "00142G10" -2.3188406601548195 1995 "40"  58.43238 . . 0 0 10 13057
                      430 "00142G10" -.14925372088328004 1995 "40"  57.99631 . . 0 0 11 13088
                      431 "00142G10"  1.3533834367990494 1995 "40"  58.43238 . . 0 0 12 13118
                      432 "00142G10"  2.0895522087812424 1996 "40"   59.3045 . . 0 0  1 13149
                      433 "00142G10"  2.0588235929608345 1996 "40"  60.17662 . . 0 0  2 13180
                      434 "00142G10"   9.275362640619278 1996 "40"  65.40938 . . 0 0  3 13209
                      435 "00142G10"  1.8133332952857018 1996 "40"   66.2815 . . 0 0  4 13240
                      436 "00142G10"  1.7894737422466278 1996 "40" 67.153625 . . 0 0  5 13270
                      437 "00142G10"  1.1168831028044224 1996 "40"  67.58969 . . 0 0  6 13301
                      438 "00142G10"    .815533039595584 1996 "40"  68.02575 . . 0 0  7 13331
                      end
                      format %tm date
                      format %td IPOdate
                      format %td fulldate
                      Code:
                      * Example generated by -dataex-. To install: ssc install dataex
                      clear
                      input long date str10 cusip double(ret year) str2 gsector float(me btm) long IPOdate float(IPO x month fulldate)
                      413 "01852J10"  -6.435643881559372 1994 "40"  49.94325  .9353796 . 0 1  6 12570
                      414 "01852J10" -1.0582010261714458 1994 "40"  49.41475  .9453837 . 0 0  7 12600
                      415 "01852J10"  -.5347593687474728 1994 "40"   49.1505  .9504663 . 0 0  8 12631
                      416 "01852J10"   5.376344174146652 1994 "40"   51.9155  .8998449 . 0 0  9 12662
                      417 "01852J10"  -5.102040991187096 1994 "40"  49.26675  .9482237 . 0 0 10 12692
                      418 "01852J10"  -7.526881992816925 1994 "40"   45.5585 1.0254047 . 0 0 11 12723
                      419 "01852J10"  1.1627906933426857 1994 "40"   46.3275 1.0083838 . 0 0 12 12753
                      420 "01852J10"   1.149425283074379 1995 "40"     46.86 1.1091974 . 0 0  1 12784
                      421 "01852J10"  2.2727273404598236 1995 "40"    47.925 1.0845486 . 0 0  2 12815
                      422 "01852J10"  -6.666667014360428 1995 "40"     44.73 1.1620164 . 0 0  3 12843
                      423 "01852J10"    7.14285746216774 1995 "40"    47.925 1.0845486 . 0 0  4 12874
                      424 "01852J10" -1.1111111380159855 1995 "40"   47.3925 1.0967345 . 0 0  5 12904
                      425 "01852J10"   4.494382068514824 1995 "40"  49.54575 1.0490706 . 0 0  6 12935
                      426 "01852J10"   7.526881992816925 1995 "40"    53.275  .9756356 . 0 0  7 12965
                      427 "01852J10"  14.000000059604645 1995 "40"   60.7335  .8558208 . 0 0  8 12996
                      428 "01852J10"  -2.631578966975212 1995 "40"     74.37  .6988972 . 0 0  9 13027
                      429 "01852J10" -3.6036036908626556 1995 "40"     71.69  .7250243 . 0 0 10 13057
                      430 "01852J10"  1.0514019057154655 1995 "40"  72.44375  .7174807 . 0 0 11 13088
                      431 "01852J10"  -.5780346691608429 1995 "40"   57.6415  .9017287 . 0 0 12 13118
                      432 "01852J10"   3.488372266292572 1996 "40"  59.65225  .9299049 . 0 0  1 13149
                      433 "01852J10"                   0 1996 "40"  59.65225  .9299049 . 0 0  2 13180
                      434 "01852J10"  -5.617977678775787 1996 "40"     56.49  .9819599 . 0 0  3 13209
                      435 "01852J10"                   0 1996 "40"     56.49  .9819599 . 0 0  4 13240
                      436 "01852J10"   1.785714365541935 1996 "40"  57.49875  .9647326 . 0 0  5 13270
                      437 "01852J10"   18.12865436077118 1996 "40"   67.9225  .8166795 . 0 0  6 13301
                      438 "01852J10"  -7.920791953802109 1996 "40"   62.5425  .8869315 . 0 0  7 13331
                      439 "01852J10"   1.344086043536663 1996 "40"  63.38313  .8751685 . 0 0  8 13362
                      440 "01852J10" -.26525198481976986 1996 "40"   63.3325  .8758681 . 0 0  9 13393
                      441 "01852J10" -1.0638297535479069 1996 "40"  62.65875   .885286 . 0 0 10 13423
                      442 "01852J10"  18.817204236984253 1996 "40"  74.44937  .7450824 . 0 0 11 13454
                      443 "01852J10"  -9.502262622117996 1996 "40"    67.375   .823316 . 0 0 12 13484
                      444 "01852J10"  10.000000149011612 1997 "40"   74.1125 1.7667503 . 0 0  1 13515
                      445 "01852J10"  12.613636255264282 1997 "40"  83.46078   1.56886 . 0 0  2 13546
                      446 "01852J10"  -6.034308671951294 1997 "40"    78.155  1.675367 . 0 0  3 13574
                      447 "01852J10"  -4.310344904661179 1997 "40"  74.78625  1.750834 . 0 0  4 13605
                      448 "01852J10"   5.855855718255043 1997 "40"  79.16563  1.653979 . 0 0  5 13635
                      449 "01852J10"  3.1063830479979515 1997 "40" 161.01813  .8131897 . 0 0  6 13666
                      450 "01852J10"   2.074688859283924 1997 "40" 164.35875  .7966616 . 0 0  7 13696
                      451 "01852J10"  1.2195121496915817 1997 "40" 166.36313  .7870632 . 0 0  8 13727
                      452 "01852J10"   17.39758998155594 1997 "40"   194.485  .6732565 . 0 0  9 13758
                      453 "01852J10"   7.216494530439377 1997 "40"    208.52  .6279411 . 0 0 10 13788
                      454 "01852J10"   .9615384973585606 1997 "40"   210.525  .6219608 . 0 0 11 13819
                      455 "01852J10"   1.371428556740284 1997 "40"   212.583  .6159396 . 0 0 12 13849
                      456 "01852J10"  -.9433962404727936 1998 "40"  210.5775  .8829857 . 0 0  1 13880
                      457 "01852J10"    4.76190485060215 1998 "40"   220.605    .84285 . 0 0  2 13911
                      458 "01852J10"  1.3090909458696842 1998 "40"   222.666  .8350485 . 0 0  3 13939
                      459 "01852J10"   .9009009227156639 1998 "40"   224.672  .8275927 . 0 0  4 13970
                      460 "01852J10"   -2.45535708963871 1998 "40"  219.1555  .8484246 . 0 0  5 14000
                      461 "01852J10" -12.183066457509995 1998 "40" 272.98676  .6811206 . 0 0  6 14031
                      462 "01852J10" -2.6178009808063507 1998 "40"  265.8405  .6994303 . 0 0  7 14061
                      463 "01852J10" -27.956989407539368 1998 "40"  191.5195  .9708511 . 0 0  8 14092
                      464 "01852J10"  10.358209162950516 1998 "40" 210.52237  .8832169 . 0 0  9 14123
                      465 "01852J10"   4.081632569432259 1998 "40" 219.11513  .8485809 . 0 0 10 14153
                      466 "01852J10"  1.9607843831181526 1998 "40"  223.4115   .832262 . 0 0 11 14184
                      467 "01852J10"  1.0384615510702133 1998 "40" 215.77437  .8617192 . 0 0 12 14214
                      468 "01852J10"   1.916932873427868 1999 "40" 219.91063  .6987869 . 0 0  1 14245
                      469 "01852J10"  -.9404388256371021 1999 "40"  217.8425   .705421 . 0 0  2 14276
                      470 "01852J10"  -9.417721629142761 1999 "40"  195.7825   .784905 . 0 0  3 14304
                      471 "01852J10"   16.19718372821808 1999 "40" 227.49374   .675494 . 0 0  4 14335
                      472 "01852J10"  18.484848737716675 1999 "40" 269.54562    .57011 . 0 0  5 14365
                      473 "01852J10"  -4.286444932222366 1999 "40"  256.4475  .5992286 . 0 0  6 14396
                      474 "01852J10" -2.9569892212748528 1999 "40"  248.8644  .6174876 . 0 0  7 14426
                      475 "01852J10"  -4.709141328930855 1999 "40"   237.145   .648003 . 0 0  8 14457
                      476 "01852J10"   -8.06976780295372 1999 "40" 203.33463  .7557526 . 0 0  9 14488
                      477 "01852J10"   4.458598792552948 1999 "40"  212.4005  .7234948 . 0 0 10 14518
                      478 "01852J10" -2.7439024299383163 1999 "40" 206.57243  .7439069 . 0 0 11 14549
                      479 "01852J10"  -6.507837027311325 1999 "40"  191.6785  .8017105 . 0 0 12 14579
                      480 "01852J10"  -5.743243172764778 2000 "40" 180.66994  .9080418 . 0 0  1 14610
                      481 "01852J10"   5.017921328544617 2000 "40"  189.7358  .8646541 . 0 0  2 14641
                      482 "01852J10" -1.9658703356981277 2000 "40" 173.20876  .9471568 . 0 0  3 14670
                      483 "01852J10"  -7.017543911933899 2000 "40"  160.9047 1.0195841 . 0 0  4 14701
                      484 "01852J10"   6.792452931404114 2000 "40" 171.02043  .9592764 . 0 0  5 14731
                      485 "01852J10"  -6.275618076324463 2000 "40" 153.78925 1.0667577 . 0 0  6 14762
                      486 "01852J10"  -.7604562677443027 2000 "40" 152.61975  1.074932 . 0 0  7 14792
                      487 "01852J10"  6.1302680522203445 2000 "40" 160.17525 1.0242273 . 0 0  8 14823
                      488 "01852J10"   4.779783263802528 2000 "40"   166.392    .98596 . 0 0  9 14854
                      489 "01852J10"               3.125 2000 "40" 171.59175  .9560824 . 0 0 10 14884
                      490 "01852J10"  -3.030303120613098 2000 "40"   166.392    .98596 . 0 0 11 14915
                      end
                      format %tm date
                      format %td IPOdate
                      format %td fulldate

                      I apologize for the lengthy post. If you think that the amount of information is excessive, please let me know so that in future posts I know what's the correct amount of info to provide so that we can help each other.

                      I really appreciate your time.

                      Comment


                      • #12
                        The volume of your data is greater than needed, but that's in no way a problem here.

                        There are some difficulties, however. Your logic for selecting potential controls if flawed. You based it on what's going on in June 1994. But your problem specification says you need the matching to take place based on the values of me and btm in December of the IPO year, which is December 1994. The mistake of using June 1994 instead of December 1994 also affects the base value of "me" that you want to compare to: you used the case's June 1994 value instead of the December 1994 value as the referent. Consequently, when I attempt to match them the way you asked for, none of them are eligible.

                        More serious than that, the matching instructions also have a criterion based on btm. But the btm variable has nothing but missing values in two of the controls, and is frequently missing in the other two cusips as well. If that's characteristic of the data, there is no sensible way you can use btm as a matching variable.

                        Finally, unrelated to your data, I've been pondering how to code for
                        I do not ever need to change the control unless the control stops trading (meaning: no more observations for that particular "cusip" after then). In that case, at the time that happens, a new control should be drawn from the original list of candidates with the next minimized book-to-market dispersion.
                        and I can't actually make sense of it. If the "first" control's data run out before the case's data do, why would we use that control anyhow? It seems to me it would just make sense to use only controls for which the data run at least as long as the case's do. If we follow that general rule, we would never match a case to a control whose data runs out earlier unless there is no well enough matching control whose data runs to the end of the case's at all, so nothing to switch to. That case would then have to either go entirely unmatched, or a settle for a match only through the available dates.

                        Comment


                        • #13
                          You are right at many points. My control logic is somewhat flawed. Please let me specify it more clearly for you using the same case above and a new draw of controls based on what you said.


                          IPO date is June 1994, so for this case I need a control that ...
                          IPO != 0, so that it does not draw a control from my case sample.

                          gsector = 40, so that I match the control in terms of economic sector.

                          0.7 < me/me_control < 1.3 on IPO date (in this case June 1994), so that I match in size range on IPO date.

                          Within that size range (x=1 in my new control sample I post below), minimum dispersion in "btm" at December of the year prior the IPO year (in this case, that would be in December 1993), so a value for the "btm" var must available in the control at that date (y=1 in my new control sample).
                          "btm" is a variable whose value is only reported at the end of the calendar year. It is my fault that I did not erase the observations that are on months different from December. I already corrected that. That being said, I have no choice but to match on "me" based on IPO date (in this case June 1994) and match on "btm" from the previous year (in this case December 1993).
                          Once a control has been found, I keep that one forever as long as it does not run out of data. What you mentioned of finding a control that complies with the aformentioned rules and runs at least as long as does the case would be optimal to prevent having to switch, so I am up for that idea. Nonetheless, if there is no good enough matching control whose data runs until the end of the case's data, I need to draw a new control from the original list so that my case is always matched as the purpose of all this is twofold: (1) measuring stock return underperformance of IPO firms relative to non-IPO firms and, (2), creating a long-short portfolio in which I buy the control and short-sell the case, so if the control ceases to trade (runs out of data) I can reinvest the proceeds from the sale in a new control from the original list and keep running the strategy until the IPO firm runs out of data.

                          As follows I post the new three controls I have found. The case is the same as posted before (cusip "00077R10").
                          The observations with x=1 match the following command:
                          Code:
                          gen x=0
                          replace x=1 if cusip!="00077R10" & IPO==0 & gsector=="40" & month==6 & year==1994 &  me<49.381*1.3 & me>49.381*0.7
                          and those with y=1 match the following:
                          Code:
                          gen y=1
                          replace y=1 if x==1 & month==12 & year==1993 & btm!=.
                          1st control



                          2nd control



                          3rd control





                          I hope that I elaborated enough to address your comment. Thank you for trying to help me with this puzzle. I really appreciate it.
                          Last edited by Roberto Iglesia; 26 Mar 2019, 05:37. Reason: I found a mistake on the controls. I am correcting it. Sorry for the inconvenience.

                          Comment


                          • #14
                            Apparently I took too much time editing the post and it does not allow me to do so anymore so please ignore the previous and find the following as the right one to follow up with the conversation. Thank you and I apologise for the inconvenience.




                            You are right at many points. My control logic is somewhat flawed. Please let me specify it more clearly for you using the same case above and a new draw of controls based on what you said.


                            IPO date is June 1994, so for this case I need a control that ...
                            IPO != 0, so that it does not draw a control from my case sample.

                            gsector = 40, so that I match the control in terms of economic sector.

                            0.7 < me/me_control < 1.3 on IPO date (in this case June 1994), so that I match in size range on IPO date.

                            Within that size range (x=1 in my new control sample I post below), minimum dispersion in "btm" at December of the IPO year (in this case, that would be in December 1994), so a value for the "btm" var must available in the control at that date (y=1 in my new control sample).
                            "btm" is a variable whose value is only reported at the end of the calendar year. It is my fault that I did not erase the observations that are on months different from December. I already corrected that. That being said, I have no choice but to match on "me" based on IPO date (in this case June 1994) and match on "btm" from the end of the IPO year (in this case December 1994).
                            Once a control has been found, I keep that one forever as long as it does not run out of data. What you mentioned of finding a control that complies with the aformentioned rules and runs at least as long as does the case would be optimal to prevent having to switch as long as there is no much dispersion in "btm" from the case, so I am up for that idea if we set a restriction of, say, +-50% in "btm". Nonetheless, I have tried to find some controls following the conditions of running until the end of sample and 0.5 < btm/btm_control < 1.5 and found very little. So, I think that if there is no good enough matching control whose data runs until the end of the case's data, I should use the control with the closest "btm" first and then draw a new control from the original list.

                            So in the controls I show below I add one that runs till the end although has a "btm" further away than +-50% from the case, an another that runs out of data but has "btm" within that range. However, for the real thing, rather than setting a range, I would like to minimize the "btm" dispersion.


                            As follows I post two new controls I have found according to this. The case is the same as posted before (cusip "00077R10").
                            The observations with x=1, y=1, and z=1 match the following code (allowed me to find the controls):
                            Code:
                            gen x=0
                            gen y=0
                            gen z=0
                            
                            *Where June 1994 is the IPO date
                            replace x=1 if cusip!="00077R10" & IPO==0 & gsector=="40" & month==6 & year==1994 & me<49.381*1.3 & me>49.381*0.7
                            replace x=. if x==0
                            enlarge x, by(cusip)
                            
                            
                            **For running till the end ...
                            
                            *Where 1994 is the IPO year
                            replace y=1 if x==1 & month==12 & year==1994 & btm!=.
                            replace y=. if y==0
                            enlarge y, by(cusip)
                            
                            *Where the caseĀ“s last trading date is April 1999
                            replace z=1 if y==1 & month==4 & year==1999
                            
                            
                            **Alternative for btm within range ...
                            
                            *Where 1994 is the IPO year
                            replace y=1 if x==1 & month==12 & year==1994 & btm<.1842716*1.5 & btm>.1842716*.5
                            1st control: this one runs till the end

                            Code:
                            * Example generated by -dataex-. To install: ssc install dataex
                            clear
                            input long date str10 cusip double(ret year) str2 gsector float(me btm) long IPOdate float(IPO fulldate month x y z)
                            413 "95214520"   2.063492126762867 1994 "40"    42.016        . . 0 12570  6 1 1 0
                            414 "95214520"            -2.34375 1994 "40"  41.03125        . . 0 12600  7 1 1 0
                            415 "95214520"   3.999999910593033 1994 "40"   42.6725        . . 0 12631  8 1 1 0
                            416 "95214520"  1.9999999552965164 1994 "40"   43.3455        . . 0 12662  9 1 1 0
                            417 "95214520"   1.515151560306549 1994 "40"  44.00225        . . 0 12692 10 1 1 0
                            418 "95214520" -10.447761416435242 1994 "40"    39.405        . . 0 12723 11 1 1 0
                            419 "95214520" -2.8333332389593124 1994 "40"   38.0045 .7106276 . 0 12753 12 1 1 0
                            420 "95214520"                   0 1995 "40"   38.0045        . . 0 12784  1 1 1 0
                            421 "95214520"   -5.17241396009922 1995 "40"  36.03875        . . 0 12815  2 1 1 0
                            422 "95214520"   5.454545468091965 1995 "40"   63.2925        . . 0 12843  3 1 1 0
                            423 "95214520"  -2.931034378707409 1995 "40"     61.11        . . 0 12874  4 1 1 0
                            424 "95214520"                   0 1995 "40"     61.11        . . 0 12904  5 1 1 0
                            425 "95214520"    5.35714291036129 1995 "40"    64.428        . . 0 12935  6 1 1 0
                            426 "95214520"   9.830508381128311 1995 "40"    70.434        . . 0 12965  7 1 1 0
                            427 "95214520"  3.8759689778089523 1995 "40"    73.164        . . 0 12996  8 1 1 0
                            428 "95214520"   5.970149114727974 1995 "40"  85.28875        . . 0 13027  9 1 1 0
                            429 "95214520"   4.225354269146919 1995 "40"   88.5405        . . 0 13057 10 1 1 0
                            430 "95214520"   2.985074557363987 1995 "40"   91.1835        . . 0 13088 11 1 1 0
                            431 "95214520" -3.6231882870197296 1995 "40"   79.8665 .6660872 . 0 13118 12 1 1 0
                            432 "95214520"  3.3984962850809097 1996 "40"   82.2685        . . 0 13149  1 1 1 0
                            433 "95214520"    9.48905125260353 1996 "40"    90.075        . . 0 13180  2 1 1 0
                            434 "95214520"   3.999999910593033 1996 "40"    93.873        . . 0 13209  3 1 1 0
                            435 "95214520"  -4.153846204280853 1996 "40"  89.66075        . . 0 13240  4 1 1 0
                            436 "95214520"                   0 1996 "40"  89.66075        . . 0 13270  5 1 1 0
                            437 "95214520"  2.0134227350354195 1996 "40"    91.523        . . 0 13301  6 1 1 0
                            438 "95214520"  -.3157894825562835 1996 "40"  90.92088        . . 0 13331  7 1 1 0
                            439 "95214520"   .6622516550123692 1996 "40"    91.523        . . 0 13362  8 1 1 0
                            440 "95214520"  3.2894738018512726 1996 "40" 130.83987        . . 0 13393  9 1 1 0
                            441 "95214520"   8.662420511245728 1996 "40"   141.678        . . 0 13423 10 1 1 0
                            442 "95214520"   4.411764815449715 1996 "40"  147.9285        . . 0 13454 11 1 1 0
                            443 "95214520"    2.11267601698637 1996 "40" 121.49187 .5526731 . 0 13484 12 1 1 0
                            444 "95214520"  12.744827568531036 1997 "40" 136.57362        . . 0 13515  1 1 1 0
                            445 "95214520"  6.1349693685770035 1997 "40" 144.95238        . . 0 13546  2 1 1 0
                            446 "95214520"                   0 1997 "40"  145.0605        . . 0 13574  3 1 1 0
                            447 "95214520"   4.323699325323105 1997 "40"    150.93        . . 0 13605  4 1 1 0
                            448 "95214520"   11.11111119389534 1997 "40"     167.7        . . 0 13635  5 1 1 0
                            449 "95214520"                  25 1997 "40"  209.9375        . . 0 13666  6 1 1 0
                            450 "95214520" -7.0079997181892395 1997 "40"   194.822        . . 0 13696  7 1 1 0
                            451 "95214520"  -9.482758492231369 1997 "40"  176.3475        . . 0 13727  8 1 1 0
                            452 "95214520"  18.095238506793976 1997 "40"   208.258        . . 0 13758  9 1 1 0
                            453 "95214520" -4.5967742800712585 1997 "40"   198.181        . . 0 13788 10 1 1 0
                            454 "95214520"    34.7457617521286 1997 "40"  267.0405        . . 0 13819 11 1 1 0
                            455 "95214520"  -4.716981202363968 1997 "40"  257.2975 .3080871 . 0 13849 12 1 1 0
                            456 "95214520"   6.138613820075989 1998 "40"  272.5825        . . 0 13880  1 1 1 0
                            457 "95214520"   .9345794096589088 1998 "40"    275.13        . . 0 13911  2 1 1 0
                            458 "95214520"  -6.018518656492233 1998 "40" 325.86575        . . 0 13939  3 1 1 0
                            459 "95214520"  3.1527094542980194 1998 "40" 335.49725        . . 0 13970  4 1 1 0
                            460 "95214520"  -3.349282220005989 1998 "40"  324.2605        . . 0 14000  5 1 1 0
                            461 "95214520" -2.4752475321292877 1998 "40"  316.8745        . . 0 14031  6 1 1 0
                            462 "95214520"  -8.934009820222855 1998 "40"  287.9215        . . 0 14061  7 1 1 0
                            463 "95214520" -22.905027866363525 1998 "40"   221.973        . . 0 14092  8 1 1 0
                            464 "95214520" -2.8985507786273956 1998 "40"   215.539        . . 0 14123  9 1 1 0
                            465 "95214520"   21.03283852338791 1998 "40"  260.0981        . . 0 14153 10 1 1 0
                            466 "95214520"  17.006802558898926 1998 "40"  304.3325        . . 0 14184 11 1 1 0
                            467 "95214520" -2.3255813866853714 1998 "40"   297.717 .3937461 . 0 14214 12 1 1 0
                            468 "95214520" -2.7142856270074844 1999 "40" 288.85638        . . 0 14245  1 1 1 0
                            469 "95214520" -3.0674846842885017 1999 "40" 279.99576        . . 0 14276  2 1 1 0
                            470 "95214520"  -5.379746854305267 1999 "40" 264.93268        . . 0 14304  3 1 1 0
                            471 "95214520"   -7.39799365401268 1999 "40" 244.55325        . . 0 14335  4 1 1 1
                            472 "95214520"  1.0869565419852734 1999 "40" 247.21144        . . 0 14365  5 1 1 0
                            473 "95214520"    .358422938734293 1999 "40"  248.0975        . . 0 14396  6 1 1 0
                            end
                            format %tm date
                            format %td IPOdate
                            format %d fulldate

                            2nd control: this one does not run till the end but it is within 0.5 < btm/btm_control < 1.5

                            Code:
                            * Example generated by -dataex-. To install: ssc install dataex
                            clear
                            input long date str10 cusip double(ret year) str2 gsector float(me btm) long IPOdate float(IPO fulldate month x y z)
                            413 "58501B10" -23.999999463558197 1994 "40"   50.2265          . . 0 12570  6 1 0 0
                            414 "58501B10"   23.68421107530594 1994 "40"  62.12225          . . 0 12600  7 1 0 0
                            415 "58501B10"   46.80851101875305 1994 "40"  91.20075          . . 0 12631  8 1 0 0
                            416 "58501B10" -10.144927352666855 1994 "40"  84.96325          . . 0 12662  9 1 0 0
                            417 "58501B10" -3.2258063554763794 1994 "40"   82.2225          . . 0 12692 10 1 0 0
                            418 "58501B10" -13.333334028720856 1994 "40"   71.2595          . . 0 12723 11 1 0 0
                            419 "58501B10" -7.6923079788684845 1994 "40"    71.394  .16676667 . 0 12753 12 1 1 0
                            420 "58501B10"  -14.58333283662796 1995 "40"  60.98238          . . 0 12784  1 1 0 0
                            421 "58501B10"   4.878048598766327 1995 "40"  63.95713          . . 0 12815  2 1 0 0
                            422 "58501B10"   4.651162773370743 1995 "40"  67.21313          . . 0 12843  3 1 0 0
                            423 "58501B10" -17.777778208255768 1995 "40"  55.26413          . . 0 12874  4 1 0 0
                            424 "58501B10"  29.729729890823364 1995 "40"    71.694          . . 0 12904  5 1 0 0
                            425 "58501B10"    4.16666679084301 1995 "40"  74.80312          . . 0 12935  6 1 0 0
                            426 "58501B10"                   0 1995 "40"  74.80312          . . 0 12965  7 1 0 0
                            427 "58501B10"  -7.999999821186066 1995 "40"  68.81888          . . 0 12996  8 1 0 0
                            428 "58501B10" -4.3478261679410934 1995 "40"   71.4945          . . 0 13027  9 1 0 0
                            429 "58501B10" -22.727273404598236 1995 "40"  55.24575          . . 0 13057 10 1 0 0
                            430 "58501B10"                   0 1995 "40"  55.24575          . . 0 13088 11 1 0 0
                            431 "58501B10"   5.882352963089943 1995 "40"  65.58525  .13817778 . 0 13118 12 1 0 0
                            432 "58501B10"   11.11111119389534 1996 "40"   72.8725          . . 0 13149  1 1 0 0
                            433 "58501B10"  -2.500000037252903 1996 "40"  71.05069          . . 0 13180  2 1 0 0
                            434 "58501B10"  23.076923191547394 1996 "40"    82.875          . . 0 13209  3 1 0 0
                            435 "58501B10"               -6.25 1996 "40"  77.69531          . . 0 13240  4 1 0 0
                            436 "58501B10"  -16.66666716337204 1996 "40"  64.74609          . . 0 13270  5 1 0 0
                            437 "58501B10"  -17.33333319425583 1996 "40"  59.32819          . . 0 13301  6 1 0 0
                            438 "58501B10" -12.903225421905518 1996 "40"  51.67294          . . 0 13331  7 1 0 0
                            439 "58501B10"  20.370370149612427 1996 "40"  62.19891          . . 0 13362  8 1 0 0
                            440 "58501B10" -30.769231915473938 1996 "40"  46.98844          . . 0 13393  9 1 0 0
                            441 "58501B10"  -26.66666805744171 1996 "40" 34.458187          . . 0 13423 10 1 0 0
                            442 "58501B10"  -33.33333432674408 1996 "40" 22.972124          . . 0 13454 11 1 0 0
                            443 "58501B10"  -9.090909361839294 1996 "40"  20.88375          . . 0 13484 12 1 0 0
                            444 "58501B10"  30.000001192092896 1997 "40" 27.148874          . . 0 13515  1 1 0 0
                            445 "58501B10" -15.384615957736969 1997 "40" 22.972124          . . 0 13546  2 1 0 0
                            446 "58501B10"  -45.45454680919647 1997 "40"  12.53025          . . 0 13574  3 1 0 0
                            447 "58501B10"  -16.66666716337204 1997 "40" 10.441875          . . 0 13605  4 1 0 0
                            448 "58501B10" -20.000000298023224 1997 "40"    8.3535          . . 0 13635  5 1 0 0
                            end
                            format %tm date
                            format %td IPOdate
                            format %d fulldate

                            Case again (updated with new variable and without "btm" in months different from December)

                            Code:
                            * Example generated by -dataex-. To install: ssc install dataex
                            clear
                            input long date str10 cusip double(ret year) str2 gsector float(me btm) long IPOdate float(IPO fulldate month x y z)
                            413 "00077R10"  -6.122449040412903 1994 "40"    49.381          . 12564 1 12570  6 . 0 0
                            414 "00077R10"                   0 1994 "40"    49.381          . 12564 1 12600  7 . 0 0
                            415 "00077R10"  30.434781312942505 1994 "40"     64.41          . 12564 1 12631  8 . 0 0
                            416 "00077R10"   1.666666753590107 1994 "40"   65.4835          . 12564 1 12662  9 . 0 0
                            417 "00077R10"  1.6393441706895828 1994 "40"    66.557          . 12564 1 12692 10 . 0 0
                            418 "00077R10"   6.451612710952759 1994 "40"    70.851          . 12564 1 12723 11 . 0 0
                            419 "00077R10"  22.727273404598236 1994 "40"   86.9535   .1842716 12564 1 12753 12 . 0 0
                            420 "00077R10"   4.938271641731262 1995 "40"    91.715          . 12564 1 12784  1 . 0 0
                            421 "00077R10"    2.35294122248888 1995 "40"    93.873          . 12564 1 12815  2 . 0 0
                            422 "00077R10"  13.793103396892548 1995 "40"   106.821          . 12564 1 12843  3 . 0 0
                            423 "00077R10"  2.0202020183205605 1995 "40"   109.181          . 12564 1 12874  4 . 0 0
                            424 "00077R10"   4.950495064258575 1995 "40"   114.586          . 12564 1 12904  5 . 0 0
                            425 "00077R10"  11.320754885673523 1995 "40"   127.558          . 12564 1 12935  6 . 0 0
                            426 "00077R10"   6.779661029577255 1995 "40"   136.458          . 12564 1 12965  7 . 0 0
                            427 "00077R10"    8.33333358168602 1995 "40"  147.8295          . 12564 1 12996  8 . 0 0
                            428 "00077R10"  10.989011079072952 1995 "40"  164.0745          . 12564 1 13027  9 . 0 0
                            429 "00077R10"   16.83168262243271 1995 "40"  192.7235          . 12564 1 13057 10 . 0 0
                            430 "00077R10"   15.25423675775528 1995 "40"   222.122          . 12564 1 13088 11 . 0 0
                            431 "00077R10"  29.411765933036804 1995 "40"   287.452 .065996796 12564 1 13118 12 . 0 0
                            432 "00077R10"   9.090909361839294 1996 "40"   313.584          . 12564 1 13149  1 . 0 0
                            433 "00077R10"            17.96875 1996 "40"    369.95          . 12564 1 13180  2 . 0 0
                            434 "00077R10"  23.178808391094208 1996 "40"     455.7          . 12564 1 13209  3 . 0 0
                            435 "00077R10"   34.40860211849213 1996 "40"  838.5625          . 12564 1 13240  4 . 0 0
                            436 "00077R10"   .4000000189989805 1996 "40"  841.9167          . 12564 1 13270  5 . 0 0
                            437 "00077R10" -19.920319318771362 1996 "40"  674.2042          . 12564 1 13301  6 . 0 0
                            438 "00077R10"   .9950248524546623 1996 "40"   689.591          . 12564 1 13331  7 . 0 0
                            439 "00077R10"  11.330049484968185 1996 "40"   767.722          . 12564 1 13362  8 . 0 0
                            440 "00077R10"   27.43362784385681 1996 "40"   978.336          . 12564 1 13393  9 . 0 0
                            441 "00077R10"   -3.81944440305233 1996 "40"  943.5313          . 12564 1 13423 10 . 0 0
                            442 "00077R10" -37.906137108802795 1996 "40"   585.875          . 12564 1 13454 11 . 0 0
                            443 "00077R10"  -8.430232852697372 1996 "40"  536.4844   .3376609 12564 1 13484 12 . 0 0
                            444 "00077R10"  11.428571492433548 1997 "40"  597.7969          . 12564 1 13515  1 . 0 0
                            445 "00077R10"   6.552706658840179 1997 "40"  636.9688          . 12564 1 13546  2 . 0 0
                            446 "00077R10"  -22.99465239048004 1997 "40"     490.5          . 12564 1 13574  3 . 0 0
                            447 "00077R10"   11.80555522441864 1997 "40"  550.9219          . 12564 1 13605  4 . 0 0
                            448 "00077R10"   59.62733030319214 1997 "40"  879.4219          . 12564 1 13635  5 . 0 0
                            449 "00077R10"  -9.727626293897629 1997 "40"   793.875          . 12564 1 13666  6 . 0 0
                            450 "00077R10"  -6.034482643008232 1997 "40"   745.996          . 12564 1 13696  7 . 0 0
                            451 "00077R10"  -1.376146823167801 1997 "40"    735.73          . 12564 1 13727  8 . 0 0
                            452 "00077R10"  2.7906976640224457 1997 "40"   756.262          . 12564 1 13758  9 . 0 0
                            453 "00077R10" -14.932127296924591 1997 "40"  643.5945          . 12564 1 13788 10 . 0 0
                            454 "00077R10"  2.1276595070958138 1997 "40"   657.288          . 12564 1 13819 11 . 0 0
                            455 "00077R10"  -.5208333488553762 1997 "40"  653.8646  .29684407 12564 1 13849 12 . 0 0
                            456 "00077R10"   3.141361102461815 1998 "40"   674.134          . 12564 1 13880  1 . 0 0
                            457 "00077R10"  15.228426456451416 1998 "40"   776.794          . 12564 1 13911  2 . 0 0
                            458 "00077R10"  -.8810572326183319 1998 "40"    769.95          . 12564 1 13939  3 . 0 0
                            459 "00077R10"   2.888888865709305 1998 "40"  830.3326          . 12564 1 13970  4 . 0 0
                            460 "00077R10" -11.447083950042725 1998 "40"  735.2838          . 12564 1 14000  5 . 0 0
                            461 "00077R10"   -7.31707289814949 1998 "40"  681.4825          . 12564 1 14031  6 . 0 0
                            462 "00077R10"  -26.31579041481018 1998 "40"   502.285          . 12564 1 14061  7 . 0 0
                            463 "00077R10" -17.142857611179352 1998 "40"   416.179          . 12564 1 14092  8 . 0 0
                            464 "00077R10"  -5.603448301553726 1998 "40"  392.8586          . 12564 1 14123  9 . 0 0
                            465 "00077R10"   37.89954483509064 1998 "40"  541.9579          . 12564 1 14153 10 . 0 0
                            466 "00077R10"  -9.933774918317795 1998 "40"   488.121          . 12564 1 14184 11 . 0 0
                            467 "00077R10"  15.441176295280457 1998 "40"  563.4926  .40926075 12564 1 14214 12 . 0 0
                            468 "00077R10"   16.56050980091095 1999 "40"  656.8099          . 12564 1 14245  1 . 0 0
                            469 "00077R10"  -22.95081913471222 1999 "40"  506.0666          . 12564 1 14276  2 . 0 0
                            470 "00077R10" -1.4184396713972092 1999 "40"  498.8884          . 12564 1 14304  3 . 0 0
                            471 "00077R10"   .7194244768470526 1999 "40"  502.4775          . 12564 1 14335  4 . 0 0
                            472 "00077R10"  44.285714626312256 1999 "40"  725.0032          . 12564 1 14365  5 . 0 0
                            473 "00077R10"   256.6831588745117 1999 "40" 2585.9646          . 12564 1 14396  6 . 0 0
                            end
                            format %tm date
                            format %td IPOdate
                            format %d fulldate

                            Lastly, just to add a little bit of context my purpose is twofold: (1) measuring stock return underperformance of IPO firms relative to non-IPO firms and, (2), creating a long-short portfolio in which I buy the control and short-sell the case, so if the control ceases to trade (runs out of data) I can reinvest the proceeds from the sale in a new control from the original list and keep running the strategy until the IPO firm runs out of data.


                            I hope that I elaborated enough to address your comment. Thank you for trying to help me with this puzzle. I really appreciate it.

                            Comment


                            • #15
                              I still can't work with this data. There is no value for btm in any month of 1996 or 1997 for 58501B10, nor for 1999 for 00077R10 and 95214520. While the btm values may not be needed for the particular match of this case, they are needed for a general algorithm that will consider every control and every case for possible pairing. If btm is only assessed annually, that is OK, I can work with just one per year, but I can't work with no values of btm in a year.

                              Also, I still don't get the business about how far the data extends. If a case were matched to a control and the control runs out of data before the case does, the only way that would happen is if there isn't any other possible control whose data does run far enough.

                              Comment

                              Working...
                              X