0

I'm currently working with a Cox regression model and the p-value generated for some of the variables are extremely small, automatically rounding to 0. Is there a way to extract the true p-value?

Edit: So I've included an example below. Since I'm using a subset of the data, the p-value is no longer rounding to 0. I've tried applying a logarithm as well as increasing digits to print but I believe the value is already rounded so when I apply these functions, the value calculated ends up being Inf.

structure(list(ID = 1:40, out = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), time = c(3207L, 3215L, 3549L, 
4495L, 4489L, 4461L, 4460L, 4433L, 4459L, 4447L, 4441L, 4452L, 
4445L, 4427L, 4426L, 4429L, 4433L, 1928L, 4452L, 4464L, 4397L, 
4377L, 4388L, 4320L, 4311L, 3814L, 4317L, 2743L, 3476L, 4485L, 
4348L, 4299L, 3718L, 4320L, 4321L, 4319L, 3733L, 3714L, 3705L, 
3701L), V1 = c(-0.264536029, -0.115092615501491, 0.147808368, 
0.33603814, -1.439531471, -1.568919632, 0.18001237, -0.041789298, 
-0.035816632, -0.066011812, 1.15034938, -0.107634392, -0.115092615501491, 
0.812217801, 0.967421566, 0.948535041, -1.644853627, -0.652178986, 
-0.340694827, 0.253347103, 0.841621234, -0.565948822, -0.18001237, 
0.407918741, -0.115092615501491, 0.783500375, 0.727913291, 1.110771617, 
0.167894005, -0.572967548, -0.020890088, -1.367627923, -0.115092615501491, 
-0.500580105, -1.072861342, -0.967421566, 0.477040428, -0.430727299, 
0.597760126, -1.003147968), Iden = c(TRUE, TRUE, TRUE, TRUE, 
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 
TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 
TRUE, TRUE, TRUE, TRUE)), row.names = c(2L, 4L, 6L, 10L, 11L, 
13L, 15L, 16L, 17L, 19L, 22L, 25L, 26L, 30L, 31L, 32L, 36L, 38L, 
39L, 41L, 42L, 44L, 47L, 79L, 81L, 82L, 83L, 85L, 88L, 90L, 93L, 
94L, 99L, 101L, 102L, 104L, 105L, 106L, 108L, 109L), class = "data.frame")

Here is the code I used to build the model.

cch(Surv(time, out) ~ V1, data = data, 
    subcoh = ~Iden, id = ~ID, 
    cohort.size = 100000, method = "SelfPren")
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
ASW
  • 29
  • 5
  • 2
    it may be a printing issue. – akrun Jul 14 '20 at 22:31
  • 1
    `options(scipen=999)` could help! – Duck Jul 14 '20 at 22:32
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jul 14 '20 at 22:39
  • Okay, let me add that right now! – ASW Jul 14 '20 at 22:43
  • I just added an example! Thanks so much for your help :) – ASW Jul 14 '20 at 22:57
  • @ASW what is the value you are getting from this example – akrun Jul 14 '20 at 23:02
  • 0.28. Unfortunately, I'm not sure how I can create a reproducible example with a pval of 0 without using the entire dataset. I've tried your solution of using print but I'm limited at approx. 20 digits. Is there a way to extend this? – ASW Jul 14 '20 at 23:06

2 Answers2

2

I'm extracting the code from print.cch. If x is your model:

coef <- coef(x)
se <- sqrt(diag(vcov(x)))
Z <- abs(coef/se)
log_p <- pnorm(Z, log.p=TRUE)

That should give you the (natural) log of the p-value. If log(p) is less than about -708, you won't be able to convert it back to the raw scale without underflowing to zero: this answer could be adapted to get you the answer in (mantissa)*10^(exponent) format ...

Note that the original code uses pnorm() without log.p=TRUE, probably because the authors didn't worry about the possibility that people would want p-values that were in danger of underflowing to zero (i.e., log(p)<(-708) or p<.Machine$double.xmin (approx 2e-308). (Outside of bioinformatics, I'm not aware of anyone who cares about p-values that small ...)

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
1

We can use print with digits

print(coef(summary(model1))[, "p"], digits = 16)
#               p 
#0.2807147760863391 
akrun
  • 874,273
  • 37
  • 540
  • 662