-
Notifications
You must be signed in to change notification settings - Fork 2
/
mi_dom.ado
50 lines (27 loc) · 1.25 KB
/
mi_dom.ado
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
*! mi_dom version 0.0.1 1/12/2024 Joseph N. Luchman
program define mi_dom, eclass //history and version information at end of file
version 15
syntax varlist if [aw fw iw pw], Reg_mi(string) Fitstat_mi(string) [MIOpt(string)]
tempfile mifile //produce a tempfile to store imputed fitstats for retreival
tempvar touse
tempname fitstat
gettoken reg_mi regopts_mi: reg_mi // separate out reg() options
quietly generate byte `touse' = 1 `if'
quietly mi estimate, saving(`mifile') `miopt': `reg_mi' ///
`varlist' [`weight'`exp'] `if', `regopts_mi' //run mi analysis saving results
scalar `fitstat' = 0 //placeholder scalar to hold the sum
local num_imputes = `:word count `e(m_est_mi)''
foreach x of numlist `=e(m_est_mi)' {
estimates use `mifile', number(`x') //find the focal estimates
scalar `fitstat' = `fitstat' + `=`fitstat_mi''*`num_imputes'^-1 //add in the weighted fitstat value
}
local title = e(title)
ereturn clear
ereturn post, esample(`touse')
ereturn local title = "Multiply imputed: `title'"
ereturn scalar fitstat = `fitstat'
end
/* programming notes and history
- mi_dom version 0.0.0 - August 14, 2023
// 0.0.1 - January 12, 2024
- fixed 'which' reference - erroneously noted 'fitdom' as program - thanks to Eric Melse for bug report