Re: GGRAPH multiple variable stacked bar

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

Re: GGRAPH multiple variable stacked bar

Dennis Deck
In the event that anyone else is struggling with GPL, I'm posting the
"paper trail" of assistance ViAnn provided offline as I tried to create
a stacked bar graph with multiple variables using GGRAPH.

I have a series of 8 scales with ordinal scores (values range from 0 to
3 representing recognition levels).  I would like to display a summary
profile consisting of stacked bars showing the number of cases (schools)
at each recognition level.  It is easy enough to use Chart Builder to
create stacked bars but this example requires some GPL work.

Dennis Deck, PhD
RMC Research Corporation
[hidden email]

-----Original Message-----
From: Beadle, ViAnn [mailto:[hidden email]]
Sent: Wednesday, February 21, 2007 10:40 AM
To: Dennis Deck
Subject: RE: GRAPH stacked bar syntax limitations

Login as guest with password guest.

The include function makes sure something is allocated even though it
might not exist in data. Use the exclude function.

Is level4 your paneling variable? If so you need to include it in the
algebra for each element (e.g.: summary.count("rPhysAct"*1*level4) )

-----Original Message-----
From: Dennis Deck [mailto:[hidden email]]
Sent: Wednesday, February 21, 2007 12:28 PM
To: Beadle, ViAnn
Subject: RE: GRAPH stacked bar syntax limitations

Well I had rolled up my sleeves, though without much success, but with
your example got it working first try (first example below).  Thanks!!

That was exactly what I needed.   I never would have guessed the
position(summary.count("xxx"*1)) syntax.  There is obviously much more
to GPL than is in the Syntax Reference Guide.  I found a link to a GPL
guide on the SPSS website but the link was now password protected
(support only). Is additional documentation available?

Unfortunately my attempts to extend the working code were less
successful:

 1) added a line I thought would suppress category "0" (no level) but
the line was ignored:
    SCALE: cat(aesthetic(aesthetic.color.interior), include("1", "2",
"3"))

 2) added lines to break out a Panel dimension but these were also
ignored (see second example).  I based the additions on working syntax
generated by Chart Builder for a simpler chart (1 stacked variable by 2
categorical variables).

Thanks again.

* Base stacked bar profile - WORKING!! .
GGRAPH
  /GRAPHDATASET NAME="graphdataset"
                VARIABLES=rPolicy rMeals rFoods rHlthEd rPhysEd
                          rPhysAct rAftrSch rStaff rTotal
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA:  rPolicy = col(source(s), name("rPolicy"), unit.category())
 DATA:  rMeals  = col(source(s), name("rMeals"),  unit.category())
 DATA:  rFoods  = col(source(s), name("rFoods"),  unit.category())
 DATA:  rHlthEd = col(source(s), name("rHlthEd"), unit.category())
 DATA:  rPhysEd = col(source(s), name("rPhysEd"), unit.category())
 DATA:  rPhysAct= col(source(s), name("rPhysAct"),unit.category())
 DATA:  rAftrSch= col(source(s), name("rAftrSch"),unit.category())
 DATA:  rStaff  = col(source(s), name("rStaff"),  unit.category())
 DATA:  rTotal  = col(source(s), name("rTotal"),  unit.category())
 GUIDE: axis(dim(2), label("Count of Schools"))
 GUIDE: legend(aesthetic(aesthetic.color.interior), label("Levels"))
 SCALE: linear(dim(2), include(0))
 ELEMENT: interval.stack(position(summary.count("rPolicy"*1)),
color.interior(rPolicy), shape.interior(shape.square))
 ELEMENT: interval.stack(position(summary.count("rMeals"*1)),
color.interior(rMeals),  shape.interior(shape.square))
 ELEMENT: interval.stack(position(summary.count("rFoods"*1)),
color.interior(rFoods),  shape.interior(shape.square))
 ELEMENT: interval.stack(position(summary.count("rHlthEd"*1)),
color.interior(rHlthEd), shape.interior(shape.square))
 ELEMENT: interval.stack(position(summary.count("rPhysEd"*1)),
color.interior(rPhysEd), shape.interior(shape.square))
 ELEMENT:
