winsor2
Stata 进行批量进行 winsor 或 trimming 处理的第三方命令,作者为连玉君。
winsor2 winsorize or trim (if trim option is specified) the variables in varlist at particular percentiles specified by option cuts(# #). In defult, new variables will be generated with a suffix "_w" or "_tr", which can be changed by specifying suffix() option. The replace option replaces the variables with their winsorized or trimmed ones.
ssc install winsor2, replace
winsor2 varlist [if] [in], [ suffix(string) replace trim cuts(# #) by(groupvar) label ]
(1) 可以批量处理多个变量;
(2) 不仅可以 winsor,也可以 trimming;
(3) 附加了 by() 选项,可以分组 winsor 或 trimming;
(4) 增加了 replace 选项,可以不必生成新变量,直接替换原变量。
/*- winsor at (p1 p99), get new variable "wage_w"*/
. sysuse nlsw88, clear
. winsor2 wage
/*- left-trimming at 2th percentile*/
. winsor2 wage, cuts(2 100) trim
/*- winsor variables by (industry south), overwrite the old variables*/
. winsor2 wage hours, replace by(industry south)
姓名:连玉君邮箱:arlionn@163.com
单位:中山大学岭南学院金融系