0

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.

  • By *common* do you mean *equal*? In order to ask a better question please read [How to ask a good question](https://stackoverflow.com/help/how-to-ask) and [Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/mcve) and [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Rui Barradas Apr 04 '19 at 15:48
  • Yes, the same/equal random numbers within a group but different between groups. The group column is defined by household_id variable. Thanks for your reply. Aplology if my question was not clear before. – user11292146 Apr 04 '19 at 15:55
  • can you please provide a sample of data with dput(data) ? – FALL Gora Apr 04 '19 at 15:59

1 Answers1

0

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