Colour coded regression plots?

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
mledger3
Posts: 5
Joined: Tue May 20, 2014 8:57 pm

Colour coded regression plots?

Post by mledger3 »

Hi,

I have been asked to produce colour coded regression plots so that each country can be distinguished from another. I have 7 countries and they are my highest sorted level, although in my model they are included as a fixed effect. I have two levels, individuals within primary sampling units.

Has anyone ever come across a way to colour code regression plots? I cannot find anything on the web, I haven't even been able to find anything with colour coded plots let alone how to make them.

I hope someone can help me. If you need any more info feel free to ask. Thanks.
ChrisCharlton
Posts: 1384
Joined: Mon Oct 19, 2009 10:34 am

Re: Colour coded regression plots?

Post by ChrisCharlton »

You haven't specified exactly what sort of graph you are plotting, however you should be able to do this in the following way:
  • Generate an indicator variable for each row of the graph data indicating which country it corresponds to (you may already have this).

    In the customised graphs menu:
  • Under plot what? select this variable as group.
  • Under plot style change the colour to rotate (the option lowest down).
  • If you want a legend, under other tick group code (you can choose where to place this by clicking the Labels button).
  • Click Apply.
If you want more control over the colouring of individual countries you can either redefine the colours use through the Graphs->Set Graph Colours menu, or manually separate the different countries in your data and plot each one manually.
mledger3
Posts: 5
Joined: Tue May 20, 2014 8:57 pm

Re: Colour coded regression plots?

Post by mledger3 »

Oh yes, I am so sorry I am trying to plot the residuals. I don't know why I wrote regression. Is it possible to do this with residuals. The way I know to plot residuals is on the special residual tab.

I tried doing it using the advice above and it says that my column lengths are not the same and produced a blank graph. Could there be something wrong with my residual selection? I have already sorted the data but it asking me to do it again.

Then a second error message comes up saying that group column wrong length dataset number 1 but I don'd really understand this.

Thank you so much.
ChrisCharlton
Posts: 1384
Joined: Mon Oct 19, 2009 10:34 am

Re: Colour coded regression plots?

Post by ChrisCharlton »

The residuals columns will be shorter than your original data (with one row per unit) so you will need to create a shorter indicator column before performing the same steps as I indicated previously. Alternatively, as you only have seven countries, you could create the residuals plots as you would normally and then click on points on the graph to identify and highlight each school using the Graph options menu that pops up. If you use the second method you will not be able to automatically create a legend for the different schools.
mledger3
Posts: 5
Joined: Tue May 20, 2014 8:57 pm

Re: Colour coded regression plots?

Post by mledger3 »

Thank you, there are only seven countries but I have nearly 3000 primary sampling units. So I will try and create a smaller country variable and see what happens.

I realised this wont work as my country variable is already 1 - 7.

I am so sorry, I don't really understand column length, as you can imagine. Do you mean that I should create a variable which indicates if the residual is part of a certain country? As I have only 3307 residuals (one for each PSU) but 32265 codes for the country (one for each individual).


Thank you again.
ChrisCharlton
Posts: 1384
Joined: Mon Oct 19, 2009 10:34 am

Re: Colour coded regression plots?

Post by ChrisCharlton »

Yes, I am suggesting creating a variable that is the same length as the residuals, where each row indicates which country that residual corresponds to. You might be able to do this automatically using the Data Manipulation->Unreplicate window (i.e. replicate country on blocks defined by PSU).
Post Reply