📄 glogit.ado
字号:
*! version 4.0.4 31mar2005
program define glogit, eclass byable(onecall) properties(or)
if _by() {
local BY `"by `_byvars'`_byrc0':"'
}
if _caller() < 9 {
`BY' glogit_8 `*'
exit
}
`BY' _vce_parserun glogit, jkopts(eclass) : `0'
if "`s(exit)'" != "" {
exit
}
version 6.0, missing
if replay() {
if `"`e(cmd)'"'!=`"glogit"' { error 301 }
if _by() { error 190 }
Replay `0'
exit
}
`BY' Estimate `0'
end
program Estimate, eclass byable(recall)
syntax varlist(min=2) [if] [in] [, or Level(cilevel) ]
marksample touse
tokenize `varlist'
local lhs1 "`1'"
local lhs "`1' `2'"
tempvar S F LOGIT xb L
quietly {
gen double `S'=`1' if `1'>=0 /* NB: S+F = n(i) */
gen double `F'=`2'-`1' if `2'>=0 & `2'>`1'
gen double `LOGIT'=log(`S'/`F') if `touse'
mac shift 2
/* Stage one to get consistent estimates of weights */
_regress `LOGIT' `*' if `touse'
predict double `xb', xb
gen double `L' = exp(`xb') / ( 1 + exp(`xb'))
replace `L' = `L'*(1-`L')*(`S'+`F')
_regress `LOGIT' `*' [aw=`L'] if `touse', depname(`lhs1')
}
est local cmd
est local estat_cmd "" /* override what _regress set */
est local depvar "`lhs'"
est local wexp
est local wtype
est local ll
est local ll_0
est local predict "glogit_p"
est local title ///
`"Weighted LS logistic regression for grouped data"'
est local cmd "glogit" /* double save in e() and S_E_ */
global S_E_cmd "glogit"
Replay, level(`level') `or'
end
program Replay
syntax [, or Level(cilevel) ]
if `"`or'"'!=`""' { local or `"eform(Odds Ratio)"' }
if "`e(prefix)'" == "" {
di _n as txt `"`e(title)'"'
}
regress, level(`level') `or'
end
exit
/*
Prior to version 9 of Stata, the weights were calculated using the
observed proportions in the formula n*p*(1-p). Now we run a first-
stage OLS regression to get predicted p's and use those in the weights
instead. See Greene (3rd ed., p. 896, fn. 24). BPP
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -