I have data for four variables, each describing forecasts from different approaches to time series. The variables are Actual_Data, Exponential_Smoothing_Data, ARIMA_Data, and Bayesian_Data. I would like to develop a legend that contains each variable and its color code in a line graph. Is there any way to do this, or do I need to reshape the data to one variable containing all predictions and a second variable indicating category? I've reviewed all of the SPSS documentation, and can't find any way to do the first option, but wondered if I'm missing something. It would make life a lot easier for me since other graphs are in the format I've described. Thanks.
Brian |
Administrator
|
Hi Brian. If I understand what your data look like, you can use either GRAPH or GGRAPH to make a multi-line line graph for separate variables. Here is an example using some fake data.
NEW FILE. DATASET CLOSE ALL. DATA LIST FREE / Time (F2.0). BEGIN DATA 1 2 3 4 5 6 7 8 9 10 END DATA. * Generate some random data to illustrate. COMPUTE F1 = RV.NORMAL(50,10)+Time. COMPUTE F2 = RV.NORMAL(45,10)+Time. COMPUTE F3 = RV.NORMAL(40,10)+Time. COMPUTE F4 = RV.NORMAL(35,10)+Time. DESCRIPTIVES F1 to F4. * Multiple line graph via GRAPH command (legacy-dialogs). GRAPH /LINE(MULTIPLE)=VALUE(F1) VALUE(F2) VALUE(F3) VALUE(F4) BY Time /MISSING=LISTWISE /TITLE='Plot of 4 time series'. * Multiple line graph via Chart Builder. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=Time MEAN(F1) MEAN(F2) MEAN(F3) MEAN(F4) MISSING=LISTWISE REPORTMISSING=NO TRANSFORM=VARSTOCASES(SUMMARY="#SUMMARY" INDEX="#INDEX") /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: Time=col(source(s), name("Time"), unit.category()) DATA: SUMMARY=col(source(s), name("#SUMMARY")) DATA: INDEX=col(source(s), name("#INDEX"), unit.category()) GUIDE: axis(dim(1), label("Time")) GUIDE: axis(dim(2), label("Value")) GUIDE: legend(aesthetic(aesthetic.color.interior), label("")) GUIDE: text.title(label("Plot of Four Time Series")) SCALE: linear(dim(2), include(0)) SCALE: cat(aesthetic(aesthetic.color.interior), include( "0", "1", "2", "3")) ELEMENT: line(position(Time*SUMMARY), color.interior(INDEX), missing.wings()) END GPL. Okay, now you can tell me that I completely misunderstood what your data looks like! ;-)
--
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/). |
Administrator
|
PS- Add variable labels to see the labels you mentioned in the legend of the multi-line plot.
VARIABLE LABELS F1 "Actual Data" F2 "Exponential Smoothing Data" F3 "ARIMA Data" F4 "Bayesian_Data" .
--
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/). |
Free forum by Nabble | Edit this page |