multi-line graph picturing a time course for four variables

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

multi-line graph picturing a time course for four variables

tamar002
Dear all,

I would very much appreciate your help for the following problem:
I need to produce a time-course graph containing four lines, each reflecting the probability (Y-axis in %) to several points in time (X-axis in ms) to one specific type of stimulus (1 - 4). Time-range is from 200 to 2000ms (X-axis), divided into 100ms intervals. Data involves 32 values (which are mean proportions from 32 items in %) for each interval and stimulus type.
Thus the points of the lines are to depict the mean of 32 values each.

Now the aspect making things more complicated: I have to produce several graphs, each excluding some of the values (e.g. in interval from 500-600ms the value for stimulus type B of item 13). How can I arrange data appropriately to produce the described line graph AND to just deactivate several of the proportion values by using (e.g.) the select function?  

At the moment my table contains one column for each interval and stimulus-type (1_200, 2_200, 3_200, 4_200, 1_300...), consisting of 32 rows with the respective values (in row 1 the value for Item 1 and so on)...

Thanks a lot for your help,
Tanja


 
Reply | Threaded
Open this post in threaded view
|

Re: multi-line graph picturing a time course for four variables

Andy W

Short answer if you can generate a line graph you are happy with, you can use a temporary select if statement before generating the graph to remove certain values.

Long example below - IMO your data is stored in a weird and inconvenient format, and so I go through several intermediate steps to get the final outcome. Also it isn't really clear what you want to happen when "deselect" values. Here it just draws a line through the missing values as if nothing else changed, if you don't want it to draw a line other measures will need to be taken.


*******************************************************.
*making fake cases data - how I think your data is set up?.
set seed = 10.
input program.
loop #i = 1 to 32.
compute idn = #i.
end case.
end loop.
end file.
end input program.
dataset name sim.
execute.

*Making the stimulus variables.
vector stim1_(19)
/stim2_(19)
/stim3_(19)
/stim4_(19).

*when you say "probability Y axis" - makes me think the data are bernoulli.
do repeat stim = stim1_1 to stim4_19.
compute stim = RV.BERNOULLI(0.5).
end repeat.

*this is a weird way to have the data stored IMO - we will reshape and contain the info we need.
varstocases
/make stim1 from stim1_1 to stim1_19
/make stim2 from stim2_1 to stim2_19
/make stim3 from stim3_1 to stim3_19
/make stim4 from stim4_1 to stim4_19
/index intervalms.

*here we can aggregate to get the mean within each experiment condition.
DATASET ACTIVATE sim.
DATASET DECLARE mean_cond.
AGGREGATE
  /OUTFILE='mean_cond'
  /BREAK=intervalms
  /stim1_mean=MEAN(stim1) 
  /stim2_mean=MEAN(stim2) 
  /stim3_mean=MEAN(stim3) 
  /stim4_mean=MEAN(stim4).
dataset activate mean_cond.
dataset close sim.

*for simplicity in making the graph I will reshape again so all simulus variables are in one column.
varstocases
/make stim_mean from stim1_mean to stim4_mean
/index stim_type.
*If you want to estimate anova or logit regression- simply take out the aggregate step above.

*make a numeric interval value.
compute intervalms_num = (intervalms+1)*100.
exe.

*now we can make your line graph.
DATASET ACTIVATE mean_cond.
* Chart Builder.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=intervalms_num stim_mean stim_type MISSING=LISTWISE 
    REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: intervalms_num=col(source(s), name("intervalms_num"))
  DATA: stim_mean=col(source(s), name("stim_mean"))
  DATA: stim_type=col(source(s), name("stim_type"), unit.category())
  GUIDE: axis(dim(1), label("intervalms_num"))
  GUIDE: axis(dim(2), label("stim_mean"))
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("stim_type"))
  ELEMENT: line(position(intervalms_num*stim_mean), color.interior(stim_type), missing.wings())
END GPL.

*You can just use a temporary select statement before generating the graph to deselect certain intervals.
temporary.
select if intervalms_num <> 500.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=intervalms_num stim_mean stim_type MISSING=LISTWISE 
    REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: intervalms_num=col(source(s), name("intervalms_num"))
  DATA: stim_mean=col(source(s), name("stim_mean"))
  DATA: stim_type=col(source(s), name("stim_type"), unit.category())
  GUIDE: axis(dim(1), label("intervalms_num"))
  GUIDE: axis(dim(2), label("stim_mean"))
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("stim_type"))
  ELEMENT: line(position(intervalms_num*stim_mean), color.interior(stim_type), missing.wings())
END GPL.
*******************************************************.

You may also want to consider plots that draw error bars (should be simple to add in the above set up if all your cells have exactly 32 values). Here I give an example on the developerworks forum.

Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/