FW: Line Graph of Repeated Measures Data with One Line for Each Case?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

FW: Line Graph of Repeated Measures Data with One Line for Each Case?

ViAnn Beadle

Oops, the d was stripped from the data list command in the last email, so here’s the corrected version.

 

From: ViAnn Beadle [mailto:[hidden email]]
Sent: Friday, September 04, 2009 4:27 PM
To: 'Justin Meyer'; '[hidden email]'
Subject: RE: Line Graph of Repeated Measures Data with One Line for Each Case?

 

If you have no categorical variable (as in your example below), then the mean is the observed value. The complication arises when you add a categorical variable such as school to the algebra, because then you get the mean of the school. You can use the split function to split the lines by student id.

 

As has been discussed here repeatedly, things get very complicated within GPL when you try to compare multiple variables. It was really designed to compare rows of data. It is true that the GGRAPH provides a shortcut for restructuring on the fly via the TRANSFORM keyword, but this is tied to aggregation and now your mean is an mean within school. If multiple students are in the same school, you do not get what you want.

 

The simplest way to approach this is to restructure the data using VARSTOCASES command first to generate a dataset in which each row is a student’s score on a single administration. The following simple example does that and then uses split to get a line for each student.

 

data list list/ student test1 test2 test3 test4 (5f1.0)school (A1).

begin data

1 5 3 4 2 A

2 3 3 3 4 A

3 4 3 5 2 B

4 2 2 2 4 B

end data.

VARSTOCASES MAKE testresult from test1 to test4

 / INDEX = time.

* Chart Builder.

variable level time student (nominal) testresult(scale).

 

* Chart Builder.

GGRAPH

  /GRAPHDATASET NAME="graphdataset" VARIABLES=time testresult[LEVEL=SCALE] school student

  /GRAPHSPEC SOURCE=INLINE.

BEGIN GPL

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

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

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

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

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

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

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

  GUIDE: legend(aesthetic(aesthetic.color.interior), label("school"))

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

  ELEMENT: line(position(time*testresult), color.interior(school), split(student), missing.wings())

END GPL.

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Justin Meyer
Sent: Friday, September 04, 2009 1:46 PM
To: [hidden email]
Subject: Line Graph of Repeated Measures Data with One Line for Each Case?

 

Hi SPSS Listers,

 

I want to graph data from 4 test administrations on a line graph, with the y axis as each student’s test score and the x-axis the 4 administrations. My data has each student as a case with one text variable indicating school and each of the four test scores as a scale variable. I dragged the four scores into the y axis box in chart builder but it will only let me summarize the data as a mean, etc (shown below). How do I get it to show the line for each student? I suppose I could create a variable with a unique number for each student and then use it as a grouping variable, but there has to be a cleaner method. Once I have a line for each student, how can I color code them by school? Thanks!

 

* Chart Builder.

GGRAPH

  /GRAPHDATASET NAME="graphdataset" VARIABLES=MEAN(SS4) MEAN(sSS4) MEAN(

  F08SS4) MEAN(S09SS4) MISSING=LISTWISE REPORTMISSING=NO

  TRANSFORM=VARSTOCASES(SUMMARY="#SUMMARY" INDEX="#INDEX")

  /GRAPHSPEC SOURCE=INLINE.

BEGIN GPL

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

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

 DATA: SUMMARY=col(source(s), name("#SUMMARY"))

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

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

 SCALE: cat(dim(1), include("0", "1", "2", "3"))

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

 ELEMENT: line(position(INDEX*SUMMARY), missing.wings())

END GPL.

 

____________________________________

Justin Meyer

Researcher

Rowland Reading Foundation

6120 University Avenue

Middleton, WI 53562

phone: 866-370-7323  fax: 608-204-3846

www.rowlandreading.org

____________________________________