Suppose I have a variable var1. What is the best/most efficient way of accessing its contents in a Mata if statement?
Something like:
Something like:
Code:
..... if var1 == 23
mata: rseed(1) x = runiform(10,1):>.5 var1 = 23*x either var2 = J(rows(var1),1,.) index = selectindex(var1:==23) var2[index] = rbinomial(rows(index),1,1,0.46) or var2 = rbinomial(rows(var1),1,1,0.46):*(var1:==23) // but here you evaluate more binomial variates than needed end
Comment