Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in ggsurvplot when log-rank weight specified for some data sets #191

Closed
kassambara opened this issue Apr 7, 2017 · 2 comments
Closed

Comments

@kassambara
Copy link
Owner

The following example from the vignette (http://www.sthda.com/english/rpkgs/survminer/articles/Specifiying_weights_in_log-rank_comparisons.html) works:

library("survival")
library(survminer)
data("kidney", package="KMsurv")
fit1 <- survfit(Surv(time=time, event=delta) ~ type, data=kidney)
ggsurvplot(fit1, data = kidney, pval = TRUE, log.rank.weights = "S1")

P-values from survMisc

library(survMisc)
tenfit <- ten(Surv(time=time, event=delta) ~ type, data=kidney)
capture.output(comp(tenfit)) -> null_dev
attributes(tenfit)$lrt -> tests
tests
                     Q         Var         Z     pNorm   
1             -3.96355     6.23675 -1.587104 0.1124892   
n              9.00000 38919.18761  0.045621 0.9636127   
sqrtN        -13.20293   433.84450 -0.633875 0.5261626   
S1            -2.46920     4.37254 -1.180837 0.2376674   
S2            -2.31343     4.20869 -1.127672 0.2594583   
FH_p=1_q=1    -1.02064     0.10661 -3.125846 0.0017729 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Observation: The pNorm column is present

But, the example below, using another dataset, doesn't work:

library(survival)
library(survminer)
data("larynx", package="KMsurv")
fit2 <- survfit(Surv(time, delta) ~ stage, data=larynx)
ggsurvplot(fit2, data = larynx, log.rank.weights = "S1", pval = TRUE)

Error message:

Error in round(tests$pNorm[tests$W == method], 4) : 
  argument non numérique pour une fonction mathématique

P-values from survMisc

library(survMisc)
tenfit <- ten(Surv(time, delta) ~ stage, data=larynx)
capture.output(comp(tenfit)) -> null_dev
attributes(tenfit)$lrt -> tests
tests
           chiSq df     pChisq    
1          22.763  3 4.5252e-05 ***
n          23.177  3 3.7093e-05 ***
sqrtN      23.141  3 3.7746e-05 ***
S1         23.171  3 3.7199e-05 ***
S2         23.170  3 3.7213e-05 ***
FH_p=1_q=1 16.661  3 0.00082967 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Observation: The pNorm column is not present

@kassambara
Copy link
Owner Author

We should update the surv_pvalue() function.

I'm working on this...
We should update the surv_pvalue() function.

I'm working on this...

kassambara added a commit that referenced this issue May 2, 2017
@kassambara
Copy link
Owner Author

fixed now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant