首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何限制插值值的最大缺失间隙

如何限制插值值的最大缺失间隙
EN

Stack Overflow用户
提问于 2018-05-28 17:51:54
回答 1查看 163关注 0票数 0

在插值或外推(使用带或不带epolateipolate )缺失值时,是否可以预先限制要插值(或外推)的缺失间隙大小,或者事后计算间隙大小?

实际上,我想要的是将最大连续插值(我的数据是每年)限制为三年。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-28 18:10:38

你总是可以计算法术的长度,然后有条件地使用ipolate。这里我使用SSC中的tsspell来计算这些人工引入的长度:

代码语言:javascript
复制
webuse grunfeld, clear 
set seed 2803 
replace invest = . if runiform() < 0.2 
tsset company year 
* need previous -ssc install tsspell- to run this 
tsspell , cond(missing(invest)) 
egen length = max(_seq), by(company _spell) 
tab length 
list company year invest if length >= 3, sepby(company _spell)

     +-------------------------+
     | company   year   invest |
     |-------------------------|
 13. |       1   1947        . |
 14. |       1   1948        . |
 15. |       1   1949        . |
     |-------------------------|
 41. |       3   1935        . |
 42. |       3   1936        . |
 43. |       3   1937        . |
     +-------------------------+

ipolate invest year if length <= 2, by(company) epolate
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50563580

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档