You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
Plaintext
51 lines
1.2 KiB
Plaintext
9 months ago
|
*! version 1.0 Alfonso Miranda-Caso-Luengo, June 2003 (SJ4-1: st0057)
|
||
|
program define espoisson_p, sort
|
||
|
version 7
|
||
|
|
||
|
local myopts "n"
|
||
|
|
||
|
_pred_se "`myopts'" `0'
|
||
|
if `s(done)' { exit }
|
||
|
local vtyp `s(typ)'
|
||
|
local varn `s(varn)'
|
||
|
local 0 `"`s(rest)'"'
|
||
|
|
||
|
syntax [if] [in] [, `myopts' noOFFset]
|
||
|
|
||
|
local type "`n'"
|
||
|
marksample touse
|
||
|
|
||
|
if "`type'"=="n" | "`type'"=="" {
|
||
|
|
||
|
tempname mu zu lnsigma kappa
|
||
|
qui _predict double `mu' if `touse', xb `offset' eq(#1)
|
||
|
qui _predict double `zu' if `touse', xb `offset' eq(#2)
|
||
|
qui _predict double `lnsigma' if `touse', xb eq(#3)
|
||
|
qui _predict double `kappa' if `touse', xb eq(#4)
|
||
|
|
||
|
local d "`e(edummy)'"
|
||
|
|
||
|
tempvar sma u rho
|
||
|
gen double `sma' = exp(`lnsigma')
|
||
|
gen double `rho' = (exp(2*`kappa')-1)/(exp(2*`kappa')+1)
|
||
|
|
||
|
tempvar p eta
|
||
|
gen double `p'=0 if `touse'
|
||
|
gen double `eta'=0 if `touse'
|
||
|
qui replace `mu'=exp(`mu'-0.5*`sma'^2) if `touse'
|
||
|
#delimit ;
|
||
|
qui replace `eta' = `d'*(norm(`zu' +`rho'*`sma')/norm(`zu'))
|
||
|
+ (1-`d')*(norm(-(`zu'+`rho'*`sma'))/norm(-(`zu'))) if `touse' ;
|
||
|
#delimit cr
|
||
|
qui replace `p'=`mu'*`eta' if `touse'
|
||
|
qui gen `vtyp' `varn'=`p' if `touse'
|
||
|
label var `varn' "predicted number of events of `e(depvar)'"
|
||
|
exit
|
||
|
}
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|