1 Star 0 Fork 2

kerrydu/statamacroe

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
translog.ado 2.81 KB
一键复制 编辑 原始数据 按行查看 历史
kerrydu 提交于 2024-02-08 23:02 . added packages
*! version 1.1 3Mar2017
* Kerry Du
cap program drop translog
program def translog,rclass
syntax varlist(min=1) [,Time(varname) NORMalize Local(str)]
version 10.1
local newvarlist
if "`normalize'"=="" {
foreach v of local varlist {
qui gen ln`v'=ln(`v')
label var ln`v' "log(`v')"
local newvarlist `newvarlist' ln`v'
}
local y `varlist'
foreach v of local varlist {
gettoken x y: y
foreach v1 of local y {
qui gen ln`v'_ln`v1'=0.5*ln`v'*ln`v1'
label var ln`v'_ln`v1' "0.5 * ln`v' * ln`v1'"
local newvarlist `newvarlist' ln`v'_ln`v1'
}
}
if "`time'"!="" {
qui egen _t=group(`time')
label var _t "time trend"
local newvarlist `newvarlist' _t
foreach v of local varlist {
qui gen _t_ln`v'=0.5*_t*ln`v'
label var _t_ln`v' "0.5 * _t * ln`v'"
local newvarlist `newvarlist' _t_ln`v'
}
qui gen _t_2=0.5*_t^2
label var _t_2 "0.5 * _t_square"
local newvarlist `newvarlist' _t_2
}
foreach v of local varlist {
qui gen ln`v'_2=0.5*ln`v'*ln`v'
label var ln`v'_2 "0.5 * ln`v'_square"
local newvarlist `newvarlist' ln`v'_2
}
}
else {
disp as green "Note: Variables are normalized by their means respectively before taking log."
foreach v of local varlist {
qui su `v'
local vmean=r(mean)
qui gen ln`v'=ln(`v'/`vmean')
label var ln`v' "log(`v')"
local newvarlist `newvarlist' ln`v'
//qui gen ln`v'_2=0.5*ln`v'*ln`v'
//label var ln`v'_2 "0.5 * ln`v'_square"
}
local y `varlist'
foreach v of local varlist {
gettoken x y: y
foreach v1 of local y {
qui gen ln`v'_ln`v1'=0.5*ln`v'*ln`v1'
label var ln`v'_ln`v1' "0.5 * ln`v' * ln`v1'"
local newvarlist `newvarlist' ln`v'_ln`v1'
}
}
if "`time'"!="" {
disp as green "Note: _t is the deviation from the mean."
qui egen _t=group(`time')
label var _t "time trend"
qui su _t
local vmean=r(mean)
qui replace _t=_t-`vmean'
local newvarlist `newvarlist' _t
foreach v of local varlist {
qui gen _t_ln`v'=0.5*_t*ln`v'
label var _t_ln`v' "0.5 * _t * ln`v'"
local newvarlist `newvarlist' _t_ln`v'
}
qui gen _t_2=0.5*_t^2
label var _t_2 "0.5*_t_square"
local newvarlist `newvarlist' _t_2
}
foreach v of local varlist {
qui gen ln`v'_2=0.5*ln`v'*ln`v'
label var ln`v'_2 "0.5 * ln`v'_square"
local newvarlist `newvarlist' ln`v'_2
}
}
return local xvar `newvarlist'
if "`local'" != "" {
c_local `local' `newvarlist'
}
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
其他
1
https://gitee.com/kerrydu/statamacroe.git
[email protected]:kerrydu/statamacroe.git
kerrydu
statamacroe
statamacroe
master

搜索帮助