Page **1** of **1**

### Imputation files not found

Posted: **Mon Aug 22, 2016 10:33 pm**

by **amarkovitz**

Hello,

I ran what appeared to be a successful imputation procedure, but when I type realcomImputeLoad in stata, I am getting the following error:

**file imputeiter100. not found**

If it's helpful to diagnose this error, here is my model in stata:

realcomImpute bmi bmixsplinea1 bmixsplinea2 bmixsplinea3 bmixsplinea4 bmixsplinea5 bmiat18 ///

splinea1 splinea2 splinea3 splinea4 splinea5 parous HDL ///

parousxsplinea1 parousxsplinea2 parousxsplinea3 parousxsplinea4 parousxsplinea5 ///

post_preg_ind post_time h3 ses ///

using TestMIInput.dat, replace numresponses(7) ///

level2id(pid) cons(cons)

When I ran the MCMC, I obtained the attached log and it saved the attached impvals.txt file. It also created a storedata.mat file which as far as I can tell doesn't contain anything in it. Was there some issue in creating the imputed datasets? How were they supposed to be stored? As far as I can tell, the documentation doesn't get into this level of detail.

Thank you,

Amanda

### Re: Imputation files not found

Posted: **Mon Aug 22, 2016 11:04 pm**

by **ChrisCharlton**

When you run the imputation Realcom-Impute should save a file containing the imputed responses for each chosen imputation. The names of these files should correspond with the text in the fourth line of the impvals.txt file and should be in the same directory as this file. The storedata.mat file should contain the state of the software when you last used it, in theory allowing you to carry on from that point at a later date, this is not however used by external software. If the imputeiter* files are missing then it may that these was an estimation problem. The output that you posted seems to contain a lot of zeros, so it might be worth looking at the earlier output to see whether there were any further messages from when it was running the MCMC chains. It may also be worth checking the MCMC trajectories to ensure that they look okay.

### Re: Imputation files not found

Posted: **Tue Aug 23, 2016 1:56 pm**

by **amarkovitz**

Hello Chris,

Thank you for the fast reply. It does seem like there might have been estimation problems, although I did not see anything in the log to indicate this. When I click "view results" I do get error messages (attached). I did monitor one of the MCMC trajectories while it was running, but could not find anywhere in the documentation that explained what to look for in these trajectories. I've attached an example of one. Is there other documentation I could use to learn more about how to evaluate these trajectories?

I've tried many different versions of this model with different predictor variables and haven't yet been able to sucessfully run it without some type of error. Are there any tips for getting the model to fit? I'm predicting a level 2 variable (BMI at age 18) and I have values for BMI at other ages, as well as other variables that will end up in my final model. There are some missing values for BMI at other ages, although not many, so I included them as response variables.

Thank you,

Amanda

### Re: Imputation files not found

Posted: **Tue Aug 23, 2016 3:35 pm**

by **ChrisCharlton**

It looks like something definitely is going wrong there, you shouldn't get any error messages while estimating and the value of the beta you are monitoring is staying extremely close to zero. I would suggest that you initially check the files that have been output from Stata for use in Realcom-Impute to ensure that they match what you expect from your data. I would also suggest checking that the value used to correspond to "missing" within these files matches that specified within Realcom-Impute before you start the iterations. For general advice on MCMC and interpreting the chains see the first chapter of the MLwiN MCMC guide (

http://www.bris.ac.uk/cmm/media/softwar ... mc-web.pdf)

### Re: Imputation files not found

Posted: **Tue Aug 23, 2016 6:48 pm**

by **amarkovitz**

Hello Chris,

Thank you for that information, that will be very helpful. In an effort to try to figure out what might be going wrong, I tried to simplify the problem. I ran MI again with just two variables, BMI at age 18 which is missing for about 44% of people and current BMI which I made sure was not missing for anyone. I am now getting an immediate error upon running the MCMC despite confirming that the missing value was set to 9999 in the dataset and in REALCOM. I also tried it with a few other non-missing predictors in the model as well. I feel like there must be something very basic that I'm missing, any suggestions are greatly appreciated!

Here is my stata code:

sort pid

replace bmiat18=9999 if missing(bmiat18)

drop if bmi==.

realcomImpute bmiat18 bmi ///

using TestMIInput2.dat, replace numresponses(1) ///

level2id(pid) cons(cons)

### Re: Imputation files not found

Posted: **Tue Aug 23, 2016 7:49 pm**

by **ChrisCharlton**

The interface for setting the missing value can sometimes be confusing. Can you confirm that you clicked the button labelled "set missing value to:" after typing in the new value, as I think that the error message you are getting is suggesting that it isn't seeing any missing data?

### Re: Imputation files not found

Posted: **Thu Aug 25, 2016 9:34 pm**

by **amarkovitz**

Hello Chris,

Unfortunately, I did try that and received the same error. I've also tried a few different missing values (ex. STATA's default -9.999e+29, 9999, and 99999) and also have tried running the model with different response and auxiliary variables to see if was something wrong with the variables I'm using, but am having the same problem. Is there anything else you would suggest I try?

Thank you,

Amanda

### Re: Imputation files not found

Posted: **Thu Aug 25, 2016 10:28 pm**

by **ChrisCharlton**

