Hi, all.
I'm struggling with developing a graph which shows overlap of the frequency of a variable by group, in which the graph is based on the rank of the variable in one of the two groups. Specifically, how might I produce a graph overlaying the frequency of age for each group based on the rank of age in the control group. The summary frequency table with the data appears below. Thanks.
Brian
|
I don't understand what you want. Can you maybe draw a sketch of the graph
you are thinking and upload it? ----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- 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 |
I thought this went through earlier, but perhaps not. Here's a file with the
two graphs. I would like to overlay the control group onto the treatment group, keeping the order of the ages (x axis) the same. The x-axis is ranked by frequency of age. Brian Graphs_for_Overlay.docx <http://spssx-discussion.1045642.n5.nabble.com/file/t341458/Graphs_for_Overlay.docx> -- 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 |
After calculating proportions for each age and restructuring to the long data
format, the Graph>Chart Builder was used with a clustered bar chart. Custom sort order was chosen on the x-axis but an GPL-error is generated in the sort function. Running the GPL code in syntax and changing sort.values() to sort.data() fixes the x-axis order. HTH, PR DATA LIST LIST / Age Treatment Control (3F8). BEGIN DATA 31 34 52 30 44 32 28 33 30 29 40 28 32 25 25 33 14 18 34 7 14 26 7 10 27 17 10 25 6 3 35 1 3 36 0 2 24 0 1 37 0 1 23 1 0 END DATA. DATASET NAME BD. AGGREGATE /OUTFILE = * MODE=ADDVARIABLES OVERWRITEVARS=YES /BREAK = /Treatment_sum = SUM(Treatment) /Control_sum = SUM(Control) . COMPUTE Treatment_frc = Treatment/Treatment_sum. COMPUTE Control_frc = Control/Control_sum. *Set decimals in graph. FORMATS Treatment_frc Control_frc (F8.3). SORT CASES Treatment (D) Age (A). VARSTOCASES /MAKE data FROM Treatment_frc Control_frc /INDEX=Group(2) /KEEP=Age /NULL=KEEP. VALUE LABELS Group 1'Treatment' 2'Control'. GGRAPH /GRAPHDATASET NAME = "graphdataset" VARIABLES = Age [LEVEL=NOMINAL] data Group MISSING = LISTWISE REPORTMISSING = NO /GRAPHSPEC SOURCE = INLINE. BEGIN GPL SOURCE: s =userSource(id("graphdataset")) DATA: Age =col(source(s), name("Age"), unit.category()) DATA: data =col(source(s), name("data")) DATA: Group=col(source(s), name("Group"), unit.category()) COORD: rect(dim(1,2), cluster(3,0)) GUIDE: axis(dim(3), label("Age")) GUIDE: legend(aesthetic(aesthetic.color.interior), label("Group")) SCALE: cat(aesthetic(aesthetic.color.interior), include("1", "2")) SCALE: cat(dim(1), include("1", "2")) SCALE: linear(dim(2), include(0)) COMMENT: The following SCALE statement is generated as sort.values() and generates an error. change to sort data() to keep original order SCALE cat(dim(3), sort.values()) SCALE: cat(dim(3), sort.data()) ELEMENT: interval(position(Group*data*Age), color.interior(Group), shape.interior(shape.square)) END GPL. -- 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 |
Thank-you very much! I really appreciate the time you spent on this, and hopefully others will find it useful as well. I've started spending more time with GGraph, but I have a long way to go. Too much time spent with matrices and macros. Thanks again.
Brian
From: SPSSX(r) Discussion <[hidden email]> on behalf of PRogman <[hidden email]>
Sent: Friday, November 9, 2018 11:50:06 AM To: [hidden email] Subject: Re: Graph of Overlay of Two Variables Ranked by One of the Two Variables After calculating proportions for each age and restructuring to the long data
format, the Graph>Chart Builder was used with a clustered bar chart. Custom sort order was chosen on the x-axis but an GPL-error is generated in the sort function. Running the GPL code in syntax and changing sort.values() to sort.data() fixes the x-axis order. HTH, PR DATA LIST LIST / Age Treatment Control (3F8). BEGIN DATA 31 34 52 30 44 32 28 33 30 29 40 28 32 25 25 33 14 18 34 7 14 26 7 10 27 17 10 25 6 3 35 1 3 36 0 2 24 0 1 37 0 1 23 1 0 END DATA. DATASET NAME BD. AGGREGATE /OUTFILE = * MODE=ADDVARIABLES OVERWRITEVARS=YES /BREAK = /Treatment_sum = SUM(Treatment) /Control_sum = SUM(Control) . COMPUTE Treatment_frc = Treatment/Treatment_sum. COMPUTE Control_frc = Control/Control_sum. *Set decimals in graph. FORMATS Treatment_frc Control_frc (F8.3). SORT CASES Treatment (D) Age (A). VARSTOCASES /MAKE data FROM Treatment_frc Control_frc /INDEX=Group(2) /KEEP=Age /NULL=KEEP. VALUE LABELS Group 1'Treatment' 2'Control'. GGRAPH /GRAPHDATASET NAME = "graphdataset" VARIABLES = Age [LEVEL=NOMINAL] data Group MISSING = LISTWISE REPORTMISSING = NO /GRAPHSPEC SOURCE = INLINE. BEGIN GPL SOURCE: s =userSource(id("graphdataset")) DATA: Age =col(source(s), name("Age"), unit.category()) DATA: data =col(source(s), name("data")) DATA: Group=col(source(s), name("Group"), unit.category()) COORD: rect(dim(1,2), cluster(3,0)) GUIDE: axis(dim(3), label("Age")) GUIDE: legend(aesthetic(aesthetic.color.interior), label("Group")) SCALE: cat(aesthetic(aesthetic.color.interior), include("1", "2")) SCALE: cat(dim(1), include("1", "2")) SCALE: linear(dim(2), include(0)) COMMENT: The following SCALE statement is generated as sort.values() and generates an error. change to sort data() to keep original order SCALE cat(dim(3), sort.values()) SCALE: cat(dim(3), sort.data()) ELEMENT: interval(position(Group*data*Age), color.interior(Group), shape.interior(shape.square)) END GPL. -- 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 |
Free forum by Nabble | Edit this page |