Page 1 of 1

R2MLwiN is showing "Error in read.dta(chainfile[i]): unable to open file: 'No such file or directory'"

Posted: Fri Feb 22, 2019 8:17 pm
by dcanarteg
Hello
After successfully running 4 models before the one below. I am having the following error

"Error in read.dta(chainfile) :
unable to open file: 'No such file or directory'"

What does it mean " error while obeying batch file..... at line number 197"?

The formula below is for a Hierarchical Logistic Regression.

Thanks

Below is the output copied and pasted from my console.
##############################################################################
> m5 = logit(AltAnySupport) ~ 1 + TieIsFamily + TieSameSex + TieSameAge + EgoMarital + EgoSex +
EgoTMig + AltSex + AltIsRoma + AltNatRomanian + AltResidence + NetPropFemCen + NetPropFamCen +
NetPropIsRomaCen + NetPropNatRomanianCen + NetPropResidCen + EgoTMig:AltIsRoma +
EgoSex:AltIsRoma + EgoTMig:TieSameSex + (1 | EgoIdentifier)
> (VarCompModel5 <- runMLwiN(Formula = m5, D = "Binomial", data = RomaAllData2,
estoptions = list(EstM = 1)))

MLwiN is running, please wait......
/nogui option ignored
ECHO 0

Echoing is ON
BATC 1

Batch mode is ON
MAXI 2
STAR
iteration 0
iteration 1

Convergence not achieved
TOLE 2
MAXI 20
BATC 1

Batch mode is ON
NEXT
iteration 2
iteration 3
iteration 4
iteration 5
iteration 6

Convergence achieved
ECHO 0

Echoing is ON
MCMC 0 500 1 5.8 50 10 G30[1] G30[2] 2 2 2 1 1 2

error while obeying batch file /var/folders/3n/zvw9lr5s1c1dnl0jkrc8y2xh0000gn/T//Rtmp8C7bVa/macrofile_149428d0dce5.txt at line number 197:
MCMC 0 500 1 5.8 50 10 C2498] C2499] 2 2 2 1 1 2
MCMC Error 0002 : Matrix must be positive definite for inversion

error while obeying batch file /var/folders/3n/zvw9lr5s1c1dnl0jkrc8y2xh0000gn/T//Rtmp8C7bVa/macrofile_149428d0dce5.txt at line number 197:
MCMC 0 500 1 5.8 50 10 C2498] C2499] 2 2 2 1 1 2
Unable to invert xtx
dealloc_all

error while obeying batch file /var/folders/3n/zvw9lr5s1c1dnl0jkrc8y2xh0000gn/T//Rtmp8C7bVa/macrofile_149428d0dce5.txt at line number 197:
MCMC 0 500 1 5.8 50 10 C2498] C2499] 2 2 2 1 1 2

Unable to invert xtx.
Execution completed

Error in read.dta(chainfile) :
unable to open file: 'No such file or directory'

##############################################################################

Re: R2MLwiN is showing "Error in read.dta(chainfile[i]): unable to open file: 'No such file or directory'"

Posted: Tue Feb 26, 2019 10:29 am
by ChrisCharlton
The error message indicates an estimation problem, possibly due to the data or starting values. I would suggest trying to fit the same model using IGLS (i.e. by removing EstM=1) and seeing whether you get any estimates of zero, or other estimation problems there. If so it might suggest a problem such as high correlations between some of your variables. You might be able to persuade MCMC to run if you specify manual starting values (see chapter 5 of the MCMC guide at http://www.bristol.ac.uk/cmm/software/r2mlwin/examples/), however I would suggest looking closely at the parameter chains to check that they are behaving correctly. Another thing to try would be simplified versions of the model to see which variables cause the problem when added.

Re: R2MLwiN is showing "Error in read.dta(chainfile[i]): unable to open file: 'No such file or directory'"

Posted: Tue Feb 26, 2019 12:49 pm
by dcanarteg
Thank you! I'll try that

Re: R2MLwiN is showing "Error in read.dta(chainfile[i]): unable to open file: 'No such file or directory'"

Posted: Tue Jul 07, 2020 4:44 am
by jhog2395
Hi guys,

I am finding the same error when using R2MLwiN. I am trying to run a random slopes model where a categorical variable, SA2irsd, is allowed to vary per region (the variable SLA). I have 491 regions and around 3,200 observations with a median of 6 observations per region. SA2irsd has 3 categories. When I estimate using EstM=0, as Chris suggested, all the variances and covariance terms are zero so I am wondering whether this error is not a coding problem but a model problem. My supervisor says I can use a level-2 variable as a random term, but I was sure this could not be estimated.

My code is below.

#Define New Starting Values
fixed<-c(rep(0,17))
st_val<-list(list(FP.b = fixed, RP.b = c(rep(10,6), 1)),
list(FP.b = fixed, RP.b = c(rep(50,6), 1)),
list(FP.b = fixed, RP.b = c(rep(100,6), 1)))
#Mixed Model
F8=logit(bin_stage)~1+employment + priv_insur + age + household_comp +
menopause + hrt + age_menarche+SA2irsd_grp+(1+SA2irsd_grp|SLA)
both_8<-runMLwiN(Formula=F8, data=FULL, D = "Binomial", estoptions = list(EstM=1, sort.force=T,
startval=st_val, mcmcMeth = list(nchains=3))

Thankyou in advance for any help here

Jamie

Re: R2MLwiN is showing "Error in read.dta(chainfile[i]): unable to open file: 'No such file or directory'"

Posted: Thu Jul 09, 2020 3:45 pm
by richardparker
Hi - the default for MLwiN (when using (R)IGLS) is to reset negative variance estimates, and any associated covariances, to zero, so it is possible that you are getting negative variance estimates during estimation for some reason, and they are being reset in this manner.

If you wished to explore that possibility further, then you can allow negative variances via reset in the list of estoptions in the call to runMLwiN(). ?runMLwiN provides further guidance, but for a 2-level model this is specified as reset = c(<level_1>, <level_2>), with options: 0 == a negative variance estimate is reset to zero and so are any associated covariances; 1 == a negative variance estimate is reset to zero but not the associated covariances; 2 == no resetting takes place. So, specifying reset = c(2, 2) for a 2-level model would request that variances and covariances are not reset to zero in the case of negative variance estimates during model estimation for either level.

In addition it can also sometimes be helpful to open the MLwiN GUI and explore the model in that environment, particularly if you are unsure as to where issues may lie. If you are interested in doing this, you can do so by specifying debugmode = TRUE in the list of estoptions (as documented in ?runMLwiN).

Re: R2MLwiN is showing "Error in read.dta(chainfile[i]): unable to open file: 'No such file or directory'"

Posted: Fri Jul 31, 2020 4:58 am
by jhog2395
Thankyou richardparker for your response here. Unfortunately I need to use MCMC estimation for my model, but I can see the usefulness of this setting.