Announcement

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

  • Reducing my sample

    Dear all,
    I'm working on the following sample.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str6 company double year float(var1 var2)
    "001166" 2006          0  .11279426
    "001166" 2007  -1.637959 -.27963558
    "001166" 2008   -.950194   .0750155
    "001166" 2009  -.8942925   .4627495
    "001166" 2010  -.8927091   .4618876
    "001166" 2011  -.9401239   .4821147
    "001166" 2012 -.24718045  1.0281346
    "001166" 2013   .3438349  .58495206
    "001166" 2014  .11407267  .26770407
    "001166" 2015 -1.7433417  -.5185392
    "001166" 2016   .2910845  .14705177
    "001166" 2017  -1.207478   1.905073
    "001166" 2018 -1.2699703  2.0405955
    "001491" 2005  .11319265          0
    "001491" 2006     1.3774  1.5326812
    "001491" 2007 -.15200947  .19509214
    "001491" 2008  .09235152 -.03370083
    "001491" 2009   .4543725   .4367438
    "001491" 2010   .1379019  .04374808
    "001491" 2011   .7400544  .58201104
    "001491" 2012  1.3656943   .9399076
    "001491" 2013 -2.4492245 -1.6763176
    "001491" 2014   .1054693    .715324
    "001491" 2015  -.4048582  -.7234704
    "001491" 2016 .028132726   .3532367
    end
    I would like to keep just the observations in which var1 is lower than var2 (var1<var2) with a p-value of 0.10 (one-sided) or less. It is worth underlying that var1 and var2 are computed thanks to a regression like this: y=a+var1*x1+var2*x2.
    How could I do that?
    Thanks for the attention.

    Daniel

  • #2
    I responded to your post yesterday. Please don't repost almost identical questions. If you didn't get the answer you want, then try a very different posting.

    When you say "thanks to a regression like this: y=a+var1*x1+var2*x2." it is hard to understand how var1 and var2 could be created by a regression where they appear to be on the rhs. It is also hard to understand - what are variables and what are the parameters in your regression? As I said before, if you're using predict to generate predicted values, then you can also generate standard errors.

    Comment


    • #3
      Sorry Phil, I'll try to be clearer. I'm trying to predict year-ahead earnings based on the following regression: earnings(t)=a+w1*accruals(t-1)+w2*cashflows(t-1). The regression is estimated for each company based on a rolling ten-year window. here you can find an extract of my sample.

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input str6 company double year float(earnings accruals cashflows a w1 w2)
      "001166" 1996             .            .           .           .          .          .
      "001166" 1997    -.17344426 -.0022363567   -.1712079           .          .          .
      "001166" 1998     .04296355   -.07042014   .11338369           .          .          .
      "001166" 1999     .07506385    -.2564893    .3315531           .          .          .
      "001166" 2000      .3188296     .0402236     .278606           .          .          .
      "001166" 2001     .03159729   -.04062267   .07221997           .          .          .
      "001166" 2002   -.008508008   -.05540978   .04690177           .          .          .
      "001166" 2003    .021413997   -.12322964   .14464363           .          .          .
      "001166" 2004     .11822596 -.0043004174   .12252638           .          .          .
      "001166" 2005     .07532598   .008315909  .067010075           .          .          .
      "001166" 2006      .1574603   -.05431213   .21177244   .06227482          0  .11279426
      "001166" 2007     .17622428   .013350233   .16287404 -.008575335  -1.637959 -.27963558
      "001166" 2008      .0848003   -.05648047   .14128079   .03812211   -.950194   .0750155
      "001166" 2009     .04289107    -.1507751   .19366618  -.06099143  -.8942925   .4627495
      "001166" 2010      .3290127    .05835369     .270659  -.06307609  -.8927091   .4618876
      "001166" 2011     .19211413    .09166703   .10044709  -.06676859  -.9401239   .4821147
      "001166" 2012     .05785522  -.006740377  .064595595  -.06149056 -.24718045  1.0281346
      "001166" 2013   -.008499536    -.2796652   .27116567   .05238836   .3438349  .58495206
      "001166" 2014     .04031636  -.026404735    .0667211   .10021935  .11407267  .26770407
      "001166" 2015     .05215391   -.02709517   .07924908    .1804879 -1.7433417  -.5185392
      "001166" 2016    .030050375  -.008465899   .03851628   .10039933   .2910845  .14705177
      "001166" 2017     .04415479  -.015258932   .05941372  -.25465402  -1.207478   1.905073
      "001166" 2018     .05634042  -.014258256   .07059868  -.27287132 -1.2699703  2.0405955
      "001491" 1995             .            .           .           .          .          .
      "001491" 1996     .05867701   -.04952936   .10820637           .          .          .
      "001491" 1997     .06847423    .00640167   .06207256           .          .          .
      "001491" 1998     .07480522  -.073293045   .14809826           .          .          .
      "001491" 1999      .0968837    .05484225   .04204144           .          .          .
      "001491" 2000     .04633003    -.1974512   .24378125           .          .          .
      "001491" 2001     .02034333  -.005735719  .026079046           .          .          .
      "001491" 2002     .03586264  -.026845597   .06270824           .          .          .
      "001491" 2003     .03895941   -.02759124   .06655065           .          .          .
      "001491" 2004      .0446503    -.0467723    .0914226           .          .          .
      "001491" 2005     .04122434   -.08269802   .12392236  .074080594  .11319265          0
      "001491" 2006     .07826556   -.01537453   .09364008   -.0291499     1.3774  1.5326812
      "001491" 2007     .06048017    -.0645141   .12499427   .05170445 -.15200947  .19509214
      "001491" 2008    .011324465   .032385007 -.021060543   .06860633  .09235152 -.03370083
      "001491" 2009   -.000723325   -.03423203  .033508707   .02480591   .4543725   .4367438
      "001491" 2010    .013932136    .04414495  -.03021282    .0373165   .1379019  .04374808
      "001491" 2011   -.013726063   -.04117081   .02744475   .02454488   .7400544  .58201104
      "001491" 2012    .005304825   -.04444692   .04975174  .018704643  1.3656943   .9399076
      "001491" 2013    -.01955572   -.03528511  .015729392    .0825838 -2.4492245 -1.6763176
      "001491" 2014   -.020802936   -.07277225   .05196932  -.00645565   .1054693    .715324
      "001491" 2015    .005364127   -.06671057    .0720747   .10512625  -.4048582  -.7234704
      "001491" 2016     .02345395  -.005459054  .028913004  .009861388 .028132726   .3532367
      "001491" 2017      .0419029   -.06600713   .10791002  .002695332   .6511824  .55156463
      "001491" 2018     .06463527  -.020566816    .0852021  .005249023  -.4640799 -.19116877
      "001855" 2000             .            .           .           .          .          .
      "001855" 2001     -.6498575    -6.567124    5.917266           .          .          .
      "001855" 2002     -.1150441            .           .           .          .          .
      "001855" 2003   -.073643796            .           .           .          .          .
      "001855" 2004    -.10277302            .           .           .          .          .
      "001855" 2005    -.15240316    -.7430383    .5906351           .          .          .
      "001855" 2006     -.1614885     .7639872   -.9254757           .          .          .
      "001855" 2007     -.0173509    .04297726  -.06032816           .          .          .
      "001855" 2008    -.07128289    .13992783  -.21121074           .          .          .
      "001855" 2009    -.03466324   -.24388373    .2092205           .          .          .
      "001855" 2010      .0897076   -.10372785   .19343546           .          .          .
      "001855" 2011    .015470693   .011834325 .0036363676           .          .          .
      "001855" 2012      .0635791   .006782219   .05679687           .          .          .
      "001855" 2013     .05467487   -.05245628   .10713115           .          .          .
      "001855" 2014    .030865803   -.07485598   .10572179  -.10533644          0 -.09507062
      "001855" 2015   -.008031781   -.03838891  .030357134  -.07355596   .2037961  .10750423
      "001855" 2016  .00016019505  -.003519125   .00367932  -.05852123   .2749106   .1760321
      "001855" 2017 -.00024305806   -.07272584   .07248278  -.10314717    -2.6788 -2.2901726
      "001855" 2018    .007708453  -.037151784   .04486024 -.018780556  -.6326878  -.2276851
      "001932" 1995             .            .           .           .          .          .
      "001932" 1996     .05035159 -.0045576873   .05490928           .          .          .
      "001932" 1997     .03975762  -.007800804   .04755843           .          .          .
      "001932" 1998     .02302531   -.01757553   .04060084           .          .          .
      "001932" 1999     .09279744   -.04931183   .14210926           .          .          .
      "001932" 2000     .10233927   -.04596145   .14830072           .          .          .
      "001932" 2001      .1244104    -.0530002    .1774106           .          .          .
      "001932" 2002     .13008712   -.04553049    .1756176           .          .          .
      "001932" 2003     .12556359   -.06941727   .19498086           .          .          .
      "001932" 2004     .11185377  -.037102714   .14895649           .          .          .
      "001932" 2005     .14132832  -.021294557    .1626229   -.0852292          0  2.2762423
      "001932" 2006     .15207887   -.02210575    .1741846   -.4527249  -12.76777   7.909246
      "001932" 2007      .1635437  -.024928775    .1884725   .06116212  -3.578239  -.9477926
      "001932" 2008      .1568746  -.022040235   .17891484   .04445792  -4.451492  -.9835192
      "001932" 2009     .16320503   -.01015416    .1733592   .10688499  3.5502696  1.2015682
      "001932" 2010      .1829864  -.028784374   .21177076   .06197146   .6293077  .55401886
      "001932" 2011     .19007257  -.009967442      .20004   .14125386   .7311197  .11962037
      "001932" 2012      .2086471   -.00473864   .21338575   .22394687   .1647793 -.50672024
      "001932" 2013     .21199822 -.0019923258   .21399055   .19139676   .7354411 -.15725724
      "001932" 2014      .1884331  -.016551048   .20498416   .15467118  1.0488538   .1577161
      "001932" 2015      .1710759  -.013418398    .1844943   .13151032   .7123489  .24158955
      "001932" 2016      .1488329 -.0017955336   .15062843   .11922158   5.987796   .9939422
      "001932" 2017      .0800062  -.015076516    .0950827    .2256536  1.6091285  -.1517841
      "001932" 2018     .06981697   -.02355766   .09337462  -.05140816   2.899344  1.5253427
      "001945" 1989             .            .           .           .          .          .
      "001945" 1990     .14320706   .007616256    .1355908           .          .          .
      "001945" 1991     .13903062   .017487915    .1215427           .          .          .
      "001945" 1992     .12570554  -.013460802   .13916634           .          .          .
      "001945" 1993     .11713618   .015894666   .10124151           .          .          .
      "001945" 1994      .0910662  -.005145867   .09621207           .          .          .
      "001945" 1995      .1200121   -.05224539    .1722575           .          .          .
      "001945" 1996     .11988798  -.034339435    .1542274           .          .          .
      "001945" 1997      .1133532   -.06020053   .17355374           .          .          .
      "001945" 1998     .04004966    -.1073485   .14739816           .          .          .
      end
      Parameters a, w1 and w2 have been estimated according to the following:

      Code:
       capture program drop one_prediction
       program define one_prediction
          tsset year
          regress earnings L1.accruals L1.cashflows in 2/-8
          gen a = _b[-cons]
          gen w1 =_b[L1.accruals]
          gen w2 =_b[L1.cashflows]
          predict predicted_earnings
          keep in L
          exit
      end  
      
      rangerun one_prediction, interval(year -11 0) by(company)
      Now, I would like to create a sample consisting of observations with w1<w2 at pvalue<0.10 only. This sample should include observations where the F-statistics on the difference between w1 and w2 is significant with a p-value of 0.10 (one-sided) or less. How could I do that? And how could I calculate standard deviation for w1 and w2 for each observation each year?
      Thanks in advance for the attention.
      Kind regards,

      Daniel
      Last edited by Danilo Sultanazzi; 30 Sep 2019, 04:27.

      Comment

      Working...
      X