0% found this document useful (0 votes)
72 views1 page

MA251 Computer Assessment: "Survival Analysis" Answer Key: The Saylor Foundation Page 1 of 1

This document provides R code to analyze survival data from a study of patients with Acute Myelogenous Leukemia. The code loads the aml dataset, uses the Kaplan-Meier estimator to estimate survival distributions for patients who received additional chemotherapy cycles (maintained) versus those who did not (nonmaintained), performs a log-rank test to compare the survival curves between the two groups, conducts an exponential regression and Cox proportional hazards regression on the data, and obtains the baseline hazard rate from the Cox model.

Uploaded by

thermopolis3012
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views1 page

MA251 Computer Assessment: "Survival Analysis" Answer Key: The Saylor Foundation Page 1 of 1

This document provides R code to analyze survival data from a study of patients with Acute Myelogenous Leukemia. The code loads the aml dataset, uses the Kaplan-Meier estimator to estimate survival distributions for patients who received additional chemotherapy cycles (maintained) versus those who did not (nonmaintained), performs a log-rank test to compare the survival curves between the two groups, conducts an exponential regression and Cox proportional hazards regression on the data, and obtains the baseline hazard rate from the Cox model.

Uploaded by

thermopolis3012
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Saylor URL: www.saylor.org/MA251 Subunit 6.

3

The Saylor Foundation Saylor.org
Page 1 of 1



MA251
Computer Assessment: Survival Analysis
Answer Key

Instructions: The solution to Task 2 of the assessment is provided in the R code below.
Copy and paste the code to the R command window.

# Task 2: Load the dataset aml, which provides data on survival in patients with Acute
Myelogenous Leukemia.

# Use the Kaplan-Meier estimator to estimate the distributions of lifetimes for patients
who received additional chemotherapy cycles (maintained) and those who did not
(nonmaintained).

#Loading data
library(survival)
data(aml)
attach(aml)
aml

#Use survfit() to construct the K-M estimate for survival time.
# x contains the information on chemotherapy: Maintained versus Nonmaintained
KMfit <- survfit(Surv(time,status)~x)

# Plot the KM fit
plot(KMfit, lty = 2:3)
legend(100, .9, c("Maintenance", "No Maintenance"), lty = 2:3)
title("Kaplan-Meier Curves\nfor AML Maintenance Study")

#Perform a two-sample log-rank test to see whether the survival curves are different for
the two groups of patients.
survdiff(Surv(time, status)~x, data=aml)

#Conduct an exponential regression for the survival data.
survreg(Surv(time, status)~x, dist="exponential")

#Fit a Cox proportional hazard to the data.]
Coxfit <- coxph(Surv(time, status)~x)
summary(Coxfit)
#Obtain the baseline hazard rate
basehaz(Coxfit)

You might also like