📄 xtcnt_p.ado
字号:
*! version 1.1.3 30sep2004
program define xtcnt_p
version 6, missing
/* Step 1:
place command-unique options in local myopts
Note that standard options are
LR:
Index XB Cooksd Hat
REsiduals RSTAndard RSTUdent
STDF STDP STDR noOFFset
SE:
Index XB STDP noOFFset
*/
local myopts "XB NU0 IRU0"
/* Step 2:
call _propts, exit if done,
else collect what was returned.
*/
_pred_se "`myopts'" `0'
if `s(done)' { exit }
local vtyp `s(typ)'
local varn `s(varn)'
local 0 `"`s(rest)'"'
/* Step 3:
Parse your syntax.
*/
syntax [if] [in] [, `myopts' noOFFset]
/* Step 4:
Concatenate switch options together
*/
local type "`nu0'`iru0'`xb'"
/* Step 5:
quickly process default case if you can
Do not forget -nooffset- option.
*/
/* Step 6:
mark sample (this is not e(sample)).
*/
marksample touse
/* Step 7:
handle options that take argument one at a time.
Comment if restricted to e(sample).
Be careful in coding that number of missing values
created is shown.
Do all intermediate calculations in double.
*/
/* Step 8:
handle switch options that can be used in-sample or
out-of-sample one at a time.
Be careful in coding that number of missing values
created is shown.
Do all intermediate calculations in double.
*/
if "`type'"=="xb" | "`type'"=="" {
if "`type'"=="" {
di in gr /*
*/ "(option xb assumed; linear prediction)"
}
_predict `vtyp' `varn' if `touse', xb `offset'
label var `varn' "linear prediction"
exit
}
if "`type'"=="nu0" {
tempvar xb
qui _predict double `xb' if `touse', xb `offset'
gen `vtyp' `varn' = exp(`xb') if `touse'
label var `varn' "predicted number of events (assuming u_i=0)"
if "`e(cmd2)'"=="xtn_re" {
tempname rr
scalar `rr' = (exp(_b[/ln_r]))
if `rr' > 1 {
qui replace `varn' = /*
*/ `varn'*(exp(_b[/ln_s]))/(`rr'-1)
}
else {
di as txt "warning: estimated value of r " _c
di as txt "is less than one; expected value" _c
di as txt " undefined."
qui replace `varn' = .
}
label var `varn' "predicted number of events"
}
exit
}
if "`type'"=="iru0" {
tempvar xb
qui _predict double `xb' if `touse', xb nooffset
gen `vtyp' `varn' = exp(`xb') if `touse'
label var `varn' "predicted incidence rate (assuming u_i=0)"
if "`e(cmd2)'"=="xtn_re" {
qui replace `varn' = `varn'*(exp(_b[/ln_s])/ /*
*/ (exp(_b[/ln_r])-1))
label var `varn' "predicted incidence rate"
}
exit
}
error 198
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -