Professional Documents
Culture Documents
knitr::include_graphics("6_2.PNG")
Required data
### Patients whowere given 6-mercaptopurine
### The time for 6-MP and the placebo time were given in weeks
MP <- c(6,6,6,6,7,9,10,10,11,13,16,17,19,20,22,23,25,32,32,34,35)
cens1 <- c(1,1,1,0,1,0,1,0,0,1,1,0,0,0,1,1,0,0,0,0,0)
### Converting the given times to months by dividing the number of weeks/4.34
5
### Joining the MP and placebo censored data in the same vector
Comparation Chart
plot(km.model, conf.int=F,col=c("red", "blue"), xlab = "Remission time (in mo
nths)", ylab = "S(t)", main="Comparing the survival time for the 2 groups", m
ark.time = TRUE, lwd = 2, las=1)
legend("topright", legend=c("6-MP","Placebo"), lty = 1, lwd = 2, col=c("blue"
, "red"), bty="n")
knitr::include_graphics("6_2_a.PNG")
From the analysis of the graphs, it can be seen that the time for the treatment group
administered the 6-MP steroid to enter remission is longer than that of the patients
administered the placebo. We can also see that the survival function for the treatment
group is above that of the placebo group, clearly indicating that the efficacy of the 6-MP
steroid, of course this is not the case at all times and the survival function for both groups is
maintained at 100%, until the first week where both graphs are far apart, corroborating the
effectiveness of the treatment because the risk of entering remission is lower.
knitr::include_graphics("6_2_b.PNG")
Using
the graphs for both groups we can estimate that the probability of survival, i.e. not entering
remission after 3 months, for the treatment group is about 70%, while for the placebo
group it is about 20%.
knitr::include_graphics("6_2_c.PNG")
summary(km.model)
Using the summary function on the kaplan-maier model, to calculate the estimated value of
the survival function beyond 3 months, we have that for the group to which the treatment
was administered it was 69%, while for the placebo group it was 19.05%.
knitr::include_graphics("6_3.PNG")
To fill in the values of the PL- estimator for 6-MP group, we will use definition 6.3 to
manually calculate the values as shown below.
### Turning data into a DF
Manual calculation
knitr::include_graphics("6_3R.png")
To verify the calculations performed we will calculate the KM estimator on the training
group data only.
km.modelMP <- survfit(Surv(MP,cens1)~ 1)
summary(km.modelMP)
As we can see the summary function shows that the manually calculated data match the
data generated by the software.
knitr::include_graphics("6_6.PNG")
Required data
## Stanford Heart Transplat Data
## Reading data
i <- order(heart$Days)
heart <- heart[i,]
head(heart)
PL- Estimator
km.modelH <- survfit(Surv(heart$Days,heart$Cens)~1)
st <-km.modelH$surv
tekm <- km.modelH$time
inv_Phi <- qnorm(st)
Graficando probabilidad
plot(km.modelH, conf.int=T, xlab = "Time (Days)", ylab="% Alive = S(t)", main
="KM-Model for Heart Transplat Patients")
summary(km.modelH)
knitr::include_graphics("6_6_1.PNG")
Using the summary function, it is estimated that the probability that the patient will live for
more than one year after transplantation is approximately 43%, with a estimate standard
error of 0.0620
knitr::include_graphics("6_6_2.PNG")
The probability of survival after 6 to the next 6 months after heart transplantation
decreases based on the model calculated in this way and the probability of survival
between months 7 to 12 is given respectively by the following:
### Calculating the survival probability between the months 7 to 12
## month St
## 1 7 0.5158837
## 2 8 0.4997623
## 3 9 0.4831036
## 4 10 0.4497861
## 5 11 0.4324866
## 6 12 0.4324866