interval.stack(position(summary.count("rPhysAct"*1)),color.interior(rPhy
sAct),shape.interior(shape.square))
 ELEMENT:
interval.stack(position(summary.count("rAftrSch"*1)),color.interior(rAft
rSch),shape.interior(shape.square))
 ELEMENT: interval.stack(position(summary.count("rStaff"*1)),
color.interior(rStaff),  shape.interior(shape.square))
 ELEMENT: interval.stack(position(summary.count("rTotal"*1)),
color.interior(rTotal),  shape.interior(shape.square))
END GPL .

* Add Panel - NOT WORKING - PANEL CODE IGNORED .
GGRAPH
  /GRAPHDATASET NAME="graphdataset"
                VARIABLES=rPolicy rMeals rFoods rHlthEd rPhysEd
                          rPhysAct rAftrSch rStaff rTotal Level4
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA:  rPolicy = col(source(s), name("rPolicy"), unit.category())
 DATA:  rMeals  = col(source(s), name("rMeals"),  unit.category())
 DATA:  rFoods  = col(source(s), name("rFoods"),  unit.category())
 DATA:  rHlthEd = col(source(s), name("rHlthEd"), unit.category())
 DATA:  rPhysEd = col(source(s), name("rPhysEd"), unit.category())
 DATA:  rPhysAct= col(source(s), name("rPhysAct"),unit.category())
 DATA:  rAftrSch= col(source(s), name("rAftrSch"),unit.category())
 DATA:  rStaff  = col(source(s), name("rStaff"),  unit.category())
 DATA:  rTotal  = col(source(s), name("rTotal"),  unit.category())
 DATA:  Level4  = col(source(s), name("Level4"),  unit.category())
 GUIDE: axis(dim(2), label("Count of Schools"))
 GUIDE: legend(aesthetic(aesthetic.color.interior), label("Levels"))
 GUIDE: axis(dim(4), label("Grade Level"), opposite())
 GUIDE: legend(aesthetic(aesthetic.color.interior), label("Recognition
Level"))
 SCALE: linear(dim(2), include(0))
 SCALE: cat(dim(4), include("1", "2", "3", "4"))
 ELEMENT: interval.stack(position(summary.count("rPolicy"*1)),
color.interior(rPolicy), shape.interior(shape.square))
 ELEMENT: interval.stack(position(summary.count("rMeals"*1)),
color.interior(rMeals),  shape.interior(shape.square))
 ELEMENT: interval.stack(position(summary.count("rFoods"*1)),
color.interior(rFoods),  shape.interior(shape.square))
 ELEMENT: interval.stack(position(summary.count("rHlthEd"*1)),
color.interior(rHlthEd), shape.interior(shape.square))
 ELEMENT: interval.stack(position(summary.count("rPhysEd"*1)),
color.interior(rPhysEd), shape.interior(shape.square))
 ELEMENT:
interval.stack(position(summary.count("rPhysAct"*1)),color.interior(rPhy
sAct),shape.interior(shape.square))
 ELEMENT:
interval.stack(position(summary.count("rAftrSch"*1)),color.interior(rAft
rSch),shape.interior(shape.square))
 ELEMENT: interval.stack(position(summary.count("rStaff"*1)),
color.interior(rStaff),  shape.interior(shape.square))
 ELEMENT: interval.stack(position(summary.count("rTotal"*1)),
color.interior(rTotal),  shape.interior(shape.square))
END GPL .


Dennis Deck, PhD
RMC Research Corporation
[hidden email]

-----Original Message-----
From: Beadle, ViAnn [mailto:[hidden email]]
Sent: Wednesday, February 21, 2007 5:12 AM
To: Dennis Deck
Subject: RE: GRAPH stacked bar syntax limitations

Looks to me like you just used the Chart Builder interface. You're going
to have to get down and dirty with the GGRAPH syntax and GPL. You'll
need one ELEMENT statement for each of your variables crossed with unity
and a string to provide the label on x for each stack. You'll also need
to bypass the aggregation in the GGRAPH command directly specify it as a
summary function in the algebra. Here's an example for just two
variables pillok and spanking (from the GSS93 Subset.sav sample file):

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=pillok spanking
MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA: pillok=col(source(s), name("pillok"), unit.category())
 DATA: spanking=col(source(s), name("spanking"), unit.category())
 GUIDE: axis(dim(2), label("Count"))
 GUIDE: legend(aesthetic(aesthetic.color.interior), label("Responses"))
 SCALE: linear(dim(2), include(0))
 ELEMENT: interval.stack(position(summary.count("Birth Control to
Teenagers 14-16"*1)), color.interior(pillok),
shape.interior(shape.square))
 ELEMENT: interval.stack(position(summary.count("Favor Spanking to
Discipline Child"*1)), color.interior(spanking),
shape.interior(shape.square)) END GPL.

Walk through this with the on-line GPL help and when you get stuck, ask
questions. Note that if you are not using 15, there are some differences
between 14 and 15 but this will probably run on 14.

-----Original Message-----
From: Dennis Deck [mailto:[hidden email]]
Sent: Wednesday, February 21, 2007 2:27 AM
To: Beadle, ViAnn
Subject: RE: GRAPH stacked bar syntax limitations

I see that GGRAPH provides some extra flexibility (eg, ability to
exclude categories as required for variation d) but I don't see how it
allows for stacking multiple variables with the same categories needed
for the profiles (a-c).  I tried various approaches to profiles without
success.  The Chart Builder helped me understand the syntax better but
did not allow me to select multiple variables. I can get GGRAPH to
recognize the categories of a multiple response set but could not see
how to specify the X-axis properly.


GGRAPH
  /GRAPHDATASET NAME="graphdataset"
   VARIABLES=$RecgLevel[name="RecgLevel"]
              RESPONSES()[name="RESPONSES"]
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA: RecgLevel=col(source(s), name("RecgLevel"), unit.category())
 DATA: RESPONSES=col(source(s), name("RESPONSES"))
 GUIDE: axis(dim(1), label("Scale Recognition Levels"))
 GUIDE: axis(dim(2), label("N of Schools"))
 SCALE: cat(dim(1), include("1", "2", "3", "4"))
 SCALE: linear(dim(2), include(0))
 ELEMENT: interval.stack(position(RecgLevel*RESPONSES), color.interior(
  RecgLevel), shape.interior(shape.square))
END GPL.

Any suggestions appreciated.

Dennis Deck, PhD
RMC Research Corporation
[hidden email]

-----Original Message-----
From: Beadle, ViAnn [mailto:[hidden email]]
Sent: Tuesday, February 20, 2007 2:37 PM
To: Dennis Deck; [hidden email]
Subject: RE: GRAPH stacked bar syntax limitations

This is definitely a ggraph problem and will take a bit of exploration
or requires you do some data management to start re-arranging if you
want to use the ancient GRAPH command.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Dennis Deck
Sent: Tuesday, February 20, 2007 3:54 PM
To: [hidden email]
Subject: GRAPH stacked bar syntax limitations

I have a series of 8 scales with ordinal scores (values range from 0 to
3 representing recognition levels - see SPSS code below).  I would like
to display a summary profile consisting of stacked bars showing the
number of cases (schools) at each recognition level.  I would like to
break this down by one or more categorical variables.  I would also like
to produce variations such as the corresponding 100% stacked bars.

GRAPH syntax seems very limiting for stacked bars.  I can only get
appropriate stacked bars for two limited circumstances:
 a) one scale by one categorical variable
 b) one scale by two categorical variables (using /Panel)

I cannot produce:
 a) a profile for all 8 scales
 b) a profile for all 8 scales with panels by a categorical variable
 c) 100% stacked bars with the correct percentages (ie, within category)

 d) stacked bars which count for levels 1-3 but ignoring 0 (ie, not
reaching first recognition level)

My conclusion is that the syntax is just too limiting.  It appears that
I can only use the manual method:  use CTABLES to get the summary counts
or percentages and paste these into Powerpoint after a little editing.
My questions are:
 a) Have I overlooked any tricks to using GRAPH?
 b) Do GGRAPH or IGRAPH provide any additional capability? (my quick
examination suggests not)


*********************** .
*** Data Definition *** .
*********************** .

VARIABLE LEVEL rPolicy rMeals rFoods rHlthEd rPhysEd
               rPhysAct rAftrSch rStaff rTotal (ORDINAL) .
VARIABLE LEVEL Level4 Pilot LowSES Ethnic Size  (NOMINAL).

VARIABLE LABELS
  rPolicy  'Policy'
 /rMeals   'Reimbursable Meals'
 /rFoods   'Competitive Foods'
 /rHlthEd  'Health Education'
 /rPhysEd  'Physical Education'
 /rPhysAct 'Physical Activity'
 /rAftrSch 'After School'
 /rStaff   'Staff Wellness'
 /rTotal   'Total (overall level)' .

VALUE LABELS
 rPolicy rMeals   rFoods   rHlthEd
 rPhysEd rPhysAct rStaff  rAftrSch rTotal
  0 'No level'
  1 'Bronze'
  2 'Silver'
  3 'Gold' .

********************** .
*** Display Charts *** .
********************** .

* one scale by one categorical variable .
GRAPH /Bar(Stacked)= COUNT BY Level BY rPolicy  .

* one scale by two categorical variables .
GRAPH /Bar(Stacked)= COUNT BY Level BY rPolicy
  /Panel RowVar= LowSES .



Dennis Deck, PhD
RMC Research Corporation
111 SW Columbia Street, Suite 1200
Portland, Oregon 97201-5843
voice: 503-223-8248 x715
voice: 800-788-1887 x715
fax:  503-223-8248
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: GGRAPH multiple variable stacked bar

Maguin, Eugene
I'd like someone from spss to respond directly to these two questions.

Why does the 14 syntax reference manual not provide complete documentation
for all GPL commands and subcommands along with examples such as is done for
Igraph or Graph?

Why is it better for users to have program documentation stored behind a
usernamed and passworded website (I understand that that guest guest are the
defaults but only people who have seen it will know)?

Gene Maguin
Reply | Threaded
Open this post in threaded view
|

Re: GGRAPH multiple variable stacked bar

Beadle, ViAnn
AFAIK, the pdf wasn't available when 14 shipped but was subsequently built from the same source as the help text for GPL which is on the 14 distribution. I also think there are examples in the 14 help but not having 14 on my machine I can't check. The GPL reference pdf is on the 15 distribution.

I can't speak for why registration is encouraged on the SPSS web site.


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gene Maguin
Sent: Friday, February 23, 2007 2:55 PM
To: [hidden email]
Subject: Re: GGRAPH multiple variable stacked bar

I'd like someone from spss to respond directly to these two questions.

Why does the 14 syntax reference manual not provide complete documentation
for all GPL commands and subcommands along with examples such as is done for
Igraph or Graph?

Why is it better for users to have program documentation stored behind a
usernamed and passworded website (I understand that that guest guest are the
defaults but only people who have seen it will know)?

Gene Maguin
Reply | Threaded
Open this post in threaded view
|

Re: GGRAPH multiple variable stacked bar

Oliver, Richard
There is extensive GPL documentation in the SPSS 14 help system. (Try the Help Contents tab, Base System, GPL Reference.) In SPSS 14.0.1 this documentation was also provide in the form of a PDF manual on the separate Manuals CD. AFAIK, there is nothing in the PDF version that is not also provided in the help system.



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Beadle, ViAnn
Sent: Sunday, February 25, 2007 3:19 PM
To: [hidden email]
Subject: Re: GGRAPH multiple variable stacked bar

AFAIK, the pdf wasn't available when 14 shipped but was subsequently built from the same source as the help text for GPL which is on the 14 distribution. I also think there are examples in the 14 help but not having 14 on my machine I can't check. The GPL reference pdf is on the 15 distribution.

I can't speak for why registration is encouraged on the SPSS web site.


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gene Maguin
Sent: Friday, February 23, 2007 2:55 PM
To: [hidden email]
Subject: Re: GGRAPH multiple variable stacked bar

I'd like someone from spss to respond directly to these two questions.

Why does the 14 syntax reference manual not provide complete documentation
for all GPL commands and subcommands along with examples such as is done for
Igraph or Graph?

Why is it better for users to have program documentation stored behind a
usernamed and passworded website (I understand that that guest guest are the
defaults but only people who have seen it will know)?

Gene Maguin
Reply | Threaded
Open this post in threaded view
|

Re: GGRAPH multiple variable stacked bar

Maguin, Eugene
I make an apology to spss (and to Richard Oliver and ViAnn Beadle, both from
spss) for my confrontational tone regarding gpl documentation. Following
their reply, I checked my intallation and the gpl pdf is there. Given it
size, 4.6M, it would be huge addition to an already large (16M) syntax
reference pdf. I do think that things would be improved if the gpl manual
were connected to the syntax manual by adding to the Begin gpl section of
syntax manual a line referring the user to the gpl manual for syntax and
examples.

Gene Maguin
Reply | Threaded
Open this post in threaded view
|

Re: GGRAPH multiple variable stacked bar

Oliver, Richard
FWIW, we're working on ways to reduce the size of the GPL PDF file from 46 MB (not 4.6) to something more reasonable so we can include it in the installation, in a fashion similar to the Command Syntax Reference PDF.

But to reiterate, the same GPL documentation is available (and automatically installed) in the help system.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gene Maguin
Sent: Monday, February 26, 2007 11:49 AM
To: [hidden email]
Subject: Re: GGRAPH multiple variable stacked bar

I make an apology to spss (and to Richard Oliver and ViAnn Beadle, both from
spss) for my confrontational tone regarding gpl documentation. Following
their reply, I checked my intallation and the gpl pdf is there. Given it
size, 4.6M, it would be huge addition to an already large (16M) syntax
reference pdf. I do think that things would be improved if the gpl manual
were connected to the syntax manual by adding to the Begin gpl section of
syntax manual a line referring the user to the gpl manual for syntax and
examples.

Gene Maguin
Reply | Threaded
Open this post in threaded view
|

Re: GGRAPH multiple variable stacked bar

Oliver, Richard
In reply to this post by Dennis Deck
Oops. Never mind what I said about the size of the PDF file. The GPL PDF file is actually quite small. So including it in the installed documentation set might be an option -- although as I previously stated, it wouldn't provide any additional information beyond what's already in the help. The same is true for virtually all the PDF files on the Manuals CD; they basically provide the same information that's in the help system, just in a different format. If we installed all those PDF files, that would significantly increase the size of the installed documentation set without providing any real additional information, which is why we don't do it.

-----Original Message-----
From: Oliver, Richard
Sent: Monday, February 26, 2007 12:00 PM
To: 'Gene Maguin'; [hidden email]
Subject: RE: Re: GGRAPH multiple variable stacked bar

FWIW, we're working on ways to reduce the size of the GPL PDF file from 46 MB (not 4.6) to something more reasonable so we can include it in the installation, in a fashion similar to the Command Syntax Reference PDF.

But to reiterate, the same GPL documentation is available (and automatically installed) in the help system.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gene Maguin
Sent: Monday, February 26, 2007 11:49 AM
To: [hidden email]
Subject: Re: GGRAPH multiple variable stacked bar

I make an apology to spss (and to Richard Oliver and ViAnn Beadle, both from
spss) for my confrontational tone regarding gpl documentation. Following
their reply, I checked my intallation and the gpl pdf is there. Given it
size, 4.6M, it would be huge addition to an already large (16M) syntax
reference pdf. I do think that things would be improved if the gpl manual
were connected to the syntax manual by adding to the Begin gpl section of
syntax manual a line referring the user to the gpl manual for syntax and
examples.

Gene Maguin