1
$\begingroup$

I have 6 variables, three of which are median splits and three of which are continuous measures of 'such and such', each of which is measured on the same 5 point scale. I am trying to produce a graph that would plot the median splits of the three variables on the X axis against a mean score of the Y axis. In essence, I am trying to produce three summary graphs, instead of nine.
That is, instead of plotting each median split variable against the Y axis, I would like to plot the median splits of all three variables against the mean of the variable on the Y axis. Is there a way to do this?

$\endgroup$
3
  • $\begingroup$ Why are you doing median splits? $\endgroup$
    – Glen_b
    Jul 18 '13 at 17:26
  • $\begingroup$ Because its embedded in our hypothesis. $\endgroup$
    – jpf66
    Jul 18 '13 at 17:27
  • $\begingroup$ What's embedded in your hypothesis? $\endgroup$
    – Glen_b
    Jul 18 '13 at 18:06
2
$\begingroup$

To make the requested graph in SPSS it is easiest to reshape your data so you can make small multiples by faceting. To make the appropriate panels for multi variable comparisons you need to reshape and duplicate the data. So to start, here is some example data I presume looks like yours;

********************************************.
set seed 10.
input program.
loop #i = 1 to 100.
compute id = #i.
end case.
end loop.
end file.
end input program.
dataset name MedSplit.

*Generating fake continuous data.
vector X(3).
vector Y(3).
compute #xl = RV.NORMAL(0,1).
loop #i = 1 to 3.
    compute X(#i) = #xl + RV.NORMAL(0,1).
    compute Y(#i) = 0.5*#xl + RV.NORMAL(0,1).
end loop.

*Making the median splits for the X variables.
RANK
  VARIABLES=X1 X2 X3  (A) /NTILES (2) INTO MX1 MX2 MX3 /PRINT=NO
  /TIES=CONDENSE.
********************************************.

The Xs and the Ys are continuous, and the MXs are the median splits. To make the data in the necessary shape, we will use two successive VARSTOCASES commands.

VARSTOCASES
/MAKE X from X1 to X3
/MAKE MX from MX1 to MX3
/INDEX OrigVarX (X).
*Then do second VARSTOCASES for the full expansion.
VARSTOCASES
/MAKE Y from Y1 to Y3
/INDEX OrigVarY (Y).
formats X Y (F2.1).
value labels MX
1 'Low'
2 'High'.

If you look at the data you can now see that you have two categorical variables, OrigVarX and OrigVarY, for which we can make our panels and define our aggregate statistics with. Now the below GPL call will produce the suggested plot of means and standard errors by group for all 3 of the Y values clustered by median splits;

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=OrigVarX OrigVarY MEANSE(Y, 2)[name=
  "MEANSE_Y_2" LOW="MEANSE_Y_2_LOW" HIGH="MEANSE_Y_2_HIGH"] MX
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA: OrigVarX=col(source(s), name("OrigVarX"), unit.category())
 DATA: OrigVarY=col(source(s), name("OrigVarY"), unit.category())
 DATA: MEAN_Y=col(source(s), name("MEANSE_Y_2"))
 DATA: LOW=col(source(s), name("MEANSE_Y_2_LOW"))
 DATA: HIGH=col(source(s), name("MEANSE_Y_2_HIGH"))
 DATA: MX=col(source(s), name("MX"), unit.category())
 COORD: rect(dim(1,2), cluster(3,0))
 GUIDE: axis(dim(2), label("Mean and Standard Error"))
 GUIDE: legend(aesthetic(aesthetic.color.interior), label("Median Split"))
 GUIDE: text.footnote(label("Error Bars: +/- 2 SE"))
 GUIDE: axis(dim(4), opposite())
 ELEMENT: interval(position(region.spread.range(MX*(LOW+HIGH)*OrigVarX*OrigVarY)),shape.interior(shape.ibeam), color.interior(MX))
 ELEMENT: point(position(MX*MEAN_Y*OrigVarX*OrigVarY), color.interior(MX))
END GPL.

enter image description here

As Glen_b hinted, it is rarely a good idea to dichotomize continous variables like this. Even if the variables effects are theoretically step-like, like using median splits suggests, there seems no reason to a priori believe that step is at the sample median. We can graphically check this assumption though by plotting the continuous variables. Below I plot the 95% confidence interval (within each facet) of the linear regression of Y = intercept + beta(X), the scatterplot of each pair of points, and a loess smoother broken by the median splits (this allows you to easily tell where the median split is).

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=X Y OrigVarX OrigVarY MX
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA: X=col(source(s), name("X"))
 DATA: Y=col(source(s), name("Y"))
 DATA: OrigVarX=col(source(s), name("OrigVarX"), unit.category())
 DATA: OrigVarY=col(source(s), name("OrigVarY"), unit.category())
 DATA: MX=col(source(s), name("MX"), unit.category())
 GUIDE: axis(dim(1))
 GUIDE: axis(dim(2))
 GUIDE: axis(dim(3), opposite())
 GUIDE: axis(dim(4), opposite())
 GUIDE: legend(aesthetic(aesthetic.color.interior), null())
 GUIDE: text.footnote(label("Lines are Loess Smoothers by Median Split. Grey area in background is 95% confidence interval for linear regression of X on Y by panel."))
 ELEMENT: area.difference(position(region.confi.smooth.linear(X*Y*OrigVarY*OrigVarX)), color.interior(color.grey), transparency.interior(transparency."0.8"), transparency.exterior(transparency."0.4"))
 ELEMENT: point(position(X*Y*OrigVarY*OrigVarX), size(size."2"))
 ELEMENT: line(position(smooth.loess(X*Y*OrigVarY*OrigVarX)), color.interior(MX), size(size."4"))
END GPL.

You could add more information to the plot, (or perhaps a construct a more formal test of a linear association vs. median splits) but basically if the loess lines do not show strong evidence of discontinuity at the median split and are not flat the arbitrary dichotomy is not likely appropriate.

enter image description here

$\endgroup$
7
  • $\begingroup$ This is incredibly thorough and I appreciate how meticulous and helpful your comment was. I am wondering, though, if you could explain how to do this without syntax... $\endgroup$
    – jpf66
    Jul 18 '13 at 20:01
  • $\begingroup$ VARSTOCASES is through the Data -> Restructure menu's. After you reshape the data the first graph can be generated through the chart dialog builder, the second can not though. If the syntax is unclear just ask a question about it, it is easier to explain the syntax then the run through all the menu's needed to reproduce the results. $\endgroup$
    – Andy W
    Jul 18 '13 at 20:10
  • $\begingroup$ Basically all of the syntax is foreign to me (unfortunately), so point and click advice might be easier. When I select the varstocases command, do I choose the continuous variables to be transposed or do I transpose the variables that have already had the median split? $\endgroup$
    – jpf66
    Jul 18 '13 at 20:22
  • $\begingroup$ anyone know how to do that? $\endgroup$
    – jpf66
    Jul 18 '13 at 21:15
  • $\begingroup$ @user16204: learn syntax. I know it may take a bit of time and effort at first. But you'll soon wonder why on earth you've been wasting so much time by clumsing around with the GUI. $\endgroup$
    – RubenGeert
    Jul 19 '13 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.