realcomImpute error

Welcome to the forum for REALCOM users. Feel free to post your question about REALCOM here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Go REALCOM (Developing multilevel models for REAListically COMplex social science data) >> http://www.bristol.ac.uk/cmm/software/realcom/
Post Reply
Jamoo
Posts: 36
Joined: Wed Oct 05, 2011 2:33 pm

realcomImpute error

Post by Jamoo »

Hi

Any ideas why I might be getting the 'in range not allowed' error when I use the realcomImpute command to export data from Stata to Realcom?

. realcomImpute deltabmi o.nq4sessions m.ethnic m.tenure m.singlepar m.empstat bmi1c idaci07 age1 sex nprogperpm nperprog towns villages built nq4sessions htroundbin wtroundbin using "Analysis\Change in BMI\dbmirealcom7.dat" ,numresponses(6) cons(cons) level2id(numprogid) replace

6 responses: deltabmi o.nq4sessions m.ethnic m.tenure m.singlepar m.empstat
12 auxiliary variables: bmi1c idaci07 age1 sex nprogperpm nperprog towns villages built nq4sessions htroundbin wtroundbin

in range not allowed
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: realcomImpute error

Post by ChrisCharlton »

From the output that you have provided it looks like it's having a problem in the following section of code:

Code: Select all

*save file ready for REALCOM to load
local stoppos = strpos("`using'",".")
if `stoppos'==0 {
	local savename `using'.txt
}
else {
	local savename `using'
}
file open myFile using `savename', write `replace'
file write myFile "`numresponses'" _n
local numauxvarstotal = `numauxvars'+2
file write myFile "`numauxvarstotal'" _n

file write myFile "`type1'"
forvalues i=2(1)`numresponses' {
	file write myFile _tab
	file write myFile "`type`i''"
}
file write myFile _n

*write variable names
local myvarlist `respvars_withoutprefix' `level2id' `cons' `auxvars'
tokenize `myvarlist'
local myvarlistlength = `numresponses' + 2 + `numauxvars'
file write myFile "`1'"
forvalues i=2(1)`myvarlistlength' {
	file write myFile _tab
	file write myFile "``i''"
}
file write myFile _n

*now write data
forvalues i=1(1)`numobs' {
	if `1'[`i']==. {
		file write myFile (-9.999e+029)
	}
	else {
		file write myFile (`1'[`i'])
	}
	forvalues j=2(1)`myvarlistlength' {
		if ``j''[`i']==. {
			file write myFile _tab (-9.999e+029)
		}
		else {
			file write myFile _tab (``j''[`i'])
		}
	}
	file write myFile _n
}

file close myFile
As these lines mostly appear to be related to writing to a file I would imagine that the most likely line to be the cause would be

Code: Select all

file open myFile using `savename', write `replace'
You can confirm this by running the command

Code: Select all

set trace on
prior to running the realcomImpute command. If this line is where the problem is occuring then there is probably a problem with the file name that you are specifying for saving the data. The first things I would try would be to specify either the full path, or with no path to see whether you still get the error.
Jamoo
Posts: 36
Joined: Wed Oct 05, 2011 2:33 pm

Re: realcomImpute error

Post by Jamoo »

Dear Chris,

Thanks for the advice. I removed part of the file path and it worked - it was a very slight typo which I hadn't picked up by eyeballing the file path originally.

Good idea on the 'set trace on'. That might be a useful general note for people sending in error messages from Stata for the runmlwin forum too.

Best wishes

Jamie
Post Reply