Hi all, 

I just wanted to point out that in our latest version of Amelia (v 1.6), we have added some features that will help you export the imputations to the Stata flong format, ready for use with the "mi" suite of commands. You can update your version of Amelia by opening R and running the following command:

install.packages("Amelia", repos = "http://r.iq.harvard.edu", type = "source")

Specifically, in AmeliaView, there is an option for exporting to "Stata 10+ (stacked)" which will export one .dta file with each imputed dataset and the original data all stacked together with an additional variable called "imp" that records to which imputed dataset the observation belongs (this is 0 in the case of the original data). One exported, you can load up this dataset in Stata using the "mi import flong" command and use any of the built-in "mi estimate" commands. 

At the R command line, you can export a stacked Stata file using the update "write.amelia" function with the "separate" argument set to FALSE. 

The updated documentation that has an example of the R and Stata code needed to do all of this (see sec. 4.2.1 and 4.9):

http://r.iq.harvard.edu/docs/amelia/1.6/amelia.pdf

Note that the documentation on the main Amelia page is slightly out of date. We're working to fix that. 

Cheers,
matt.

~~~~~~~~~~~
Matthew Blackwell
PhD Candidate
Institute for Quantitative Social Science
Department of Government
Harvard University
url: http://www.mattblackwell.org

On Saturday, February 18, 2012 at 1:32 PM, Michelle Phelps wrote:

Hi Ken.  I recently did just this by editing the STATA imputation files (to give them a m id tag), appending them (to convert into flong format), and then importing into STATA.  Below is my code.  NOTE: This was done in STATA 12.

Best,

Michelle

----

Michelle Phelps
Ph.D. Candidate
Sociology & Social Policy
Princeton University
www.princeton.edu/~phelps




****Appending imputed data sets****

* 1) Adding m terms to each file
use "H:\AMELIA MI\Imputation Files\State Vars for AMELIA_0"
gen m=0
save, replace
clear

use "H:\AMELIA MI\Imputation Files\State Vars for AMELIA_1"
gen m=1
save, replace
clear

use "H:\AMELIA MI\Imputation Files\State Vars for AMELIA_2"
gen m=2
save, replace
clear

use "H:\AMELIA MI\Imputation Files\State Vars for AMELIA_3"
gen m=3
save, replace
clear

use "H:\AMELIA MI\Imputation Files\State Vars for AMELIA_4"
gen m=4
save, replace
clear

use "H:\AMELIA MI\Imputation Files\State Vars for AMELIA_5"
gen m=5
save, replace
clear


* 2) Appending files together

use "H:\AMELIA MI\Imputation Files\State Vars for AMELIA_0"
append using "H:\AMELIA MI\Imputation Files\State Vars for AMELIA_1"
append using "H:\AMELIA MI\Imputation Files\State Vars for AMELIA_2"
append using "H:\AMELIA MI\Imputation Files\State Vars for AMELIA_3"
append using "H:\AMELIA MI\Imputation Files\State Vars for AMELIA_4"
append using "H:\AMELIA MI\Imputation Files\State Vars for AMELIA_5"

*Check
tab m

*Sorting
sort state year


* 3) Saving data (NOTE: Stata requires this step -- data must be saved before importing)
save "H:\AMELIA MI\Imputation Files\State Vars for AMELIA_FINAL", replace

* 4) Importing into STATA as MI

mi import flong,  m(m) id(state year) imputed(drug_arrest_rate_all_urb per_cap perc_foreign perc_leg_repub perc_urban prison_adm_tot prison_rel_tot prob_rate prob_tot unempl_ratio_blacktowht)
*NOTE: Use the "imputed" to note which variables had missing data.  All imputed vars should be declared.

mi describe
mi varying
*See STATA help on the import command re: what these commands should produce if data are properly identified

* 5) XT models

*Setting data as MI time series
mi xtset state_no time

*Using MI xtreg
mi estimate: xtreg f.inc_rate crimerate drug_arrest_rate_all_urb p1524 fisc_cap lag10x_fiscap log_totexpend_percap ///
p_police p_welf perc_leg_repub repgov per_cap rtws south gini perc_black perc_hisp perc_foreign  ///
perc_urban unempl_rate_total pov_rate statepop000 time time_sq if decade==1, re

drop m


*Saving
save "H:\AMELIA MI\Imputation Files\State Vars for AMELIA_FINAL", replace


On Sat, Feb 18, 2012 at 12:55 AM, Ken-Hou Lin <kenhou.lin@gmail.com> wrote:
Dear Amelia users

I'm using Amelia 2 in R to do the multiple imputation. I have
successfully run the imputation and saved them into Stata files. Is
there any way I can load the completed data sets back to Stata without
using the Clarify package? I am asking because Clarify does not
support models such as xtmixed, which I'd like to use for my analysis.
I'm also not sure whether I can just calculate the coefficients and
standard errors by hand when it comes to Multi-level models.

Thanks for your help,
Ken
--
Amelia mailing list served by HUIT
[Un]Subscribe/View Archive: http://lists.gking.harvard.edu/?info=amelia
More info about Amelia: http://gking.harvard.edu/amelia
Amelia mailing list
Amelia@lists.gking.harvard.edu
https://lists.gking.harvard.edu/mailman/listinfo/amelia

--
Amelia mailing list served by HUIT
[Un]Subscribe/View Archive: http://lists.gking.harvard.edu/?info=amelia
More info about Amelia: http://gking.harvard.edu/amelia
Amelia mailing list
Amelia@lists.gking.harvard.edu
https://lists.gking.harvard.edu/mailman/listinfo/amelia