举个例子,假设price中存在缺失值是用" ."表示的空缺值。其他的是一些和price相关的变量
* 回归法(如果样本量小,不想把缺漏值删除,就用这个命名来填补缺漏的值,假设这个缺漏值跟现有的其他变量是有线性关系的,用回归产生新的变量i_price的值就是相应的缺漏值)
impute price weight length foreign turngear, gen(i_price)
list price price i_price if price==.
* 插值法(就是利用缺漏值前后已有数据求出斜率,再根据已有Y,求出缺漏值X)
ipolate price weight, gen(ip_price)epolate
list price price i_price ip_price ifprice2==.
do L2_data_gr_ipolate.do /*图解*/
* 如果缺漏值的数目较多,并不建议采用插值法,因为无法提供新的信息
* 插值法比较适用于时间序列