STATA 学习笔记: outlier(离群值)的处理

您所在的位置:网站首页 stata如何删除变量 STATA 学习笔记: outlier(离群值)的处理

STATA 学习笔记: outlier(离群值)的处理

2023-09-07 09:11| 来源: 网络整理| 查看: 265

STATA 学习笔记: outlier(离群值)的处理

处理办法

1. 取对数 sysuse nlsw88, clear histogram wage

在这里插入图片描述 时薪大于40美元的属于离群值

gen lwage = ln(wage) histogram lwage

在这里插入图片描述 取对数之后,接近正态分布

2. 删除/截尾(trimming)

标准: ①标准差:超过标准差的2倍或3倍 ②1%或99%分位

命令 winsor2,trim

Description

winsor2 winsorize or trim (if trim option is specified) the variables in varlist at particular percentiles specified by option cuts(#1 #2). 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. sysuse nlsw88, clear sum wage,detail

在这里插入图片描述

sysuse nlsw88, clear winsor2 wage, cuts(1 99) replace trim //不加trim就是缩尾,加trim才是截尾 count if (wage


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3