Random number generation but common within group

55 Views Asked by At

Is there a way to generate random numbers from a distribution such that these numbers are common for rows within a group? Within an unbalanced panel, there is a household_id variable according to which I want to generate random numbers from truncated normal distribution using rtruncnorm.

Thank you.

1

There are 1 best solutions below

0
On

Household_id    Random number
1               0.6
1               0.6
1               0.6
2               0.1
3               0.9
3               0.9
4               0.2
5               0.7
6               0.3
6               0.3
So, the household_id is for identifying the household in this unbalanced panel. Now, I want to generate random numbers using rtruncnorm such as shown, they are the same for within household cells.

Thank you