Page 1 of 1
Colour coded regression plots?
Posted: Wed May 21, 2014 8:57 am
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.
Re: Colour coded regression plots?
Posted: Wed May 21, 2014 10:41 am
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.
Re: Colour coded regression plots?
Posted: Wed May 21, 2014 1:00 pm
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.
Re: Colour coded regression plots?
Posted: Wed May 21, 2014 2:10 pm
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.
Re: Colour coded regression plots?
Posted: Wed May 21, 2014 2:16 pm
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.
Re: Colour coded regression plots?
Posted: Wed May 21, 2014 3:12 pm
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).