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
- 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.
- 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
- Start S-PLUS 6.1
- Specify the Working Chapter.
- Menu Bar: File ® Chapters ® New Working Chapter...
- New Working Chapter Dialog Box: Input “H:\Bios242” as the Chapter Folder and “Bios242” as the Label.
- Click OK.
- Open the Object Explorer if it is not already visible.
- 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.
- Verify that S-PLUS will create editable graphics.
- Menu Bar: Options ® Graph Options...
- Graphs Dialog Box: On the Options tab check the two Create Editable Graphs options.
- Click OK.
Data
- Import the data from the ASCII file freireich.txt.
- Menu Bar: File ® Import Data ® From File...
- 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.‡
- 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
- Generate Kaplan-Meier estimates of the survival function.
- Menu Bar: Statistics ® Survival ® Nonparametric Survival...
- Nonparametric Survival Dialog Box: Set Data Set = freireich; click Create Formula.
- 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.
- 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”.
- Click Apply.
- Add the confidence intervals from Greenwood’s formula.
- 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.
- Click Apply.
- Add the confidence intervals from the Kalpfleisch and Prentice formula.
- Nonparametric Survival Dialog Box: Go to the Options tab and set Confidence Interval Type = log-log.
- Click OK.
Smooth Hazard and Survival Curves
- Open the HazardEst.ssc file.
- Menu Bar: File ® Open...
- Open Dialog Box: Select the file to open.
- 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.
- Submit the code.
- Click the forward triangle button on the toolbar or press F10. A graph window with two plots should result.
- Copy-and-paste the two hazard function into a single plot.
- Menu Bar: File ® New... (Graph Sheet)
- Copy the graph sheet page from the first hazard plot. Paste to the newly created graph sheet.
- Select and copy the second hazard curve. Select the newly created plot region and then paste the curve.
- Edit the y-axis so that both curves are displayed.
- Add a legend to the plot.
- Select the plot region in which to add the legend.
- Menu Bar: Insert ® Legend...
- Legend Menu Box: Click OK.
- 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