代码拉取完成,页面将自动刷新
*! 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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。