# Graphing multiple data elements with a grouping variable

2 messages
Open this post in threaded view
|
Report Content as Inappropriate

## Graphing multiple data elements with a grouping variable

 Dear SPSS Syntax Experts,I am trying to graph an independent variable vs. the predictive probability (and 95%CI) from a logistic regression with the lines grouped by gender. I ran the logistic regression via GENLIN because I could save the 95%CI predictive probability data. My plan was to run a scatter plot then fit a quadratic line of best fit to those data and delete the data points. That might not be efficient but it is the method I know. I can do this in Excel/Powerpoint, but was hoping to get 'er done in SPSS. The code shown below does not include a line of best fit. Optimally, I'd like to shade the area between the 95%CIs, but that might be too much to ask. Using chart builder I am able to create a scatter plot of the independent variable vs. predictive probability (without 95%CIs) grouped by gender. Code shown below:**************************************************************************************.* Plot of independent variable vs. predictive probability grouped by gender.GGRAPH  /GRAPHDATASET NAME="graphdataset" VARIABLES=pVO2kg MeanPredicted Gender MISSING=LISTWISE     REPORTMISSING=NO  /GRAPHSPEC SOURCE=INLINE.BEGIN GPL  SOURCE: s=userSource(id("graphdataset"))  DATA: pVO2kg=col(source(s), name("pVO2kg"))  DATA: MeanPredicted=col(source(s), name("MeanPredicted"))  DATA: Gender=col(source(s), name("Gender"), unit.category())  GUIDE: axis(dim(1), label("pVO2kg"))  GUIDE: axis(dim(2), label("Predicted Value of Mean of Response"))  GUIDE: legend(aesthetic(aesthetic.color.exterior), label("Gender"))  SCALE: cat(aesthetic(aesthetic.color.exterior), include("0", "1"))  ELEMENT: point(position(pVO2kg*MeanPredicted), color.exterior(Gender))END GPL.**************************************************************************************.I am also able to create this scatter plot with the 95%CI, but WITHOUT grouping by gender. Code shown below:**************************************************************************************.* Plot of independent variable vs. predictive probability (+95%CI); no grouping.GGRAPH  /GRAPHDATASET NAME="graphdataset" VARIABLES=pVO2kg MeanPredicted CIMeanPredictedLower     CIMeanPredictedUpper MISSING=LISTWISE REPORTMISSING=NO  /GRAPHSPEC SOURCE=INLINE.BEGIN GPL  SOURCE: s=userSource(id("graphdataset"))  DATA: pVO2kg=col(source(s), name("pVO2kg"))  DATA: MeanPredicted=col(source(s), name("MeanPredicted"))  DATA: CIMeanPredictedLower=col(source(s), name("CIMeanPredictedLower"))  DATA: CIMeanPredictedUpper=col(source(s), name("CIMeanPredictedUpper"))  DATA: Gender=col(source(s), name("Gender"), unit.category())   GUIDE: axis(dim(1), label("pVO2kg"))  GUIDE: axis(dim(2), label("Predicted Value of Mean of Response"))  TRANS: pVO2kg_MeanPredicted=eval("pVO2kg - Predicted Value of Mean of Response")  TRANS: pVO2kg_CIMeanPredictedL=eval("pVO2kg - Lower Bound of CI for Mean of Response")  TRANS: pVO2kg_CIMeanPredictedU=eval("pVO2kg - Upper Bound of CI for Mean of Response")  ELEMENT: point(position(pVO2kg*MeanPredicted), color.exterior(pVO2kg_MeanPredicted))  ELEMENT: point(position(pVO2kg*CIMeanPredictedLower), color.exterior(pVO2kg_CIMeanPredictedL))  ELEMENT: point(position(pVO2kg*CIMeanPredictedUpper), color.exterior(pVO2kg_CIMeanPredictedU))END GPL.**************************************************************************************.Below is my attempt at combining the code shown above. This resulted in a "GPL error: Translation failed."**************************************************************************************.* Plot of independent variable vs. predictive probability (+95%CI) grouped by gender.GGRAPH  /GRAPHDATASET NAME="graphdataset" VARIABLES=pVO2kg MeanPredicted CIMeanPredictedLower     CIMeanPredictedUpper Gender MISSING=LISTWISE     REPORTMISSING=NO  /GRAPHSPEC SOURCE=INLINE.BEGIN GPL  SOURCE: s=userSource(id("graphdataset"))  DATA: pVO2kg=col(source(s), name("pVO2kg"))  DATA: MeanPredicted=col(source(s), name("MeanPredicted"))  DATA: CIMeanPredictedLower=col(source(s), name("CIMeanPredictedLower"))  DATA: CIMeanPredictedUpper=col(source(s), name("CIMeanPredictedUpper"))  DATA: Gender=col(source(s), name("Gender"), unit.category())  GUIDE: axis(dim(1), label("pVO2kg"))  GUIDE: axis(dim(2), label("Predicted Value of Mean of Response"))  GUIDE: legend(aesthetic(aesthetic.color.exterior), label("Gender"))  SCALE: cat(aesthetic(aesthetic.color.exterior), include("0", "1"))  TRANS: pVO2kg_MeanPredicted=eval("pVO2kg - Predicted Value of Mean of Response")  TRANS: pVO2kg_CIMeanPredictedL=eval("pVO2kg - Lower Bound of CI for Mean of Response")  TRANS: pVO2kg_CIMeanPredictedU=eval("pVO2kg - Upper Bound of CI for Mean of Response")  ELEMENT: point(position(pVO2kg*MeanPredicted), color.exterior(pVO2kg_MeanPredicted))  ELEMENT: point(position(pVO2kg*CIMeanPredictedLower), color.exterior(Gender))  ELEMENT: point(position(pVO2kg*CIMeanPredictedUpper), color.exterior(Gender))END GPL.**************************************************************************************.Thanks for your time.Best wishes,Clinton A. Brawner ===================== 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