If you have access to MLwiN you could try working through the example in the Realcom-Impute manual (

http://www.bris.ac.uk/media-library/sit ... tation.pdf) to see whether you get the same problems there. If not then if you are able to replicate the problem using a publicly available dataset then we can look into it further and see whether there is an undiscovered bug in the software.

### Re: Imputation files not found

Posted: **Wed Aug 31, 2016 1:57 pm**

by **amarkovitz**

Hello Chris,

I tried to use a publicly available dataset and I did not receive the error about missing data, but it is having the estimation problem that I initially wrote about:

. realcomImputeLoad

file impvals.txt not found

Perhaps it just isn't a very good example and if so please let me know an example that should run (I tried having less missing data and it was still a problem). Here is the STATA code I used:

/*Use a publicly available multilevel STATA dataset*/

use

http://www.stata-press.com/data/r12/productivity.dta
/*Create a level-2 (state-level) variable with missing data*/

/*Mean unemployment by state*/

by state, sort: egen meanunemp = mean(unemp)

/*Missing at random conditional on "public" variable*/

replace meanunemp=. if public>50000

/*Create dataset for REALCOM-Impute*/

gen cons = 1

sort state

cd "H:\HUNT\Datasets_intermediate" //Same folder that REALCOM-Impute starts in

realcomImpute meanunemp public gsp ///

using TestMIInput.dat, replace numresponses(1) ///

level2id(state) cons(cons)

realcomImputeLoad

Thank you,

Amanda

### Re: Imputation files not found

Posted: **Wed Aug 31, 2016 3:25 pm**

by **ChrisCharlton**

I just tried replicating your example and it seemed to work for me:

Code to set up imputation in Stata:

Code: Select all

```
. /*Use a publicly available multilevel STATA dataset*/
. use http://www.stata-press.com/data/r12/productivity.dta
(Public Capital Productivity)
.
. /*Create a level-2 (state-level) variable with missing data*/
. /*Mean unemployment by state*/
. by state, sort: egen meanunemp = mean(unemp)
.
. /*Missing at random conditional on "public" variable*/
. replace meanunemp=. if public>50000
(113 real changes made, 113 to missing)
.
. /*Create dataset for REALCOM-Impute*/
. gen cons = 1
. sort state
. cd "O:\Realcom-stata" //Same folder that REALCOM-Impute starts in
O:\Realcom-stata
. realcomImpute meanunemp public gsp ///
> using TestMIInput.dat, replace numresponses(1) ///
> level2id(state) cons(cons)
1 responses: meanunemp
2 auxiliary variables: public gsp
(note: file TestMIInput.dat not found)
Data saved to TestMIInput.dat
(note: file TestMIInput_wts.dat not found)
```

Realcom-Impute output:

Code: Select all

```
User selected O:\Realcom-stata\TestMIInput.dat
c_nimpute =
1
c_naux =
4
c_vartype =
1
ans =
2
c_betaconstraint =
0
1
fid =
3
Imputation_method =
0
Multivariate estimation using Gibbs and MH sampling - Normal/probit models
Independence assumed with standard probit model for unordered categories
Nov 14 2006
Two-level responses version
NRTYPE =
1
BETASTART =
0
0
0
BETASTART_2 =
Empty matrix: 1-by-0
SIGMASTART =
1.3530
Burn in = 100 Sample = 1000
no level 1, level 2 units = 816, 48
iteration 10
iteration 20
iteration 30
iteration 40
iteration 50
iteration 60
iteration 70
iteration 80
iteration 90
iteration 100
iteration 110
iteration 120
iteration 130
iteration 140
iteration 150
iteration 160
iteration 170
iteration 180
iteration 190
iteration 200
iteration 210
iteration 220
iteration 230
iteration 240
iteration 250
iteration 260
iteration 270
iteration 280
iteration 290
iteration 300
iteration 310
iteration 320
iteration 330
iteration 340
iteration 350
iteration 360
iteration 370
iteration 380
iteration 390
iteration 400
iteration 410
iteration 420
iteration 430
iteration 440
iteration 450
iteration 460
iteration 470
iteration 480
iteration 490
iteration 500
iteration 510
iteration 520
iteration 530
iteration 540
iteration 550
iteration 560
iteration 570
iteration 580
iteration 590
iteration 600
iteration 610
iteration 620
iteration 630
iteration 640
iteration 650
iteration 660
iteration 670
iteration 680
iteration 690
iteration 700
iteration 710
iteration 720
iteration 730
iteration 740
iteration 750
iteration 760
iteration 770
iteration 780
iteration 790
iteration 800
iteration 810
iteration 820
iteration 830
iteration 840
iteration 850
iteration 860
iteration 870
iteration 880
iteration 890
iteration 900
iteration 910
iteration 920
iteration 930
iteration 940
iteration 950
iteration 960
iteration 970
iteration 980
iteration 990
iteration 1000
iteration 1010
iteration 1020
iteration 1030
iteration 1040
iteration 1050
iteration 1060
iteration 1070
iteration 1080
iteration 1090
iteration 1100
Error using save
Unable to write file storedata: permission denied.
Error in mcmcdriver (line 1192)
Error in gui_2levmixresp>pushbutton16_RunMCMC_Callback (line 264)
Error in gui_mainfcn (line 96)
Error in gui_2levmixresp (line 46)
Error in @(hObject,eventdata)gui_2levmixresp('pushbutton16_RunMCMC_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
```

Code to load imputed data into Stata:

Code: Select all

```
. realcomImputeLoad
10 multiple imputations successfully loaded
Style: wide
last mi update 31aug2016 16:19:12, 0 seconds ago
Obs.: complete 703
incomplete 113 (M = 10 imputations)
---------------------
total 816
Vars.: imputed: 1; meanunemp(113)
passive: 0
regular: 0
system: 1; _mi_miss
(there are 12 unregistered variables)
```

Can you confirm that you are setting the output directory (via the

**Impute** button in Realcom) to be the same as Stata is using?