Announcement

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

  • Covariance for each company

    Hi All,

    I want to generate a new variable for covariance between beta_sd cfo_avgTA_sd for each co_code.

    dataex-

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long sa_finance1_cocode str66 co_name str10 sa_finance1_year float f_year double(cfo_avgTA_sd beta_sd)
        11 "20 MICRONS LTD."             "31-03-2013" 2013   .02822013908069832 .028284244273478854
        11 "20 MICRONS LTD."             "31-03-2014" 2014   .05791005751278434 .020816640142347336
        11 "20 MICRONS LTD."             "31-03-2015" 2015   .05007181080638612   .1178982667529732
        11 "20 MICRONS LTD."             "31-03-2016" 2016  .043152712754914106  .10894953073765697
        11 "20 MICRONS LTD."             "31-03-2017" 2017   .04036944303318073  .09914635990230551
        11 "20 MICRONS LTD."             "31-03-2018" 2018   .04580647753417843  .08983317964153968
        11 "20 MICRONS LTD."             "31-03-2019" 2019  .041440391662733944 .036742363824087736
        11 "20 MICRONS LTD."             "31-03-2020" 2020   .04004083355242427  .10616027063499267
        11 "20 MICRONS LTD."             "31-03-2021" 2021   .03667933955049749  .14989996524477206
     96387 "3I INFOTECH LTD."            "31-03-2009" 2009   .04881926087512617   .2757716345475099
     96387 "3I INFOTECH LTD."            "31-03-2010" 2010  .055815554224805906   .1997498350799226
     96387 "3I INFOTECH LTD."            "31-03-2011" 2011  .048945422749647256  .16680826357601114
     96387 "3I INFOTECH LTD."            "31-03-2012" 2012   .04112723925808757  .14570517291964213
     96387 "3I INFOTECH LTD."            "31-03-2013" 2013   .07196981206199908  .14570517291964213
     96387 "3I INFOTECH LTD."            "31-03-2014" 2014   .07423620985037126   .1605615167405794
     96387 "3I INFOTECH LTD."            "31-03-2015" 2015  .046442606069872175  .19408760425650626
     96387 "3I INFOTECH LTD."            "31-03-2016" 2016   .03881008507601237  .29891469266527043
     96387 "3I INFOTECH LTD."            "31-03-2017" 2017  .018225339240204808  .25626157284166995
     96387 "3I INFOTECH LTD."            "31-03-2018" 2018  .020346638259737412  .19957452290175018
     96387 "3I INFOTECH LTD."            "31-03-2019" 2019   .02162204620797293   .2217656232820056
     96387 "3I INFOTECH LTD."            "31-03-2020" 2020  .011889157978665158  .22700217966260322
     96387 "3I INFOTECH LTD."            "31-03-2021" 2021  .011650535235931455  .18316658862734317
     36277 "3M INDIA LTD."               "31-12-1999" 2000   .17976597106398418   .1325078699785712
     36277 "3M INDIA LTD."               "31-12-2000" 2001    .1273442264731989    .221065610446894
     36277 "3M INDIA LTD."               "31-12-2001" 2002   .10506396869708637   .3050082073631717
     36277 "3M INDIA LTD."               "31-12-2002" 2003   .09653363207795929   .3188573327719968
     36277 "3M INDIA LTD."               "31-12-2003" 2004   .07737078823136638   .2095709905807179
     36277 "3M INDIA LTD."               "31-12-2004" 2005   .08649320993945968  .08899437433047037
     36277 "3M INDIA LTD."               "31-12-2005" 2006   .08225729052854164 .053665632481809666
     36277 "3M INDIA LTD."               "31-12-2006" 2007   .07406562261431907  .08532291848979841
     36277 "3M INDIA LTD."               "31-12-2007" 2008   .07386507369496295    .131148771531347
     36277 "3M INDIA LTD."               "31-12-2008" 2009   .06197345174723462  .13765899326392603
     36277 "3M INDIA LTD."               "31-03-2010" 2010    .0548230169889715  .09396806714006897
     36277 "3M INDIA LTD."               "31-03-2011" 2011   .07458399303746846  .07861295981774094
     36277 "3M INDIA LTD."               "31-03-2012" 2012   .07126479447249115  .09126882271437763
     36277 "3M INDIA LTD."               "31-03-2013" 2013   .07847827358481187  .11058931791420482
     36277 "3M INDIA LTD."               "31-03-2014" 2014   .07389903072448126  .10709808726414846
     36277 "3M INDIA LTD."               "31-03-2015" 2015   .06331077633683005  .09071935208548298
     36277 "3M INDIA LTD."               "31-03-2016" 2016    .0352879985326169  .06870225331228864
     36277 "3M INDIA LTD."               "31-03-2017" 2017   .05717477379506113  .06870225331228864
     36277 "3M INDIA LTD."               "31-03-2018" 2018    .0626181816406485  .13740452104807802
     36277 "3M INDIA LTD."               "31-03-2019" 2019   .07597162410890645  .13740452419305207
     36277 "3M INDIA LTD."               "31-03-2020" 2020   .07387695642828501  .12617448981915091
     36277 "3M INDIA LTD."               "31-03-2021" 2021   .07641275632462258  .10784248154103579
    183396 "3P LAND HOLDINGS LTD."       "31-03-2000" 2000   .14767891674813255  .12124356380566281
    183396 "3P LAND HOLDINGS LTD."       "31-03-2001" 2001    .1279696588021002   .1555635069828195
    183396 "3P LAND HOLDINGS LTD."       "31-03-2002" 2002   .11163245672078903  .21337760432843572
    183396 "3P LAND HOLDINGS LTD."       "31-03-2003" 2003   .09786624188355295  .17812916873270127
    183396 "3P LAND HOLDINGS LTD."       "31-03-2004" 2004   .09948023385498744  .11480416961895906
    183396 "3P LAND HOLDINGS LTD."       "31-03-2005" 2005    .0901027978073719   .1112204934433984
    183396 "3P LAND HOLDINGS LTD."       "31-03-2006" 2006   .08922098005812727  .17564167014860474
    183396 "3P LAND HOLDINGS LTD."       "31-03-2007" 2007   .09314880571302717  .24201239068254624
    183396 "3P LAND HOLDINGS LTD."       "31-03-2008" 2008   .10098239135215151     .25739073963032
    183396 "3P LAND HOLDINGS LTD."       "31-03-2009" 2009   .08665899470659127  .17980544468971027
    183396 "3P LAND HOLDINGS LTD."       "31-03-2010" 2010   .09039406755951024  .10894952526681288
    183396 "3P LAND HOLDINGS LTD."       "31-03-2011" 2011     .133357726621706   .0521536049329429
    183396 "3P LAND HOLDINGS LTD."       "31-03-2012" 2012    .1837515996635948   .0644204830858624
    183396 "3P LAND HOLDINGS LTD."       "31-03-2013" 2013   .18767474138676626  .06442050621694471
    183396 "3P LAND HOLDINGS LTD."       "31-03-2014" 2014   .18753402004267664  .07529941408745673
    183396 "3P LAND HOLDINGS LTD."       "31-03-2015" 2015   .18732964142229147  .13352901825043179
    183396 "3P LAND HOLDINGS LTD."       "31-03-2016" 2016   .13110408752410418  .22554378932616728
    183396 "3P LAND HOLDINGS LTD."       "31-03-2017" 2017   .07172425816694675   .3032325822910185
    183396 "3P LAND HOLDINGS LTD."       "31-03-2018" 2018   .03592816963832469   .2682722428842162
    183396 "3P LAND HOLDINGS LTD."       "31-03-2019" 2019  .032846780152532555  .17311845258870892
    183396 "3P LAND HOLDINGS LTD."       "31-03-2020" 2020 .0051251647498845665  .08746427508345658
    183396 "3P LAND HOLDINGS LTD."       "31-03-2021" 2021  .009125613595860275  .10853570196794766
    218767 "52 WEEKS ENTERTAINMENT LTD." "31-03-2019" 2019   .23621424779211575  .02121320296144438
    218767 "52 WEEKS ENTERTAINMENT LTD." "31-03-2020" 2020  .021989384615337615   .1193035339215765
    218767 "52 WEEKS ENTERTAINMENT LTD." "31-03-2021" 2021   .03159629547693882   .1189887944704438
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2001" 2001   .05645901737630672  .21221057924106693
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2002" 2002  .047205593256256534  .36097092158878846
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2003" 2003    .1095086302173812   .4700744547663411
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2004" 2004   .12415324900323237   .5648627987035826
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2005" 2005   .11826395472333062  .48459259207822136
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2006" 2006   .12295211025584643   .3561319798782733
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2007" 2007    .1787020277569275  .26434827294309776
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2008" 2008   .14490319861564746  .21741665197933074
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2009" 2009   .16234067083284198   .2955503456986903
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2010" 2010   .16231809166196154   .3338113337962296
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2011" 2011   .15960935512228383  .25471555706480853
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2012" 2012   .09325841899496323  .12247450173926044
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2013" 2013   .10723062828022603  .12247450173926044
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2014" 2014   .04895091689095991  .12577759325861018
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2015" 2015   .05099054482666148  .32710857893266654
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2016" 2016    .0719179511522046   .3158797417810523
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2017" 2017   .07908077610827881   .2788010090741306
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2018" 2018    .0656140298510999  .21533696522568482
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2019" 2019   .03490994199670564  .14188027105749385
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2020" 2020   .02139553044955336   .1937782358083728
     73119 "63 MOONS TECHNOLOGIES LTD."  "31-03-2021" 2021   .01700964996957609  .23445683849512144
     73721 "7SEAS ENTERTAINMENT LTD."    "31-03-2015" 2015   .25070600129136317  .19798987850174601
     73721 "7SEAS ENTERTAINMENT LTD."    "31-03-2016" 2016    .2185046317919729  .14294519832882024
     73721 "7SEAS ENTERTAINMENT LTD."    "31-03-2017" 2017   .13871184482811766  .13047988050727474
     73721 "7SEAS ENTERTAINMENT LTD."    "31-03-2018" 2018   .23327664328181086  .11958260802914236
     73721 "7SEAS ENTERTAINMENT LTD."    "31-03-2019" 2019   .17703745836150872  .16976455629857742
     73721 "7SEAS ENTERTAINMENT LTD."    "31-03-2020" 2020   .15818387366226938  .16513632093457342
    389178 "A 2 Z INFRA ENGG. LTD."      "31-03-2015" 2015   .05598687216854091  .11313697709391542
    389178 "A 2 Z INFRA ENGG. LTD."      "31-03-2016" 2016   .06108730492335009  .08504892437210167
    389178 "A 2 Z INFRA ENGG. LTD."      "31-03-2017" 2017  .020713764541924834  .07274377343538276
    389178 "A 2 Z INFRA ENGG. LTD."      "31-03-2018" 2018   .02386352305287841   .0658026727510696
    end
    ------------------ copy up to and including the previous line ------------------

    Listed 100 out of 56809 observations

  • #2
    See rangestat from SSC.

    Comment


    • #3
      Nick- In rangestat , option interval() is required. I want to calculate covariance for all the observations for a co_code.

      Comment


      • #4
        That is fine. An interval of the form int(year . .) does precisely that. That is why I recommended rangestat, knowing that it could address your question.

        Comment


        • #5
          Thank you, Nick.

          A clarificatory question regarding rangestat. I have applied the following command- "rangestat (cov) cfo_avgTA_sd beta_sd, interval (f_year -5 -1) by (sa_finance1_cocode)". Here in the interval, is covariance calculated using the last 5 financial year values or the last 4 financial year values?

          Comment


          • #6
            First of all it is dangerous to insert spaces between option names and their arguments.

            You can answer your own question with simple experiments. For example, you can run this code to check how the command works:

            Code:
            . clear
            
            . set obs 20
            Number of observations (_N) was 0, now 20.
            
            . gen y = _n
            
            . rangestat (count) y , int(y -5 -1)
            
            . l
            In short, such an interval is in your case 5 years long, from year - 5 to year - 1. The number of observations in the interval could be 5, or more, or less, depending.

            Comment


            • #7
              Okay, I will experiment with the data.

              Comment

              Working...
              X