graph of longitudinal data

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

graph of longitudinal data

Zdaniuk, Bozena-3

Hello, i know it must be simple but for some reason i cannot figure out how to do it.
I have data for the same measure for 8 years. They are in separate columns(variables) : year1, year2.... year8 ("short" file - one case per row).
I have a grouping variable "group" consisting of four categories.
I want to create a graph with year1-year8 on the X axis, range of mean values on the Y axis, and four separate lines, each one representing means for year1-year8 for one category of the "group" variable. I have been playing with the "Graph" functions forever but don't seem to be able to produce it...
the only way i got what i wanted was when running one-within one-between factor MANOVA and asking for the plot of the interaction. But shouldn't i be able to get the same using Graph function?
Thanks so much in advance.
bozena
Reply | Threaded
Open this post in threaded view
|

Re: graph of longitudinal data

Bruce Weaver
Administrator
I've run across situations where I've had to restructure the data from wide to long (VARSTOCASES) in order to get the graph I wanted.  This may be one of those situations.  ;-)

HTH.


Bozena Zdaniuk wrote
Hello, i know it must be simple but for some reason i cannot figure out how to do it.
I have data for the same measure for 8 years. They are in separate columns(variables) : year1, year2.... year8 ("short" file - one case per row).
I have a grouping variable "group" consisting of four categories.
I want to create a graph with year1-year8 on the X axis, range of mean values on the Y axis, and four separate lines, each one representing means for year1-year8 for one category of the "group" variable. I have been playing with the "Graph" functions forever but don't seem to be able to produce it...
the only way i got what i wanted was when running one-within one-between factor MANOVA and asking for the plot of the interaction. But shouldn't i be able to get the same using Graph function?
Thanks so much in advance.
bozena
--
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: graph of longitudinal data

ViAnn Beadle
In reply to this post by Zdaniuk, Bozena-3

Here’s a solution using the GGRAPH command. To get this using Chart Builder, drag all 8 variables to y. This does a VARSTOCASES type of transformation within the procedure which creates two variables, one containing the value of the summary variable and the other an index to primary variable. The categorical variable is dragged to the set color drop zone.

 

input program.

loop #i = 1 to 100.

do repeat x = x1 to x8.

compute x = normal(1).

end repeat.

compute group = trunc(uniform(4))+ 1.

end case.

end loop.

end file.

end input program.

list.

* Chart Builder.

GGRAPH

  /GRAPHDATASET NAME="graphdataset" VARIABLES=MEAN(x1) MEAN(x2) MEAN(x3) MEAN(x4) MEAN(x5) MEAN(x6)

    MEAN(x7) MEAN(x8) group MISSING=LISTWISE REPORTMISSING=NO

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

  /GRAPHSPEC SOURCE=INLINE.

BEGIN GPL

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

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

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

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

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

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

  SCALE: cat(dim(1), include("0", "1", "2", "3", "4", "5", "6", "7"))

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

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

END GPL.

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Zdaniuk, Bozena
Sent: Thursday, November 24, 2011 2:41 PM
To: [hidden email]
Subject: graph of longitudinal data

 


Hello, i know it must be simple but for some reason i cannot figure out how to do it.
I have data for the same measure for 8 years. They are in separate columns(variables) : year1, year2.... year8 ("short" file - one case per row).
I have a grouping variable "group" consisting of four categories.
I want to create a graph with year1-year8 on the X axis, range of mean values on the Y axis, and four separate lines, each one representing means for year1-year8 for one category of the "group" variable. I have been playing with the "Graph" functions forever but don't seem to be able to produce it...
the only way i got what i wanted was when running one-within one-between factor MANOVA and asking for the plot of the interaction. But shouldn't i be able to get the same using Graph function?
Thanks so much in advance.
bozena