SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 

 View Only
Expand all | Collapse all

How to add data points to error plots in SPSS?

  • 1.  How to add data points to error plots in SPSS?

    Posted Mon October 12, 2020 04:42 PM

    I can add individual points to a box and whisker plots, but I would like to do the same thing with an error plot for normally distributed data. I can make interval plots of mean and SD. However, I can't work out how to add data points to the interval plot.

    So my code for creating the dot plots is

    GGRAPH

    /GRAPHDATASET NAME="Tutorialdata" VARIABLES= GeneCat Weight MISSING=LISTWISE

    REPORTMISSING=NO

    /GRAPHSPEC SOURCE=INLINE.

    BEGIN GPL

    SOURCE: s=userSource(id("Tutorialdata"))

    DATA: GeneCat=col(source(s), name("GeneCat"), unit.category())

    DATA: Weight=col(source(s), name("Weight"))

    GUIDE: axis(dim(1), label("GeneCat"))

    GUIDE: axis(dim(2), label("Weight"))

    SCALE: linear(dim(2), include(0))

    ELEMENT: point.dodge.symmetric(position(bin.dot(GeneCat*Weight,dim(2))),color(color.red))

    END GPL

    And I used the following code to generate the data for the interval plots

    dataset declare mean.

    OMS /IF LABELS = 'Report'

    /DESTINATION FORMAT = SAV OUTFILE = 'mean'.

    MEANS TABLES= Weight BY GeneCat

    /CELLS MEAN SEMEAN.

    OMSEND.

    dataset activate mean.

    compute mean_minus = mean - Std.ErrorofMean.

    compute mean_plus = mean + Std.ErrorofMean.

    execute.

    I saved the file as "mean", and re-labelled Var1 to "GeneCat2" and deleted row 3 (which contained totals)

    I then used the following code to plot the interval plots

    GGRAPH

    /GRAPHDATASET NAME="mean" VARIABLES=GeneCat2 mean_plus

    mean_minus Mean[LEVEL=SCALE]

    MISSING=LISTWISE REPORTMISSING=NO

    /GRAPHSPEC SOURCE=INLINE.

    BEGIN GPL

    SOURCE: s2=userSource(id("mean"))

    DATA: GeneCat2=col(source(s2), name("GeneCat"), unit.category())

    DATA: mean_plus=col(source(s2), name("mean_plus"))

    DATA: mean_minus=col(source(s2), name("mean_minus"))

    DATA: Mean=col(source(s2), name("Mean"))

    GUIDE: axis(dim(1), label("GeneCat "))

    GUIDE: axis(dim(2), label("Mean Estimate and Std. Error of Mean"))

    SCALE: linear(dim(2), include(0))

    ELEMENT: interval(position(region.spread.range(GeneCat2*(mean_minus+mean_plus))),

    shape(shape.ibeam))

    ELEMENT: point(position(GeneCat2*Mean), shape(shape.square))

    END GPL

    I tried combining them but if I open the syntax window from the tutorial data file it doesn't recognise the mean file. Likewise if open the syntax window from the mean data it doesn't recognise the tutorialdata file. I tried copy and pasting the data from the mean file in to the tutorial data file, then relabelling the mean files variable from GeneCat to Genecat2. I used the following code

    GGRAPH

    /GRAPHDATASET NAME="Tutorialdata" VARIABLES=GeneCat2 mean_plus

    mean_minus Mean[LEVEL=SCALE]

    MISSING=LISTWISE REPORTMISSING=NO

    /GRAPHDATASET NAME="Tutorialdata" VARIABLES= GeneCat Weight MISSING=LISTWISE

    REPORTMISSING=NO

    /GRAPHSPEC SOURCE=INLINE.

    BEGIN GPL

    SOURCE: s=userSource(id("Tutorialdata"))

    DATA: GeneCat=col(source(s), name("GeneCat"), unit.category())

    DATA: Weight=col(source(s), name("Weight"))

    SOURCE: s2=userSource(id("Tutorialdata"))

    DATA: GeneCat2=col(source(s2), name("GeneCat2"), unit.category())

    DATA: mean_plus=col(source(s2), name("mean_plus"))

    DATA: mean_minus=col(source(s2), name("mean_minus"))

    DATA: Mean=col(source(s2), name("Mean"))

    GUIDE: axis(dim(1), label("GeneCat"))

    GUIDE: axis(dim(2), label("Weight"))

    SCALE: linear(dim(2), include(0))

    ELEMENT: point.dodge.symmetric(position(bin.dot(GeneCat*Weight,dim(2))),color(color.red))

    ELEMENT: interval(position(region.spread.range(GeneCat2*(mean_minus+mean_plus))),

    shape(shape.ibeam))

    ELEMENT: point(position(GeneCat2*Mean), shape(shape.square))

    END GPL

    The issue is the graphs aren't overlaid. Instead whichever variables are listed in the first line will be shown, but those written in line 4 won't be.

    I am not really an SPSS user, but it was the package the department chose to teach the students, so I am trying to figure it out. I have only been at it a couple of days, and I have zero programming background or skills, so I would really appreciate if any answers were written as if addressing a complete novice.

    Any help would be greatly appreciated.






    #SPSSStatistics
    #Support
    #SupportMigration


  • 2.  RE: How to add data points to error plots in SPSS?

    Posted Mon October 12, 2020 04:44 PM

    Sorry, I have altered the code for creating the mean and spread so that it is standard deviation and not SEM a is written here.






    #SPSSStatistics
    #Support
    #SupportMigration


  • 3.  RE: How to add data points to error plots in SPSS?

    Posted Mon October 12, 2020 08:55 PM

    I suggest that you install the STATS COMPARE SUBGROUPS extension command from the Extensions > Extension Hub menu and run it. It works with two datasets, and you can see in the Notes table the GGRAPH and GPL syntax that it uses to do that.






    #SPSSStatistics
    #Support
    #SupportMigration