How to split a pattern according to a specific variable in Stata?

I would like to break the pattern according to a specific variable, creating 4 sub-choices, each of which is associated with a quartile of the distribution of the variables. The goal is to demonstrate that the presence of different levels of this variable affects the outcome of the regression, making it significant or not.

+4
source share
2 answers

The easiest way to do this is to use the egen command to cut your variable into four equally spaced intervals.

Example:

 . sysuse auto, clear (1978 Automobile Data) . sum price, detail Price ------------------------------------------------------------- Percentiles Smallest 1% 3291 3291 5% 3748 3299 10% 3895 3667 Obs 74 25% 4195 3748 Sum of Wgt. 74 50% 5006.5 Mean 6165.257 Largest Std. Dev. 2949.496 75% 6342 13466 90% 11385 13594 Variance 8699526 95% 13466 14500 Skewness 1.653434 99% 15906 15906 Kurtosis 4.819188 . egen price_cut = cut(price), group(4) . table price_cut, contents(n price min price max price) ---------------------------------------------- price_cut | N(price) min(price) max(price) ----------+----------------------------------- 0 | 18 3,291 4,187 1 | 19 4,195 4,934 2 | 18 5,079 6,303 3 | 19 6,342 15,906 ---------------------------------------------- 

Hope this helps you.

+6
source

This is the easiest way:

 xtile xx=yourvariable, nq(4) 

Hope this helps.

0
source

Source: https://habr.com/ru/post/1436194/


All Articles