rms
rms copied to clipboard
contrast.rms collapses small p-values to zero
The function contrast.rms
reports the p-values for all Wald statistics absolutely larger than ca. 9 as an exact zero.
Example adapted from the contrast.rms
help page with Z=10.36:
set.seed(1)
x = rnorm(500)
xb = 1+2*x
y = ifelse(runif(500) <= plogis(xb), 1, 0)
f = lrm(y ~ x)
ct = contrast(f, list(x=1))
ct
ct$P==0 ## Exact zero
The problem seems to be the line below in contrast.s
where the p-value is calculated:
P <- if(length(idf)) 2 * (1 - pt(abs(Z), idf)) else 2 * (1 - pnorm(abs(Z)))
Replacing this with
P <- if(length(idf)) 2 * (1 - pt(abs(Z), idf)) else 2 * pnorm(-abs(Z))
should do the trick.
rms 4.3-1
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 2.2
year 2015
month 08
day 14
svn rev 69053
language R
version.string R version 3.2.2 (2015-08-14)
nickname Fire Safety
To be consistent should that not be
|P <- if(length(idf)) 2 * pt(-abs(Z), idf)) else 2 * pnorm(-abs(Z)) |
On 09/30/2015 11:48 AM, Alexander Ploner wrote:
The function |contrast.rms| reports the p-values for all Wald statistics absolutely larger than ca. 9 as an exact zero.
Example adapted from the |contrast.rms| help page with Z=10.36:
|set.seed(1) x = rnorm(500) xb = 1+2*x y = ifelse(runif(500) <= plogis(xb), 1, 0) f = lrm(y ~ x) ct = contrast(f, list(x=1)) ct ct$P==0 ## Exact zero |
The problem seems to be the line below in |contrast.s| where the p-value is calculated:
|P <- if(length(idf)) 2 * (1 - pt(abs(Z), idf)) else 2 * (1 - pnorm(abs(Z))) |
Replacing this with
|P <- if(length(idf)) 2 * (1 - pt(abs(Z), idf)) else 2 * pnorm(-abs(Z)) |
should do the trick.
|rms 4.3-1 _ platform x86_64-w64-mingw32 arch x86_64 os mingw32 system x86_64, mingw32 status major 3 minor 2.2 year 2015 month 08 day 14 svn rev 69053 language R version.string R version 3.2.2 (2015-08-14) nickname Fire Safety |
— Reply to this email directly or view it on GitHub https://github.com/harrelfe/rms/issues/13.
Frank E Harrell Jr Professor and Chairman School of Medicine
Department of *Biostatistics* *Vanderbilt University*
Of course! Sorry, completely blinded to dfs :) /alexander
On 2015-09-30 19:16, Frank Harrell wrote:
To be consistent should that not be
|P <- if(length(idf)) 2 * pt(-abs(Z), idf)) else 2 * pnorm(-abs(Z)) |
On 09/30/2015 11:48 AM, Alexander Ploner wrote:
The function |contrast.rms| reports the p-values for all Wald statistics absolutely larger than ca. 9 as an exact zero.
Example adapted from the |contrast.rms| help page with Z=10.36:
|set.seed(1) x = rnorm(500) xb = 1+2*x y = ifelse(runif(500) <= plogis(xb), 1, 0) f = lrm(y ~ x) ct = contrast(f, list(x=1)) ct ct$P==0 ## Exact zero |
The problem seems to be the line below in |contrast.s| where the p-value is calculated:
|P <- if(length(idf)) 2 * (1 - pt(abs(Z), idf)) else 2 * (1 - pnorm(abs(Z))) |
Replacing this with
|P <- if(length(idf)) 2 * (1 - pt(abs(Z), idf)) else 2 * pnorm(-abs(Z)) |
should do the trick.
|rms 4.3-1 _ platform x86_64-w64-mingw32 arch x86_64 os mingw32 system x86_64, mingw32 status major 3 minor 2.2 year 2015 month 08 day 14 svn rev 69053 language R version.string R version 3.2.2 (2015-08-14) nickname Fire Safety |
— Reply to this email directly or view it on GitHub https://github.com/harrelfe/rms/issues/13.
Frank E Harrell Jr Professor and Chairman School of Medicine
Department of Biostatistics Vanderbilt University
— Reply to this email directly or view it on GitHub https://github.com/harrelfe/rms/issues/13#issuecomment-144480857.
Alexander Ploner Medical Epidemiology & Biostatistics Karolinska Institutet http://ki.se/meb