Announcement

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

  • #31
    The data file is actually large. I append a few wv portfolio returns from 25 and rest are like these and the rmrf, smb hml here. Kindly go thro the same. I face this error when i run the code in #30.

    variable vw_mean_mcap_q1_idiovol_q1_rt not found
    r(111);




    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(mdate vw_mean_q1_idiovol_q1_rt vw_mean_q1_idiovol_q2_rt vw_mean_q1_idiovol_q3_rt vw_mean_q1_idiovol_q4_rt vw_mean_q1_idiovol_q5_rt rmrf smb hml)
    498  -.01875001  -.05121103 -.05568177 -.09031922  -.18109927  -.08825827   -.0340242  -.08646767
    499   .11624202  -.02311949 -.04741132   .0649683      .10649   .03660561 -.011668272  -.07789018
    500  -.17689013  -.05115915  -.0818036 -.12644498   -.1752085  -.06799343  .011435956 -.025006384
    501  .005199294   .05234666   .1335188  .12164114   .12352556 -.005838253 -.033997387  .019280683
    502   .18793106    .2631455  .21076773   .1910256     .429712  .067996345  .001700103   .05373748
    503  -.02757622   -.0906348 -.04683475 -.05799859    .0217266  .036718745  -.02844303   .00962173
    504 -.023880575 -.014348214  .01893368 .016221179 -.007941992 -.032880142  -.03935827  .036588736
    505   .06116208  .017591037  .08025517  .10289047   .07289464   .01120519  -.01941483  -.01057228
    506   -.0634006  .072690725  .03002847  .08002245   .13589785  -.08240923  -.04902051 -.011406302
    507   .09846156   .14879225    .259952  .28248906    .1888206 -.006891241   .03579893   .08402058
    508  -.10924374 -.028179627 -.07654501 .036497302   .08880405   .15315036  .001694739    .1981089
    509    .2421384    .2054436   .2210655   .3443336   .28077126   .10748383   .06410722   .00010087
    end
    format %tm mdate
    Last edited by Sartaj Hussain; 12 Jan 2022, 11:53.

    Comment


    • #32
      OK, the variables in that data set are not named the way I expected them to be. Reflecting the new names, the following code should work:

      Code:
      frame create regress_results int (idiovol_group mcap_group) ///
      float(intercept tstat b_rmrf t_rmrf b_smb t_smb b_hml t_hml r2 adj_r2)
      forvalues iv = 1/5 {
          forvalues mc = 1/5 {
              local group q`mc'_idiovol_q`iv'
              regress vw_mean_`group'_rt rmrf smb hml
              matrix M = r(table)
              local topost (`iv') (`mc') (M["b", "_cons"]) (M["t", "_cons"])
              foreach x in rmrf smb hml {
                  local topost `topost' (M["b", "`x'"]) (M["t", "`x'"])
              }
              frame post regress_results `topost' (e(r2)) (e(r2_a))
          }
      }
      frame change regress_results
      rename (intercept tstat b_* t_* r2 adj_r2) =_idiovol_
      reshape wide *_idiovol_, i(mcap_group) j(idiovol_group)
      Note that this code assumes that all five mcap groups are actually represented in the input. The example you show contains only mcap group 1 (with all 5 idiovol groups). I imagine this is because -dataex- would not handle the full complement of variables.

      Much of the work of the last few days has been precipitated by differences between variable names in the code and those in the data. It is not clear how those changes arose, since in nearly all cases the code I post was tested on a dataset you posted before I released it (though in this particular instance, that was not the case.)
      Last edited by Clyde Schechter; 12 Jan 2022, 12:17.

      Comment


      • #33
        Yes. Actually, in one of recent codes, slightly different names have been used for groups. Well, we are through. Thank God!
        But just one thing about #32, if i want to add or drop regressors, can i do that by just making changes to regressors only in code and nothing else.

        Comment


        • #34
          But just one thing about #32, if i want to add or drop regressors, can i do that by just making changes to regressors only in code and nothing else.
          Almost, but not quite. You have to list them in the -regress- command, but that -foreach x in rmrf smb hml {-, which comes three lines later, would also have to be modified to reflect the regressors actually in use. Nothing else would need to change in that code.

          Comment

          Working...
          X