1 Star 0 Fork 2

kerrydu/statamacroe

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
calk.ado 1018 Bytes
一键复制 编辑 原始数据 按行查看 历史
kerrydu 提交于 2021-07-09 19:39 . 0
cap program drop calk
program define calk, sortpreserve
version 14
syntax varname(numeric), gen(string) t(varname) [first(numlist integer max=1 >=5) Delta(numlist max=1 >=0 <1) deltavar(varname) Ko(varname) id(varname) ]
if `"`id'"'!=""{
qui tab `id', nofreq
local nid=r(r)
local N=_N
if mod(`N',`nid')!=0{
noi display as error "{bf:calk} needs strongly balanced panel, use {bf:tsfill, full} to rectangularize your data."
exit
}
}
else{
tempvar id
qui gen `id'=1
}
if "`delta'"=="" local delta `deltavar'
if `"`ko'"'==""{
if "`first'"==""{
di as red "# of years in the begining should be specified."
}
tempvar g0
qui bys `id' (`t'): gen `g0'= (`varlist'[`first']/`varlist'[1])^(1/(`first'-1))-1
qui bys `id' (`t'): gen `gen'= `varlist'[1]/(`g0'+`delta')
}
else{
qui gen `gen'=`ko'
}
qui bys `id' (`t'): replace `gen'=(1-`delta')* `gen'[_n-1]+ `varlist' if _n>1
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
其他
1
https://gitee.com/kerrydu/statamacroe.git
[email protected]:kerrydu/statamacroe.git
kerrydu
statamacroe
statamacroe
master

搜索帮助