Solved – Partial correlation plot, split by groups SPSS

partial-correlationrscatterplotspss

Is it possible to illustrate partial correlation scatter plots for 2 subgroups on the same graph?

e.g. I want to make scatter plots of data controlled for age, differentiated by males or females.

I've tried doing partial regression plots generated by linear regression analysis, but I can't split it by groups.

Options to do it in excel or R would be fine too. Thanks!

Best Answer

Here is some code for how you could do it in R:

#Psuedo Data
group1 = rnorm(100)
group2 = rnorm(100)
response = rnorm(100)

#Plotting
plot(group1,response,xlim=c(min(group1,group2),max(group1,group2)),pch=21,bg="deepskyblue",
     ylab="Response Variable",xlab="Independent Variable")
points(group2,response,pch=21,bg="red")

#Adding a legend if desired
legend("topright",c("Group 1","Group 2"),pch=19,col=c("deepskyblue","red"),bg="white")

Which then generates the following plot: enter image description here

You could obviously add your own aesthetic touched but this should give you the general idea.

Related Question