ASA Connect

 View Only
  • 1.  Parallel Line Graph

    Posted 12-22-2014 12:21
    Does anyone know how to do a parallel line graph in either SAS or R? I have a request from a journal to do a parallel line graph to illustrate individual patient trends over time for pain relief but as far as I can see, it is only available in STATA which I don't have access to.
    Thanks all,
    Peter
    -------------------------------------------
    Peter Homel PhD
    Senior Biostatistician
    Maimonides Medical Center
    Brooklyn, NY 11219
    -------------------------------------------


  • 2.  RE: Parallel Line Graph

    Posted 12-23-2014 00:42
    Peter,

    For SAS:   take a look at SGPANEL which produces a "panel" of several plots, of which a scatterplot is an example.
    Aside from the actual manual, a good starting point is the following paper by Chuck Kincaid
    http://support.sas.com/resources/papers/proceedings10/234-2010.pdf

    For R: you can combine multiple plots using either the  par( ) or layout( ) function.

    With the par( ) function, you can include the option
            mfrow=c(
    nrows, ncols) to create a matrix of nrows x ncols plots that are filled in by row.
    or     mfcol=c(nrows, ncols)  to fill in the matrix by columns.

    The layout( ) function has the form layout(mat) where
    mat is a matrix object specifying the location of the N figures to plot.


    -------------------------------------------
    Mark Miller
    Senior Technology Analyst (Retired)
    Syracuse University
    -------------------------------------------




  • 3.  RE: Parallel Line Graph

    Posted 12-23-2014 07:24
    If you are referring to a "parallel coordinates" graph, here are a few explanations (and some example code) of how to do it in R.

    https://blog.safaribooksonline.com/2014/03/31/mastering-parallel-coordinate-charts-r/

    http://rcharts.io/parcoords/

    -------------------------------------------
    Scott Nestler
    -------------------------------------------




  • 4.  RE: Parallel Line Graph

    Posted 12-23-2014 08:15





  • 5.  RE: Parallel Line Graph

    Posted 12-23-2014 08:49
    What do you mean by a "parallel line graph"?  Are you talking about a graph in which a separate line is presented for each patient over time?  If so, use proc SGPLOT in SAS.  It would go something like this:

    ODS RTF FILE='INSERT FILE PATH HERE\trends.rtf';

    PROC SGPLOT DATA= DATASET_NAME;
        SERIES X= TIME Y= RESPONSE / GROUP=PATIENT MARKERS;
    RUN;

    ods rtf close;

    If you need to control the line colors, shape or size of the data points, axis scale, etc., the proc SGPLOT documentation is very user-friendly.

    -------------------------------------------
    Julie Brevard
    Director of Statistics
    Idera Pharmaceuticals
    -------------------------------------------




  • 6.  RE: Parallel Line Graph

    Posted 12-23-2014 10:05
    R package MASS has a function parcoord to do parallel coordinates plots.  If you have access to SAS's JMP, parallel coordinates plots are easily created interactively.

    -------------------------------------------
    Charles Coleman
    -------------------------------------------




  • 7.  RE: Parallel Line Graph

    Posted 12-23-2014 11:11
    If what you mean is a longitudinal "spaghetti plot" with a separate line for each person, I get such things via SAS as below.  Adapt as needed.  See online SAS Graph documentation, especially Proc GPlot.    

    goptions dev=png   ftext='Arial'  hby=2  htext=1.75  gsfname=grafout nofileonly  hsize= 8 in  vsize=5 in
          
    RESET=SYMBOL ;
        
    filename grafout  ' path to directory goes here ' ;     

    proc sort nodupkey ; by BaseDx SubjIDShort DateVst ;    

    proc gplot  uniform ;
       
    by BaseDx ;  

      plot   DepVar * Yr_in_Study = SubjIDShort   / hminor=0  vminor=0  nolegend 
               
    haxis= -0.5 to 4.5 by 0.5  vaxis= 0.5 to 4.5 by 0.5 ;  

      symbol  value=circle  width=1.75   interpol=join   height=3  repeat=5000 ; 

      label  Yr_in_Study = 'Year in the Study'  ;    

      title; 
     
    footnote;     


    -------------------------------------------
    Joseph Locascio
    -------------------------------------------