Announcement

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

  • ASROL Version 4 is Here

    Thanks to Kit Baum, version 4 of ASROL is available on SSC now. New users can install it by
    Code:
    ssc install asrol
    and existing users can update the version by
    Code:
    adoupdate asrol, update

    Major Updates

    There are several major updates which I would like to highlight here


    1. Rolling window algorithm

    Since real-life data can come in a variety of structures, a static code for extracting the rolling-window from the data is always costly in terms of time. This version of asrol has more than 6 routines in the Mata language that are meant for different data structures. Therefore, asrol speed efficiency is ensured whether the data is rectangular (balanced panel), non-rectangular, has duplicates, has missing values, or has both duplicates and missing values.


    2. More statistics

    This version of asrol has the following additional statistics :

    2.1 Percentiles : Option perc(k) can be used alongside stat(median) to find k-th percentile of the values in range.
    2.2 product : This option can be used to multiply all the numbers in a given window
    2.3 gmean : This option finds the geometric mean of positive values in a given window



    3. Excluding focal observations

    There might be circumstances where we want to exclude the focal observation while calculating the required statistics.
    asrol now allows excluding focal observation with two flavors. The first one is to exclude only the current observation while the second one is to exclude all observation of the relevant variable if there are similar (duplicate) values of the rangevar elsewhere in the given window. The help file (help asrol ) has examples to explain these two options in more details.


    4. By group statistics

    The option window is optional in this version of asrol . Hence, it can be dropped altogether. Therefore, asrol can be used for finding statistics over groups with or without using rolling window. Without the option window, asrol generates statistics just like egen command. When used with bys prefix (see below more details), asrol can closely match the speed of egen.


    5. The bysort prefix

    Earlier version of asrol would accept only option by(varlist). This version accepts two options for group statistics: i.e. by(varlist) (specified after comma) and bysort varlist used as a prefix to the asrol command. The bysort prefix is faster than the other option.


    6. Speed Efficiency

    And above all, this version is way faster than all previous versions of asrol. Those who are interested can compare the speed of this version with the earlier version using data sets which are posted here https://www.statalist.org/forums/for...peed-advantage

    Acknowledgements
    Thanks to Nick Cox who reported a small bug in the calculation of median in version 3 of asrol. This version has fixed that bug. I would really appreciate comments for further improvement of asrol.
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

  • #2
    Dear Attaullah, Thanks for sharing with us this helpful command. Is it possible to specify more than one argument in the option "stat", e.g.,
    Code:
    bys company: asrol invest, stat(count mean) win(year 4)
    Ho-Chuan (River) Huang
    Stata 17.0, MP(4)

    Comment


    • #3
      River: rangestat (SSC) can do this.

      Code:
      webuse grunfeld, clear
      rangestat (count) invest (mean) invest, int(year -3 0) by(company)

      Comment


      • #4
        River Huang, asrol is more like egen command, it handles one statistic at a time.
        Regards
        --------------------------------------------------
        Attaullah Shah, PhD.
        Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
        FinTechProfessor.com
        https://asdocx.com
        Check out my asdoc program, which sends outputs to MS Word.
        For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

        Comment


        • #5
          Since speed seems to be an important issue here (it is mentioned twice, in points 1 and 6 and has been discussed before on the list), I would think about how often you really only want one statistic. I honestly cannot tell, as I do not work in this area. However, I would guess that any speed efficiency in coding to get one statistic will likely be canceled out completely once you have to run the command twice or more often to end up with all the stats you want.

          Best
          Daniel

          Comment


          • #6
            I guess the lesson here is, as always, to avoid falling prey to the Law of the Instrument and carefully choose your tool to match the task at hand. Colloquially, the Law of the Instrument tells us not to use a hammer to drive a screw, nor a screwdriver to pound in a nail.

            For those of us with big data for problems that fit the capabilities of asrol, its potential for gains in running speed can be important. While I sometimes want several statistics, as Daniel Klein suggests, I also sometimes want the same statistic for several variables, which of course asrol supports in a single call.

            But big data is a lot easier to obtain in corporate finance where Attaullah Shah works than in the social sciences where I work, and I find the run time of my code is dwarfed by the time I spend writing it.

            So for that reason I choose other tools, like egen and rangestat, knowing that their familiarity and flexibility will, for me on my problems, reduce the total time - programming time and run time combined - needed to solve my problems.

            Comment


            • #7
              No intentions to make this a big discussion (again), but given the potential overlap of the commands (instruments/hammers/screwdrivers) for the same task at hand (driving a screw/pound in a nail), I would say that

              [asrol's] potential for gains in running speed
              needs to be shown when compared to another hammer/screwdriver and just as

              asrol supports [the same statistic for several variables] in a single call
              so does rangestat.

              I will be quite on this now.

              Best
              Daniel

              Comment


              • #8
                Actually, I see now that in reading help asrol I interpreted the following
                Code:
                Syntax
                
                    [bysort]:asrol varlist [if] [in], stat(stat_options) window(rangevar #) [gen(newvar) by(varlist) minimum(#) add(#) perc(#) xf([focal | rangevar])]
                as suggesting that asrol accepts a variable list in the way that rangestat does.

                However, rerunning the first example from help asrol with two variables specified shows that the variable list can contain only a single variable.
                Code:
                . webuse grunfeld
                
                .   bys company: asrol invest mvalue, stat(mean) win(year 4)
                too many variables specified
                r(103);
                Perhaps help asrol could be updated to replace the first occurence of "varlist" in the syntax definition with "varname" and have it link to help varname rather than help varlist.
                Last edited by William Lisowski; 14 Sep 2017, 10:55.

                Comment


                • #9
                  Hi, Nick, Thanks for the suggestion. Indeed, I have done that using -rangestat- command. Just for comparison, I used -mvsumm-, -asrol-, and -rangestat- to the same data to see their performance.

                  Ho-Chuan (River) Huang
                  Stata 17.0, MP(4)

                  Comment


                  • #10
                    Hi, Attaullah: Got it and thanks for the reply.
                    Ho-Chuan (River) Huang
                    Stata 17.0, MP(4)

                    Comment


                    • #11
                      Thanks for your comments. I have updated asrol on SSC and now it supports multiple statistics for multiple variables in one go. Statalist post related to this update can be read here for full details.

                      Short example is here for multiple statistics
                      Code:
                      webuse grunfeld, clear bys company: asrol mvalue, stat(sd mean count) w(year 4)
                      or for multiple variables and multiple statistics
                      Code:
                      bys company: asrol invest mvalue kstock, stat(mean sd count median) w(year 4)
                      Regards
                      --------------------------------------------------
                      Attaullah Shah, PhD.
                      Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                      FinTechProfessor.com
                      https://asdocx.com
                      Check out my asdoc program, which sends outputs to MS Word.
                      For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                      Comment

                      Working...
                      X