Page 1 of 1

Specifying starting values behaves strangely

Posted: Sat Oct 03, 2015 2:28 am
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

Re: Specifying starting values behaves strangely

Posted: Mon Oct 05, 2015 9:09 am
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.

Re: Specifying starting values behaves strangely

Posted: Wed Oct 07, 2015 1:50 am
by adeldaoud
Thanks Chris. Your suggestion works.

Re: Specifying starting values behaves strangely

Posted: Mon Oct 12, 2015 11:04 pm
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 8275 times