Bar charts based on counts

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

Bar charts based on counts

Robert L
Just to make things more complicated than they need to be: is there a way to set up a bar chart with Chart Builder from tabulated data? There is an option in Graphs/Legacy Dialogs where you can use "values of individual cases", but I can't find a way to do the same with Chart Builder.  I have used the following simple syntax:

DATA LIST FREE/day(F1) count(F3).
BEGIN DATA
1 23 2 45 3 90 4 175
END DATA.
DATASET NAME counts WINDOW=FRONT.

*The following works, but it would be nice to be able to do the same in Chart Builder.
GRAPH /BAR(SIMPLE)=VALUE(count) BY day.

Any suggestions?

Robert

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Robert Lundqvist
Reply | Threaded
Open this post in threaded view
|

Re: Bar charts based on counts

Bruce Weaver
Administrator
Hi Robert.  The following code generates exactly the same graph (apart from
some labeling differences) as your GRAPH command:

* Chart Builder.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=day
MEAN(count)[name="MEAN_count"] MISSING=LISTWISE
    REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: day=col(source(s), name("day"), unit.category())
  DATA: MEAN_count=col(source(s), name("MEAN_count"))
  GUIDE: axis(dim(1), label("day"))
  GUIDE: axis(dim(2), label("Mean count"))
  GUIDE: text.title(label("Simple Bar Mean of count by day"))
  SCALE: linear(dim(2), include(0))
  ELEMENT: interval(position(day*MEAN_count), shape.interior(shape.square))
END GPL.




Robert L wrote

> Just to make things more complicated than they need to be: is there a way
> to set up a bar chart with Chart Builder from tabulated data? There is an
> option in Graphs/Legacy Dialogs where you can use "values of individual
> cases", but I can't find a way to do the same with Chart Builder.  I have
> used the following simple syntax:
>
> DATA LIST FREE/day(F1) count(F3).
> BEGIN DATA
> 1 23 2 45 3 90 4 175
> END DATA.
> DATASET NAME counts WINDOW=FRONT.
>
> *The following works, but it would be nice to be able to do the same in
> Chart Builder.
> GRAPH /BAR(SIMPLE)=VALUE(count) BY day.
>
> Any suggestions?
>
> Robert
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Bar charts based on counts

Robert L
In reply to this post by Robert L
Thanks Bruce, of course it works, I should have seen that before posting. But in the data I really wanted to use (Swedish corona cases) I didn't manage to set up the bar charts. And I simply assumed that the same would happen with the smaller dataset enclosed in the previous mail.

The explanation was the variable level. For bar charts to work, the variable on the x-axis must be nominal or ordinal, not scale. Which is kind of natural, should have seen that...

But isn't it somewhat strange to have date variables defined as ordinal or nominal?

Robert

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Robert Lundqvist
Reply | Threaded
Open this post in threaded view
|

Re: Bar charts based on counts

Jon Peck
The measurement level setting in Statistics is really about how you want the variables to be treated in those places where the ML matters, not quite what the "true" level is.  For example, in CTABLES, you might want to treat years of education as scale if means and such are wanted and as categorical if you want to tabulate something by years of education.

IIRC, the places where the ml is automatically taken into account are GPL, CTABLES, TREES, and statistical extension commands.  In other places the user dictates the treatment. e.g., covariate vs factor, explicitly.

On Thu, Apr 2, 2020 at 6:44 AM Robert Lundqvist <[hidden email]> wrote:
Thanks Bruce, of course it works, I should have seen that before posting. But in the data I really wanted to use (Swedish corona cases) I didn't manage to set up the bar charts. And I simply assumed that the same would happen with the smaller dataset enclosed in the previous mail.

The explanation was the variable level. For bar charts to work, the variable on the x-axis must be nominal or ordinal, not scale. Which is kind of natural, should have seen that...

But isn't it somewhat strange to have date variables defined as ordinal or nominal?

Robert

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


--
Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Bar charts based on counts

Jon Peck
In reply to this post by Bruce Weaver
Just for fun, you can create this graph from CTABLES.

Run this
CTABLES
  /TABLE day BY count [MEAN].

Then double click the table and  select Edit > Create Graph > Bar in the Pivot Table Editor.
:-)

On Thu, Apr 2, 2020 at 6:10 AM Bruce Weaver <[hidden email]> wrote:
Hi Robert.  The following code generates exactly the same graph (apart from
some labeling differences) as your GRAPH command:

* Chart Builder.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=day
MEAN(count)[name="MEAN_count"] MISSING=LISTWISE
    REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: day=col(source(s), name("day"), unit.category())
  DATA: MEAN_count=col(source(s), name("MEAN_count"))
  GUIDE: axis(dim(1), label("day"))
  GUIDE: axis(dim(2), label("Mean count"))
  GUIDE: text.title(label("Simple Bar Mean of count by day"))
  SCALE: linear(dim(2), include(0))
  ELEMENT: interval(position(day*MEAN_count), shape.interior(shape.square))
END GPL.




Robert L wrote
> Just to make things more complicated than they need to be: is there a way
> to set up a bar chart with Chart Builder from tabulated data? There is an
> option in Graphs/Legacy Dialogs where you can use "values of individual
> cases", but I can't find a way to do the same with Chart Builder.  I have
> used the following simple syntax:
>
> DATA LIST FREE/day(F1) count(F3).
> BEGIN DATA
> 1 23 2 45 3 90 4 175
> END DATA.
> DATASET NAME counts WINDOW=FRONT.
>
> *The following works, but it would be nice to be able to do the same in
> Chart Builder.
> GRAPH /BAR(SIMPLE)=VALUE(count) BY day.
>
> Any suggestions?
>
> Robert
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


--
Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Bar charts based on counts

Rich Ulrich
In reply to this post by Jon Peck
Sorry, I can't resist breaking in with a personal peeve.

Jon: The measurement level setting in Statistics is really about how you want the variables to be treated in those places where the ML matters, not quite what the "true" level is.

I say, that is true far more widely than in specifying SPSS tables.

I say, "how the variable is treated" statistically always should
accord with the logic of the other variables and analyses.

An example: "number of children" scored as 0, 1, 2 ...  looks
both ordinal and scaled. (And, by Stephens's levels of
measurement, "interval" rather than ratio.)  But for family
dynamics, ZERO will fall out of order when you look at certain
responses with the Num_children taken as categories.  (The
error that is more subtle is deeming something "obviously
equal interval", like a chemical ppm, when taking logs creates
the equal interval scale.)

--
Rich Ulrich

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD