Hello,
I have a dataset with 10 variables and 5 binary variables (A, B, C,D,E). I'm trying to get all possible combinations of 2,3, 4 and 5 of all but I'm not sure how to go about this using a loop/permin,combin in Stata. Moreover, I want Stata to count each combination iteration and tell me the sum of times each variable (intersection in combinations/permutations) is is 1.
The data is such that the number of A=1 (say 5) instances adds upto A=1 in all other iterations ( A=1 + B=1 +C=1 (2), A=1+C=1 (3). For example, I've been trying:
tab A if A !=0 & B !=0 & C !=0
I'm having difficulties getting the combinations with a loop (minimum code) and also tallying up all iterations to 5.
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(A B C D E)
1 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 0 0 0 1
1 0 0 0 0
0 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
0 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 0 0 0 0
1 0 0 0 1
1 0 0 0 1
0 0 0 0 0
1 0 0 0 0
0 0 0 0 0
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 0 0 0 0
0 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
0 0 0 0 0
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 0 0 0 1
1 0 0 0 1
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
1 0 0 0 0
0 0 0 0 0
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
Related Posts with Combinations of binary variables
keep observations if first 2 character of the string is capital letterI have a dataset where the variable x is a string. I need to keep only observations at which the fir…
Compare coefficients with xtreg i.year and feHello, I have two models: Model A: Y = α1 + β1X1 + Σθ∙C + firm-fixed effect + year-fixed effect M…
Transformation of valuesHi, I have a data set on tumors with the variables karnofsky index/KI (categorical with values 40, …
Latent growth curve modelingDear experts, I am currently trying to fit an unconditional growth curve model (as a first step befo…
HeckmanHi, How do I apply weights in Heckman selection model? Thank you …
Subscribe to:
Post Comments (Atom)
0 Response to Combinations of binary variables
Post a Comment