Specifying starting values behaves strangely

Welcome to the forum for R2MLwiN users. Feel free to post your question about R2MLwiN 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 to R2MLwiN: Running MLwiN from within R >> http://www.bris.ac.uk/cmm/software/r2mlwin/
Post Reply
adeldaoud
Posts: 63
Joined: Sat Aug 15, 2015 4:00 pm

Specifying starting values behaves strangely

Post by adeldaoud »

Hi

I am trying to specify starting values as this:

a)
test.mcmc2 <- runMLwiN(logit(AbsolutDep, cons) ~ 1 + DisVic + (1 | country) + (1 |CountryClusterHouse),
D = "Binomial", estoptions = list(EstM = 0,
debugmode=T,
startval=list(FP.b = FP.b.my)),
data = dfrm)

b)
This generates the following error:

> test.mcmc2 <- runMLwiN(logit(AbsolutDep, cons) ~ 1 + DisVic + (1 | country) + (1 |CountryClusterHouse),
+ D = "Binomial", estoptions = list(EstM = 0,
+ startval=list(FP.b = FP.b.my)),
+ data = dfrm)
/nogui option ignored
ECHO 0


Echoing is ON
BATC 1

Batch mode is ON
MAXI 2
STAR
iteration 0
iteration 1

Convergence not achieved
JOIN -1.71714532375336 2.10982799530029 '_FP_b'
JOIN 0 0 0 '_FP_v'
JOIN 0 0 0 '_RP_b'
JOIN 0 0 0 0 0 0 '_RP_v'
TOLE 2
MAXI 20
NEXT

error while obeying batch file C:/Users/adel/AppData/Local/Temp/Rtmp4GO7Gq/macrofile_1d0056b63ef7.txt at line number 81:
NEXT

random part gone to zero - can not continue


WARNING: macro file has aborted, your data may be in a transformed state

WARNING: macro file has aborted, your data may be in a transformed state

error while obeying batch file C:/Users/adel/AppData/Local/Temp/Rtmp4GO7Gq/macrofile_1d0056b63ef7.txt at line number 81:
NEXT


random part gone to zero - can not continue
.
Execution completed

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


###

c)
However, if I run in debug mode and press Start and then Resume Macro. The code will work. This means that Mlwin takes the code from R2mlwin, after a number of iterations the estimate turn green, the object is exported back to R successfully.

d)
But, if I press Resume Macro first, it will fail. With the error code as captured by the screen shot.


Additional information: Running this tutorial involving starining values actually works:
file.show(system.file("demo", "MCMCGuide05.R", package = "R2MLwiN"))


I am not sure what is going on.


Thanks for your input
Adel
Attachments
startvalues correctly specified.png
startvalues correctly specified.png (62.2 KiB) Viewed 5496 times
random part gone to zero.png
random part gone to zero.png (99.3 KiB) Viewed 5496 times

ChrisCharlton
Posts: 1193
Joined: Mon Oct 19, 2009 10:34 am

Re: Specifying starting values behaves strangely

Post by ChrisCharlton »

This happens because when you specify starting values R2MLwiN uses these instead of generating them from an initial IGLS fit. Any parameters that you do not provide values for (in your case the random part parameters) will start with initial values of zero. As zero is not a sensible starting value for many parameters this can cause error like those that you have seen. To work around this you either need to specify starting values for parameters or run an initial IGLS version of the model first and pass in the outputs from this in as your starting values.

adeldaoud
Posts: 63
Joined: Sat Aug 15, 2015 4:00 pm

Re: Specifying starting values behaves strangely

Post by adeldaoud »

Thanks Chris. Your suggestion works.

adeldaoud
Posts: 63
Joined: Sat Aug 15, 2015 4:00 pm

Re: Specifying starting values behaves strangely

Post by adeldaoud »

Chris,

I am following up on this thread, but the question is merely related.

I am using starting values and passing both FP.b and RP.b to the model as you suggested. R2mlwing manages to run this model if I use a small random sample of the original data (~ 1000 cases), but not when I want to estimate the model of the full sample (~ 1.9 million cases).


I am getting this error code:

> m1test2 <- runMLwiN(logit(AbsolutDep, cons) ~ 1 + (1 | country) + (1 |CountryClusterHouse), D = "Binomial", estoptions = list(EstM = 1, resi.store=F,
+ debugmode=F, optimat=T,
+ mcmcMeth=list(iterations=10, burnin=10),
+ mcmcOptions=list(hcen=3),
+ startval=list(FP.b = PLOSONEestimations20000IGLS[[1]]@FP , RP.b = PLOSONEestimations20000IGLS[[1]]@RP)), data = test4a, workdir = tempdir(), MLwiNPath="C:/Program Files (x86)/MLwiN v2.35/")


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


Echoing is ON
STAR
iteration 0

Convergence not achieved
JOIN -0.491145551204681 '_FP_b'
JOIN 0 '_FP_v'
JOIN 1.10714721679688 1.04919278621674 1 '_RP_b'
JOIN 0 0 0 0 0 0 '_RP_v'
ECHO 0

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

error while obeying batch file C:/Users/adel/AppData/Local/Temp/Rtmp4GO7Gq/macrofile_1d002647c62.txt at line number 139:
MCMC 0 10 1 5.8 50 10 C2498] C2499] 2 2 2 1 1 2

wrong length random constraint matrix


error while obeying batch file C:/Users/adel/AppData/Local/Temp/Rtmp4GO7Gq/macrofile_1d002647c62.txt at line number 139:
MCMC 0 10 1 5.8 50 10 C2498] C2499] 2 2 2 1 1 2


wrong length random constraint matrix
.
Execution completed

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










Do you have any idea what is going on? I have tried to pass only the relevant variables, in case we are having a ram problem (my PC has 64 GB of ram), but that does not work either. I am clueless about what to try next.

I am hoping you might have any ideas about what to do next.


Many thanks in advance


PS I am not sure if it is related. But I am also observing a wobbling RAM consumption behaviour when I run this model (see picture please). I have not seen anything like it before. Can these two events be related?
process.png
process.png (40.66 KiB) Viewed 5471 times

Post Reply