It doesn't look right. If you want to limit the analysis to just males or females, the sex==1
or sex==2
is a separate input, the subset
clause. The new commands would be
Males<-survdiff(surv(time,Status)~Patients, data = myeloma, sex==1)
Females<-survdiff(surv(time,Status)~Patients, data = myeloma, sex==2)
You need to specify something as the dependent variable in the equation, and the only remaing variable is Patients.
If you actually want to measure the effects of both sex and age together on survival, you need to be doing a stratified log rank test. I've used the function SurvTest
(in documentation)/surv_test from the coin
package.
As far as I could tell, it only takes one stratifying variable, but I came up with a workaround by appending several variables into a new variable and using that as the stratifying variable.
There are a couple of other packages that can do the same thing, but I can't think of them right now.
survdiff
function fromsurvival
? $\endgroup$