the variable has a well defined value conditional on the value of
a binary variable. So far, I am able to do this by adding a do operator
inside the function that iterates over each observation. This loop
is, however, taking a very long time. Is there a way to write my
conditional statement in a matrix so that I would not need to loop
over each observation?
Here is an example.
Code:
function geny(xx1){ y=xx1^2:+2:*xx1:+1 return(y) } u=runiform(sampsize,1,0,1) Z=u:>0.5 X=rnormal(sampsize,1,0,1) Y=geny(X)
Thank you in advance
0 Response to generating a conditional variable in mata without loop
Post a Comment