Binary covariate and run time errors using the nlevel imputation template

Welcome to the forum for Stat-JR users. Feel free to post your question about Stat-JR 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!

We will add further support to the Stat-JR website, such as FAQs and tutorials, as soon as it is available; the Stat-JR website can be found here: http://www.bristol.ac.uk/cmm/software/statjr/
madk1712
Posts: 8
Joined: Wed Sep 05, 2018 1:30 pm

Re: Binary covariate and run time errors using the nlevel imputation template

Post by madk1712 » Wed Sep 12, 2018 2:03 pm

Hi Chris,

I've copied and pasted several chunks of code below where I can see errors. The two school-level variables I'm attempting to include are school average KS1 and KS2 scores (for 150 schools) which are normally distributed, albeit left-skewed. There are approximately 4 schools with missing KS1 and KS2 averages. Hopefully the code will be meaningful, but I can provide more if that would be helpful. I also downloaded the imputed datasets from these runs (with the school-level variables included), and the results are implausible for the level 1 variables with missing data.

Code: Select all

INFO:root:Compiling Model...
INFO:root:Running ..\..\..\eStat\bin\Release\eStat.exe
Index not valid integer Input string was not in a correct format.
Index not valid integer Input string was not in a correct format.
Index not valid integer Input string was not in a correct format.
Deterministic child has parent which is neither stochastic nor deterministic nor matrix element.
Deterministic child has parent which is neither stochastic nor deterministic nor matrix element.
Deterministic child has parent which is neither stochastic nor deterministic nor matrix element.
Deterministic child has parent which is neither stochastic nor deterministic nor matrix element.
Deterministic child has parent which is neither stochastic nor deterministic nor matrix element.

ERROR:root:sigma2_u2:
ERROR:root:0.0103558776067
ERROR:root:tau:
ERROR:root:nan
ERROR:root:sigma2_u1:
ERROR:root:0.0115536092272
ERROR:root:sigma2_u3:
ERROR:root:0.0281587281314
ERROR:root:deviance:
ERROR:root:nan
ERROR:root:u1:
ERROR:root:[ nan  nan  nan  nan  nan  nan  nan  nan  nan

ERROR:root:sigma2:
ERROR:root:nan
ERROR:root:tau has a non finite value, aborting
{'estoptions': {'Engine': 'eStat', 'nchains': '1', 'thinning': '1', 'burnin': '5000', 'defaultalg': 'Yes', 'iterations': '10000', 'outdata': 'imp4', 'makepred': 'No', 'seed': '4', 'defaultsv': 'Yes'}, 'invars': {'D': 'Normal', 'storeresid': 'No', 'C3': 'group', 'C2': 'school', 'y': 'post', 'x': 'cons,treatment,pre,ks1,schoolks2', 'C1': 'ta', 'NumLevs': '3'}, 'template': 'NLevelMod', 'dataset': 'CompleteData'}
Done

Exception in thread Thread-8:
Traceback (most recent call last):
  File "c:\Python27\lib\threading.py", line 801, in __bootstrap_inner
  File "c:\Python27\lib\threading.py", line 754, in run
  File "O:\repo\stat-jr\src\lib\EStat\engines\Python.py", line 13, in execpy
  File "<string>", line 400, in <module>
  File "O:\repo\stat-jr\src\lib\EStat\engines\Engine.py", line 21, in __getitem__
KeyError: 'Chains'

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

Re: Binary covariate and run time errors using the nlevel imputation template

Post by ChrisCharlton » Wed Sep 12, 2018 2:12 pm

Thanks for this. It looks like there is a numeric error when running the model of interest on the complete dataset (i.e. with rows containing missing values removed). Could you check whether you get the same behaviour when running the model directly? i.e. by creating a version of the dataset when the rows with missing are moved and then running the model either via the "NLevelMod" template, or via MLwiN.

madk1712
Posts: 8
Joined: Wed Sep 05, 2018 1:30 pm

Re: Binary covariate and run time errors using the nlevel imputation template

Post by madk1712 » Wed Sep 12, 2018 3:49 pm

I've managed to successfully fit the MOI (with missing values removed) using the StatJR 'nlevelmod' template and both the eStat and JAGS estimation engines. I was getting poor mixing with the eStat engine on some of the variance parameters (ESS on some of these were in the hundreds rather than the tens of thousands), which wasn't repeated in JAGS, but this may be down to the default priors used.

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

Re: Binary covariate and run time errors using the nlevel imputation template

Post by ChrisCharlton » Wed Sep 12, 2018 4:01 pm

Thanks for checking that. In that case it's possible that there is a problem with the template used to generate the complete cases version of the data (CompleteCases). Could you try running this with the variables in your model of interest and confirm that the dataset it generates matches that one that you created?

madk1712
Posts: 8
Joined: Wed Sep 05, 2018 1:30 pm

Re: Binary covariate and run time errors using the nlevel imputation template

Post by madk1712 » Thu Sep 13, 2018 8:15 am

I've checked the StatJR complete case template against the R procedure and they produce identical datasets.

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

Re: Binary covariate and run time errors using the nlevel imputation template

Post by ChrisCharlton » Thu Sep 13, 2018 1:11 pm

I'm not really sure where the difference is coming from then. Could you try running the model that worked for you using 2LevelImpute with the NLevelImpute template to confirm that this works and you get the same results as before? If it does it would be useful to know if any intermediate models (i.e. fewer classifications or co-variates) work.

Post Reply