I am trying to test the hypothesis that there is no difference in survival between the four groups in the data (kidney), reported on the death times of 863 kidney transplant patients. Where patients can be classified by race and sex into one of four groups.
I am using the code:
library(KMsurv)
data(kidney)
kidney
head(kidney)
str(kidney)
group<- rep(NA, dim(kidney)[1])
group[ kidney$gender==1 & kidney$race==1 ] <- 1
group[ kidney$gender==1 & kidney$race==2 ] <- 2
group[ kidney$gender==2 & kidney$race==1 ] <- 3
group[ kidney$gender==2 & kidney$race==2 ] <- 4
library(survival)
survdiff(Surv(obstime, death)~group, data=kidney)
survdiff(Surv(obstime, death)~race, data=kidney, subset=gender==1)
survdiff(Surv(obstime, death)~race, data=kidney, subset=gender==2)
survdiff(Surv(obstime, death)~race+strata(gender), data=kidney)
but I have not got the data of 863 kidney transplant patients, I got only 119 observation. Is there a mistake in the code I'm using? I'm unable to get any results since I could not get the whole data.
I have tried this code to obtain the data, but I am still having the same issue:
getwd()
kidney<- read.csv("kidneytransplant.csv")
head(Kidney)
str(Kidney)