overflow allocating smatrix

Welcome to the forum for runmlwin users. Feel free to post your question about runmlwin 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 runmlwin: Running MLwiN from within Stata >> http://www.bristol.ac.uk/cmm/software/runmlwin/
patriciotroncoso
Posts: 9
Joined: Wed Nov 21, 2012 12:24 pm

overflow allocating smatrix

Post by patriciotroncoso »

Dear all,

While trying to fit a Variance Component Model with 4 levels using runmlwin, I got the following error message:

error while obeying batch file "C: (...)" at line number 57: STAR overflow allocating smatrix

"C:(...)" is the path of the temp file originated from the do-file (I think)

Thinking it might have been a problem of worksheet size, I altered the default size using the option "mlwinsettings", but this didn't work either.

The strangest thing is that when I run the same model directly in MLwin, there is no problem.

What am I doing wrong?

Thanks in advance to anyone who could help me.
ChrisCharlton
Posts: 1353
Joined: Mon Oct 19, 2009 10:34 am

Re: overflow allocating smatrix

Post by ChrisCharlton »

This error indicates that the variable used to store the total size of the matrix (number of columns * number of rows) doesn't have enough capacity to store this size and has wrapped around. The check that triggers the error is to divide this total by the number of rows and check that the number is the same as we started with. The variable in question can hold values up to 2^32, so obviously this shouldn't happen. Would be be possible to send us an example where this occurs so that we can attempt to replicate it?
GinaPotarca
Posts: 5
Joined: Mon Nov 26, 2012 12:31 pm

Re: overflow allocating smatrix

Post by GinaPotarca »

Hello,

I have encountered a similar problem.

Here are my commands for a multivariate discrete response (empty) model:

runmlwin (exclude_European cons, eq(1)) (exclude_Hispanic cons, eq(2)) (exclude_Arabic cons, eq(3)) (exclude_African cons, eq(4)) (exclude_AsianTotal cons, eq(5)), ///
level2(region: (cons, eq(1)) (cons, eq(2)) (cons, eq(3)) (cons, eq(4)) (cons, eq(5))) ///
level1(id: (cons, eq(1)) (cons, eq(2)) (cons, eq(3)) (cons, eq(4)) (cons, eq(5))) ///
discrete(distribution(binomial binomial binomial binomial binomial) link(logit) denom(cons cons cons cons cons))

The sample size is around 60,000.

The model runs perfectly in Mlwin, but when I run it from Stata I receive the following errors:

'cannot allocate smatrix(fs)' I click OK, and then..
'error while obeying batch file C:\Users\EWP-GMW\AppData\Local\Temp\ST_00000007.tmp at line number 148: STAR
cannot allocate smatrix(fs)'

What can I do at this point? Is there a way of increasing the worksheet via runmlwin. My default worksheet size in Mlwin is around 500,000, but when using runmlwin, it seems to shrink down to 50,000. Is there a way to solve this?
Thank you very much in advance.
Gina
ChrisCharlton
Posts: 1353
Joined: Mon Oct 19, 2009 10:34 am

Re: overflow allocating smatrix

Post by ChrisCharlton »

You can override the MLwiN worksheet settings using the mlwin_settings() runmlwin options as described in the help file. By default runmlwin tells MLwiN to allocate matrices in normal memory rather than that allocated to the worksheet, so the problem is probably that the size allocated to the worksheet is too high. If you use the viewmacro option and look at the line that starts with

Code: Select all

INIT
then you can see how much space MLwiN is currently allocating to the worksheet. You can then use mlwin_settings(size(#)) where # is a lower number until you find a size that works.
ChrisCharlton
Posts: 1353
Joined: Mon Oct 19, 2009 10:34 am

Re: overflow allocating smatrix

Post by ChrisCharlton »

You can override the MLwiN worksheet settings using the mlwin_settings() runmlwin options as described in the help file. By default runmlwin tells MLwiN to allocate matrices in normal memory rather than that allocated to the worksheet, so the problem is probably that the size allocated to the worksheet is too high. If you use the viewmacro option and look at the line that starts with

Code: Select all

INIT
then you can see how much space MLwiN is currently allocating to the worksheet. You can then use mlwin_settings(size(#)) where # is a lower number until you find a size that works.
GinaPotarca
Posts: 5
Joined: Mon Nov 26, 2012 12:31 pm

Re: overflow allocating smatrix

Post by GinaPotarca »

Hi Chris,

Thank you very much for your reply, I truly appreciate it.
I added the following to my commands:

mlwinsettings(size(536000) levels(5) columns(1500) variables(300))

(which replicate my defaults Mlwin settings, the ones that work when running models directly in Mlwin)

But I still get the same type of errors.

To be noted that 536,000 is the maximum I could reach.

Gina
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: overflow allocating smatrix

Post by GeorgeLeckie »

Hi Gina,

I noticed something not quite right with your syntax. Note that this will not be the source of the error which you are running into.

Code: Select all

runmlwin (exclude_European cons, eq(1)) (exclude_Hispanic cons, eq(2)) (exclude_Arabic cons, eq(3)) (exclude_African cons, eq(4)) (exclude_AsianTotal cons, eq(5)), ///
level2(region: (cons, eq(1)) (cons, eq(2)) (cons, eq(3)) (cons, eq(4)) (cons, eq(5))) ///
level1(id: (cons, eq(1)) (cons, eq(2)) (cons, eq(3)) (cons, eq(4)) (cons, eq(5))) ///
discrete(distribution(binomial binomial binomial binomial binomial) link(logit) denom(cons cons cons cons cons))
You should not include any covariates at level 1 when the response is binary. This is because the model is specified in terms of the (logit of the) expectation of the binary response (i.e. the mean or proportion), not the observed binary response. There is therefore no level-1 error term in the model. Your code is trying to put in a level-1 error to each of your equations. It turns out that runmlwin simply ignores whatever you type in the level1(id:) option when the response is binary, so you get the same results either way, but thought I should point this out for your understanding nonetheless. So the corect syntax should be

Code: Select all

runmlwin (exclude_European cons, eq(1)) (exclude_Hispanic cons, eq(2)) (exclude_Arabic cons, eq(3)) (exclude_African cons, eq(4)) (exclude_AsianTotal cons, eq(5)), ///
level2(region: (cons, eq(1)) (cons, eq(2)) (cons, eq(3)) (cons, eq(4)) (cons, eq(5))) ///
level1(id:) ///
discrete(distribution(binomial binomial binomial binomial binomial) link(logit) denom(cons cons cons cons cons))
Best wishes

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

Re: overflow allocating smatrix

Post by ChrisCharlton »

The default for runmlwin is possibly slightly different to your default MLwiN settings in that it tells it not to use worksheet allocated space for storing matrices associated with fitting the model. To change runmlwin to use this same option you need to change your mlwinsettings to:

Code: Select all

mlwinsettings(size(536000) levels(5) columns(1500) variables(300) tempmat)
GinaPotarca
Posts: 5
Joined: Mon Nov 26, 2012 12:31 pm

Re: overflow allocating smatrix

Post by GinaPotarca »

Hi Chris,

Thanks once again, I tried to make the change you proposed, but unfortunately the same errors occur.

George, thank you so much for your comment, it definitely improved my understanding.

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

Re: overflow allocating smatrix

Post by ChrisCharlton »

Could you check that the error message you are getting it identical, as this would indicate that the settings are being ignored? Can you check that you are using the most recent versions of MLwiN and runmlwin in case you are coming across something that has already been fixed? If you still get the problem would it be possible to email us some example data that causes the problem so that we can attempt to replicate the error?
Post Reply