random slope grphs

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/
sunilsahadev
Posts: 5
Joined: Thu Feb 09, 2017 7:23 pm

random slope grphs

Post by sunilsahadev »

As I am plotting group lines from a randomised slope analysis, I get some really unusual lines and/or patterns. I have 21 categories in level-2 and altogether my sample is 1100 cases. In the first instance I get a few lines and a few awkward patterns and then when I clear the autosort on x box, I get all lines but there are now more than 21 lines -- about 30 odd lines. Is random slope coefficient is significant and I followed all the steps in the manual. Please help
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: random slope grphs

Post by ChrisCharlton »

Would it be possible for you to provide more information regarding the model that you have fit, along with the steps that you have taken to plot the graph? Can I also suggest that you work through the example at the end of chapter 4 of the MLwiN user guide (http://www.bristol.ac.uk/cmm/media/soft ... al-web.pdf) using the example data to ensure that you are able to replicate the graph in the manual?
sunilsahadev
Posts: 5
Joined: Thu Feb 09, 2017 7:23 pm

Re: random slope grphs

Post by sunilsahadev »

There is one level in my model (apart from the individual level)-- internet bank used being the second level. There are 21 iternet banks and altogether 1100 sample respondents across the 21 banks. I have several independent variables and the depednet variable is loyalty. All the variables are intervally scaled. I get significant coefficients for the indepenet variables when I run the random slopes. But when I try to plot the group lines. Initially for some of the banks it doesn't produce a line but some really awkward shapes. While it is a clear line for some others. I can post a screen shot if that is allowed in the forum. But when I try to plot after I unclick the 'autosort on x' box, I get several lines -- more than 21 (a profusion of lines). Thanks for attaching the manual. I have gone through the instructions given in tutorial guide .
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: random slope grphs

Post by ChrisCharlton »

The example in the manual relates to one response variable (normexam) and one predictor variable (standlrt). What is the graphed is the prediction for normexam against standlrt grouped by the level-2 variable (school). As you have more than one predictor variable included in your prediction then you will need to represent this in the graph too otherwise you will most likely have more than one value per point on the x-axis, resulting in odd looking lines such as you were getting. If you only have a couple of categorical predictors this can be achieved by using them in the "row codes" and "col codes" sections of the customised graph window, giving you a graph containing a set of slopes for each value of the predictor.
sunilsahadev
Posts: 5
Joined: Thu Feb 09, 2017 7:23 pm

Re: random slope grphs

Post by sunilsahadev »

Thanks for the prompt response. Sorry I am trying to meet a journal special issue deadline. Do you mean in the prediction stage to calculate the predicted value, you include all the indepenent variables (at once) instead of just the one indepent variable whose random slope you are planning to plot. I had also tried out removing all the indepent variables and just using the one that is under focused but the same result. I also have one query about plotting interacting effects. But that is for the next post.
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: random slope grphs

Post by ChrisCharlton »

Sorry, I wasn't clear on what you were currently predicting. If you have just one variable (plus the intercept) in your prediction then you should get the slopes that you wanted, so I am not sure what is going on there. You should generally keep the "autosort on x" box selected. I would suggest looking at the model->hierarchy window to ensure that the number of level-2 units there matches what you expect. The forum does allow posting screenshots if it helps you explain the problem further.
sunilsahadev
Posts: 5
Joined: Thu Feb 09, 2017 7:23 pm

Re: random slope grphs

Post by sunilsahadev »

To give you a comprehensive idea: I have two levels. Level.1 --individual internet banking account holders (1014 sample elements). Level.2 Banks -- 21 banks. I have about five predictor variables -- all intervally scaled. To make it simple, I just used one of the predictors this time and please see the unusual graph attached. This is after I developed the randomised slope on 'usefulness' one of the predictors as you can see. I checked the model-hierarchy. There I again found something unsual. In level.2 there were 21 units -- but the hierarchy shows 290 total units! Though the total number of units for level1 is shown as correct 1014.
Attachments
screenshot.docx
screenshot of the plot. The special graph screen and the prediction screen
(177.78 KiB) Downloaded 268 times
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: random slope grphs

Post by ChrisCharlton »

MLwiN identifiers the units by changes in the ID value rather than the ID value itself. This means that the following will be identified as having 4 higher level units:

Code: Select all

level-2 id
1
1
2
2
1
1
2
2
whereas the following will be identified as having 2 higher level units:

Code: Select all

level-2 id
 1
 1
 1
 1
 2
 2
 2
 2
It is therefore important to ensure that the data is sorted so that the hierarchy is recognised correctly.

I suspect that in your case predictions are being created on the basis that there are 290 level-2 units, but then when you are graphing them it is using the actual level IDs as the filter, merging them together to produce what you are seeing.
sunilsahadev
Posts: 5
Joined: Thu Feb 09, 2017 7:23 pm

Re: random slope grphs

Post by sunilsahadev »

Thanks a million. This is a huge relief. In the end it was such a simple thing. Once I sorted the level-2 variable the problem has been solved. One more query. I am plotting interaction effects. So what should be te x-axis variable when I am using the prediction function
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: random slope grphs

Post by ChrisCharlton »

I think that this will probably depend on the variables involved in the interaction. For an example of plotting predictions for interactions see model 3 in http://www.ats.ucla.edu/stat/mlwin/semi ... eminar.htm.
Post Reply