1 Star 0 Fork 2

kerrydu/statamacroe

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
pfilter.ado 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
kerrydu 提交于 2024-02-09 15:32 . added packages
*! Version 2.2
* Get the trend and cyclical components using filters for panel data
* By Kerui Du, [email protected]
* 23Jul 2017, use _xt
* 16May 2017, use xtset command
* 14Jun 2017
* 16Jun 2017
* 30Jun 2017
capture program drop pfilter
program define pfilter,rclass prop(xt)
version 12.1
syntax varname, method(str) [trend(str) cyc(str) *]
local cmdline `0'
_xt, trequired
local ivar=r(ivar)
local tvar=r(tvar)
//_xt, i(`i') t(`t') trequired
//local ivar "`r(ivar)'"
//local tvar "`r(tvar)'"
sort `ivar' `tvar'
qui levelsof `ivar', local(unqid) clean
mata: tre=J(0,1,.)
mata: cyc=J(0,1,.)
tempvar temp1 temp2
foreach j of local unqid{
preserve
qui keep if `ivar'==`j'
sort `tvar'
cap drop `temp1'
cap drop `temp2'
qui tsfilter `method' `temp1' = `varlist' , trend(`temp2') `options'
qui putmata xtrend=(`temp2') ,replace
qui putmata xcyc=(`temp1'),replace
mata: tre= tre \ xtrend
mata: cyc=cyc \ xcyc
restore
*continue,break
}
sort `ivar' `tvar'
if ("`trend'"!="") {
qui getmata (`trend')=tre
//disp "A new variable is generated to store the trend component."
}
if ("`cyc'"!="") {
qui getmata (`cyc')=cyc
//disp "A new variable is generated to store the cyclical component."
}
//disp "Done!"
return local cmd "pfilter"
return local varlist `varlist'
return local cmdline pfilter `cmdline'
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
其他
1
https://gitee.com/kerrydu/statamacroe.git
[email protected]:kerrydu/statamacroe.git
kerrydu
statamacroe
statamacroe
master

搜索帮助