Announcement

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

  • Parallelising tasks

    Hi all,

    maybe this is a naive question. However, let's say I have either a for loop or a collapse like for instance the following:

    Code:
    collapse (first) hs4codeprod prod6_code exporter_iso_3digit dummymax* (sum) tradevalue tradequantity (max) _fillin, by(id_iso4)
    since it takes a lot to run it all, I was thinking about parallelising it in the 8 cores of my PC. Is it possible to do so in stata?

    Thank you a lot
    Last edited by Federico Nutarelli; 04 Feb 2021, 03:28.

  • #2
    Yes, probably, if you can rewrite your code so it can be done my multiple instances. For example, split up by variables and merge afterwards.
    https://journals.sagepub.com/doi/abs...36867X19874242
    https://github.com/gvegayon/parallel
    If you cannot reach behind the paywall, I think the github rep provides the working paper.
    Best wishes

    Stata 18.0 MP | ORCID | Google Scholar

    Comment


    • #3
      Thank you very much

      Comment


      • #4
        You can also try the user written -gtools-,
        -https://gtools.readthedocs.io/en/latest/usage/gcollapse/-

        If you try it, do report whether it is doing it a lot faster.

        Comment


        • #5
          Federico Nutarelli I would recommend batcher package from ssc. There is also parallel package from ssc but batcher is much better for me as it does not require creation of multiple do files. You can run as many instances as you want given the core limits of your set up with batcher from a single file.

          Comment


          • #6
            Thank you all for your kind replies. I tried only parallel for my task. But I will try all of them in a later project. I will let you know if the speed increased a lot

            Comment

            Working...
            X