display descriptives on graph

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

display descriptives on graph

xenia
hello all,
for a range of values, is it possible to create a graph in spss displaying the mean, median, percentile points, i.e. like a graphical display of  a  table of results using a dot for the mean, a star for the median etc?

I appreciate your help, thank you.
Reply | Threaded
Open this post in threaded view
|

Re: display descriptives on graph

Andy W

Here is a quick example - are you sure you don't just want a box plot?


******************************************************************************************.
SET seed=943997.
input program.
loop a =1 to 100 by 1.
end case.
end loop.
end file.
end input program.
dataset name sim.
compute x = NORMAL(0.25).
exe.

GGRAPH
  /GRAPHDATASET NAME="sumdata" DATASET = 'sim' VARIABLES = GPTILE(x, 80)[NAME = "Per80"]  GPTILE(x, 20)[NAME = "Per20"]  MEAN(x)[NAME = "Mean_x"]
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: sumdata=userSource(id("sumdata"))
  DATA: Per80=col(source(sumdata), name("Per80"))
  DATA: Per20=col(source(sumdata), name("Per20"))
  DATA: Mean_x=col(source(sumdata), name("Mean_x"))
  TRANS: cat = eval(1)
  GUIDE: axis(dim(1), null())
  GUIDE: axis(dim(2), label("Summary Stats"))
  SCALE: linear(dim(1), min(0), max(2))
  ELEMENT: interval(position(cat*(Per20 + Per80)), color(color.grey), size(size."3"))
  ELEMENT: point(position(cat*Per80), color(color.red), size(size."15"), label("80th Percentile"), shape(shape.star))
  ELEMENT: point(position(cat*Per20), color(color.blue), size(size."10"), label("20th Percentile"), shape(shape.star))
  ELEMENT: point(position(cat*Mean_x), color(color.black), size(size."15"), label("Mean"), shape(shape.square))
END GPL.

*Are you sure you don't just want a box plot?.
compute cat = 1.
variable level cat (nominal).
EXAMINE
  VARIABLES=x BY cat /PLOT=BOXPLOT/STATISTICS=NONE/NOTOTAL.
******************************************************************************************.

Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: display descriptives on graph

xenia
hello all,
had the chance to try Andy's example, and it helped a lot.
I do not execute a program to generate my variables, I have an active dataset, and I also want the statistics to be displayed horizontally, not vertically. So, I modified the example a bit and ended-up with the following which is what I want, and I'm pasting here for the forum.
For the scale variable "difference" and the categorical variable "samples", I get the mean, median, max, min, and percentiles 10th, 25th, 75th and 90th, displayed horizontally for each level of "samples".


GGRAPH
  /GRAPHDATASET NAME="sumdata" VARIABLES = samples GPTILE(difference, 90)[NAME =   Per90"]  GPTILE(difference, 75)[NAME = "Per75"]  GPTILE(difference, 25)[NAME = "Per25"] GPTILE(difference, 10)[NAME = "Per10"] MEAN(difference)[NAME = "Mean_difference"]  MEDIAN(difference)[NAME = "Median_difference"] MAXIMUM(difference)[NAME = "max_difference"] MINIMUM(difference)[NAME = "min_difference"]
  MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: sumdata=userSource(id("sumdata"))
  DATA: samples=col(source(sumdata), name("samples"), unit.category())
  DATA: Per90=col(source(sumdata), name("Per90"))
  DATA: Per75=col(source(sumdata), name("Per75"))
  DATA: Per25=col(source(sumdata), name("Per25"))
  DATA: Per10=col(source(sumdata), name("Per10"))
  DATA: Mean_difference=col(source(sumdata), name("Mean_difference"))
  DATA: Median_difference=col(source(sumdata), name("Median_difference"))
  DATA: max_difference=col(source(sumdata), name("max_difference"))
  DATA: min_difference=col(source(sumdata), name("min_difference"))
  GUIDE: axis(dim(1), label("difference"))
  GUIDE: axis(dim(2), label("samples"))
  SCALE: linear(dim(1), min(40), max(1594))
  ELEMENT: point(position(Per90*samples), color(color.red), size(size."15"), label("90th"), shape(shape.star))
  ELEMENT: point(position(Per75*samples), color(color.blue), size(size."12"), label("75th"), shape(shape.star))
  ELEMENT: point(position(Per25*samples), color(color.white), size(size."10"), label("25th"), shape(shape.star))
  ELEMENT: point(position(Per10*samples), color(color.yellow), size(size."7"), label("10th"), shape(shape.star))
  ELEMENT: point(position(Mean_difference*samples), color(color.black), size(size."12"), label("Mean"), shape(shape.square))
  ELEMENT: point(position(Median_difference*samples), color(color.green), size(size."12"), label("Median"), shape(shape.square))
  ELEMENT: point(position(max_difference*samples), color(color.black), size(size."12"), label("max"), shape(shape.triangle))
  ELEMENT: point(position(min_difference*samples), color(color.black), size(size."12"), label("min"), shape(shape.triangle))
END GPL.


Thank you for your help