Dear All,
If you take this data:
then run
We get a new var (ywr) that samples y with replacement within its group and puts the new values in ywr. I would like to sample with replacement from group 3 only and place the new values in ywr for all y across all groups (or irrespective of group).
Any ideas how the code could be modified to do this?
Many thanks
Suhail
If you take this data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(grp y) 1 107 1 115 1 132 1 118 1 151 2 219 2 287 2 212 2 235 2 241 2 280 3 333 3 321 3 372 3 316 3 345 3 338 end
Code:
mata: mata clear putmata y putmata grp mata: rseed(87654321) yrows = rows(y) grpn = _mm_panels(grp) grpn index = mm_sample(.,grpn) ywr = y[index[,1],1] end getmata ywr list, sep(0)
Any ideas how the code could be modified to do this?
Many thanks
Suhail
Comment