Statistical Methods in Epidemiology IIComputer Lab 2

Friday, January 31, 2003

Files

The data set from the Leukemia Clinical Trial will be used for this week’s lab. The data are located in the handouts section of the course website at www.public-health.uiowa.edu/bsmith/Bios242.

Data

  1. Download† the following files to your H:\Bios242 class directory:

·  Leukemia Clinical Trial Data – freireich.txt

·  S-PLUS muhaz library – muhaz.zip

·  S-PLUS Program for smooth hazard curve estimation – HazardEst.ssc

† To download files from the class website, right click on the associated hyperlink and select the Save Target As option.

  1. Use WinZip to extract the archived files in muhaz.zip to your class directory. The files will be save to a subdirectory named “muhaz” which is created automatically during the extraction.

S-PLUS

Setup
  1. Start S-PLUS 6.1
  1. Specify the Working Chapter.
  2. Menu Bar: File ® Chapters ® New Working Chapter...
  3. New Working Chapter Dialog Box: Input “H:\Bios242” as the Chapter Folder and “Bios242” as the Label.
  4. Click OK.
  1. Open the Object Explorer if it is not already visible.
  1. Attach a new chapter in the second position of the SearchPath folder. Link the new chapter to your muhaz directory. This will make available the functions needed to generate smooth estimates of the hazard function.
  1. Verify that S-PLUS will create editable graphics.
  1. Menu Bar: Options ® Graph Options...
  2. Graphs Dialog Box: On the Options tab check the two Create Editable Graphs options.
  3. Click OK.
Data
  1. Import the data from the ASCII file freireich.txt.
  2. Menu Bar: File ® Import Data ® From File...
  3. Import From File Dialog Box: Click on Browse and select the file to import; set To Data set = “freireich”.† Go to the Options tab and select “Single TAB character (\t)” as the Delimiter.‡
  4. Click OK.

† Note that S-PLUS is case-sensitive. The lab instructions that follow assume that the name of the imported data set is in lower-case.

‡ freireich.txt is a tab-delimited file. The default in S-PLUS for ASCII files is to skip to the next column upon encountering white space or a tab. This would be undesirable if, say, the names of your treatment groups contained spaces. Thus, it is safer to separate data by a single tab rather than with spaces.

Kaplan-Meier Curves
  1. Generate Kaplan-Meier estimates of the survival function.
  2. Menu Bar: Statistics ® Survival ® Nonparametric Survival...
  3. Nonparametric Survival Dialog Box: Set Data Set = freireich; click Create Formula.
  4. Formula Dialog Box: Select “time” and click Time 1; select “event” and click Censor Codes; click Add Response. Select “group” and click Main Effect (+). If the Formula reads “Surv(time,event,type=’right’)~group” then click OK.
  5. Nonparametric Survival Dialog Box: Go to the Results tab and have both Short Output and Long Output specified. Go to the Plot tab; uncheck the Show Confidence Intervals option and set Line Types = “1, 4”.
  6. Click Apply.
  1. Add the confidence intervals from Greenwood’s formula.
  2. Nonparametric Survival Dialog Box: Go to the Plot tab and check the Show Confidence Intervals option. Go to the Options tab and set Confidence Interval Type = plain.
  3. Click Apply.
  1. Add the confidence intervals from the Kalpfleisch and Prentice formula.
  2. Nonparametric Survival Dialog Box: Go to the Options tab and set Confidence Interval Type = log-log.
  3. Click OK.
Smooth Hazard and Survival Curves
  1. Open the HazardEst.ssc file.
  1. Menu Bar: File ® Open...
  2. Open Dialog Box: Select the file to open.
  3. Click OK.

HazardEst.ssc is a text file with S-PLUS code to estimate and plot smooth hazard curves for the freireich data. The opened file will be displayed in a script window. The script window allows you to edit and submit a batch of S-PLUS commands, much like the Program Editor in SAS.

  1. Submit the code.
  2. Click the forward triangle button on the toolbar or press F10. A graph window with two plots should result.
  1. Copy-and-paste the two hazard function into a single plot.
  2. Menu Bar: File ® New... (Graph Sheet)
  3. Copy the graph sheet page from the first hazard plot. Paste to the newly created graph sheet.
  4. Select and copy the second hazard curve. Select the newly created plot region and then paste the curve.
  5. Edit the y-axis so that both curves are displayed.
  1. Add a legend to the plot.
  2. Select the plot region in which to add the legend.
  3. Menu Bar: Insert ® Legend...
  4. Legend Menu Box: Click OK.
  5. Use the mouse to edit (double-click) and position the legend.

Log Off

It is important that you log off of the computer when finished. Otherwise, the next person to use the computer will have access to your personal files. To log off, go to the Start menu in Windows and select Shut Down ® Log off.

2 of 3