Announcement

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

  • Randomly redistribute values

    I have a dataset with different types of variables (dates, string, numeric). I would like to pseudomize the data by randomly re-shuffling the values within each variable.

    Do you know how to re-shuffle the values within each variable?

  • #2
    Henry:
    without further details/example/data excerpt from your side, what springs to my mind is -runiform()-.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Is your dataset a "simple" dataset, where the observations are, essentially, independent of each other? Or is your dataset some form of a panel dataset, where some of the variables may have implicit consistency rules within each panel - same birth year in each observation for a given individual, for example?

      Comment


      • #4
        Good point, I realized simple reshuffle will nor work. Unfortunately, the data structure is very complicated as it is a linked panel dataset in spell format.

        Here is an example of the structure

        Code:
        input id birthdate education spelltype spellbeg spellend establishment_id firmsize
        1 01jan1970 10 unempl 01jan1990 30dec1990 . .
        1 01jan1970 10 unempl 01jan1991 30dec1992 . .
        1 01jan1970 11 empl 01jan1992 30dec1995 1 10
        1 01jan1970 11 empl 01jan1996 30dec1998 2 100
        1 01jan1970 11 empl 01jan1999 30dec1999 2 105
        end
        • id is an identifier for each person
        • birthdate is an example of variable that would be constant within id
        • education is an example of a variable that is time-varying (and has logical implication that it should not decrease over time)
        • Then there is information about spells which can be either employment, inactivity or unemployment.
        • Each spell has beginning and end date (and here again there is logical implications that spell end > spell begin AND spell beign[_n+1] > spell end [_n])
        • If the spell is an employment spell then is another panel dimension, namely the establishment, which has an id and again variable that are fixed over time or might vary.
        So yea, reshuffling was a bad idea. I will open another question about constructing this from scratch.

        Comment


        • #5
          If future visitors of this thread do want to reshuffle, here is a good Stata tip on how to do it:

          Ängquist, Lars. "Stata tip 92: Manual implementation of permutations and bootstraps." The Stata Journal 10, no. 4 (2010): 686-688.

          Comment

          Working...
          X