winsor2 批量进行 winsor trimming 处理
winsor2 命令使用说明 |
NEW: winsor2 已经可以直接在 Stata 内部下载,命令如下:
ssc install winsor2, replace
简介: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.
相比于winsor命令的改进:
(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)
复制代码
使用方法: winsor2 已经可以直接在 Stata 内部下载,命令如下:
ssc install winsor2, replace
评论前必须登录!
注册