predint.txt problems

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

Remember to check out our extensive software FAQs which may answer your question: http://www.bristol.ac.uk/cmm/software/s ... port-faqs/
Post Reply
sianphillips
Posts: 7
Joined: Thu Aug 04, 2011 10:33 am

predint.txt problems

Post by sianphillips »

Hi,

I am running a cross classified 4 level model with a binary outcome using MCMC. I want to plot the regression lines it produces, plus the 95% confidence interval of that line. It has a random intercept at every level but no random slope. I am following the instructions in chapter 6 of the MCMC manual. I ran the MCMC model with 5001 iterations, storing the level 2 residuals only in column c200. Then i ran the macro predint.txt. I get the following error message:

error while obeying batch file ...at line number 16, calc c350 = c81+cb11 + b3 * (c82+cb12)
arithmetic expression too complicated

I think it is the cb11/cb12 reference - what does this refer to? I tried changing it to b11/b12 and its runs OK, but i get a very odd output graph. I would really appreciate some advice, I have copied the whole macro below for reference

Many thanks in advance,
Sian

Note macro creates prediction curves with error bands for a random slopes regression model
erase c21-c23
note put residuals into c201-c265 (intercepts) and c301-c365 (slopes)
code 130 1 5001 c199
split c200 c199 c201-c330
code 6 1 5001 c89
note put fixed intercept and slope in columns c81 and c82
split c1090 c89 c81-c86
note loop around all individuals
loop b1 1 45391
pick b1 '1_4R1ID' b2
pick b1 '1_41hrexclfirstR1' b3
calc b11 = 2*b2 + 199
calc b12 = 2*b2 + 200
note calculate the derived predicted values for individual b1 and put in c300
calc c350 = c81+cb11 + b3 * (c82+cb12)
sort c350 c350
note pick out quantiles and median for individual b1
pick 125 c350 b21
pick 2500 c350 b22
pick 4875 c350 b23
join c21 b21 c21
join c22 b22 c22
join c23 b23 c23
endl
Note transform quantiles into differences
calc c21 = c22 - c21
calc c23 = c23 - c22
name c22 'pred'
name c21 'lowlim'
name c23 'uplim'

(note 45391 is the number of people i have at level 1, '1_4R1ID' is the level 2 category, and '1_41hrexclfirstR1' is the main predictor of interest in my model.)
billb
Posts: 157
Joined: Fri May 21, 2010 1:21 pm

Re: predint.txt problems

Post by billb »

Hi Sian,
My predint.txt macro is going to be tricky to replicate for bigger datasets - basically the following is done:
1) The residual chains have been stored stacked up in c200 - there are 130 of them as there are 65 schools (intercepts and slopes)
2) The school ids go from 1 to 65 which is important to make the command work - if your ids aren't starting from 1 and going up 1 at a time the macro will not work
3) The split command takes the residual chains and unstacks them into c201-c330 now if you had loads more higher level units this would get tricky as you might run out of columns
4) In line with 2 above the pick command picks the correct school and puts it in b2 then the b11 and b12 lines will point to where the intercept and slope residual chains are stored e.g. for school 1 b11 = 201 and b12 = 202
5) Your initial question was what is cb11 and cb12 and essentially just substitutions so for school 1 cb11 is c201 and cb12 is c202. The error is likely to be for example if we had school 6000 then c6000 might not be defined! in fact your code is assuming only 65 schools below.

I hope this is helpful,
Regards,

Bill.
Post Reply