Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Is there an -mi drop- command?
From
daniel klein <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Is there an -mi drop- command?
Date
Wed, 10 Apr 2013 14:56:25 +0200
Clyde,
there is a -mi earse- command, but this does not seem to do what you
want. It seems you have to -drop- the data yourself.
Assuming your data is set -flong- style, all you need to do, is -drop-
the observations for which _mi_m equals one of the numbers of imputed
datasets you want to drop, then renumber the datasets (i.e. _mi_m) and
set the characteristic _dta[mi_M] to the number of imputations left. I
hope this approach does not oversimplify the problem, but it seems
there is not all too much "magic" behind -mi- that StataCorp is not
willing to document.
Anyway, here is a draft
*! version 1.0.0 10apr2013 Daniel Klein
pr midropm
vers 11.2
// check basic setting
u_mi_assert_set flong
loc M : char _dta[_mi_M]
if !(`M') {
di as err "no imputations"
e 459
}
// get user
syntax anything(id = "numlist") [, noUPdate]
numlist "`anything'" ,int max(249) r(>0 <=`M') sort
loc todrop `r(numlist)'
loc todrop : list uniq todrop
loc todrop : subinstr loc todrop " " ", " ,all
// drop datasets
qui drop if inlist(_mi_m, `todrop')
// renumber _mi_m
tempname old
qui ta _mi_m if _mi_m ,matrow(`old')
loc nM = r(r)
forv j = 1/`nM' {
qui replace _mi_m = `j' if (_mi_m == `old'[`j', 1])
}
// reset M
char _dta[_mi_M] `nM'
// certify
if ("`update'" == "") u_mi_certify_data ,proper
end
Best
Daniel
--
I'm pretty sure the answer to this question is no: I've scoured the MI
manual and can't find it.
Let me explain what I'm looking for and why I think such a command
would be useful.
[...]
Any thoughts?
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/