2008/7/25 Frank E Harrell Jr <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
David Hajage wrote:
Hello R users,
I have several problems with the functions summary.formula and
latex in
package Hmisc. Here an example :
####
library(Hmisc)
sex <- factor(sample(c("m","f", "?"), 50, rep=TRUE))
age <- rnorm(50, 50, 5)
treatment <- factor(sample(c("Drug","Placebo"), 50, rep=TRUE))
symp <- c('Headache','Stomach Ache','Hangnail',
'Muscle Ache','Depressed')
symptom1 <- sample(symp, 50,TRUE)
symptom2 <- sample(symp, 50,TRUE)
symptom3 <- sample(symp, 50,TRUE)
Symptoms <- mChoice(symptom1, symptom2, symptom3, label='Primary
Symptoms')
f <- summary(treatment ~ age + sex + Symptoms, method="reverse",
test=TRUE)
print(f, digits = 5, pdig = 2, pctdig = 3, eps = 0.5, prmsd = F)
print(f, digits = 5, pdig = 2, pctdig = 3, eps = 0.5, prmsd = T)
latex(f, long = T, pdig = 2, pctdig = 3, eps = 0.5, prmsd = F,
file = "")
###
Here the problems :
- The first print(f, ...) doesn't replace all p-value <0.5 by
"P<0.5" :
+----------------------------+-------------------------+-------------------------+-----------------------------+
| |Drug
|Placebo | Test |
| |(N=31)
|(N=19) |Statistic |
+----------------------------+-------------------------+-------------------------+-----------------------------+
|age | 45.926/48.750/54.019|
47.344/50.728/53.696| F=0.9 d.f.=1,48 P<0.5 |
+----------------------------+-------------------------+-------------------------+-----------------------------+
|sex : ? | 25.806% ( 8) |
26.316% (
5) | Chi-square=0.3 d.f.=2 P=0.86|
+----------------------------+-------------------------+-------------------------+-----------------------------+
| f | 38.710% (12) |
31.579% (
6) | |
+----------------------------+-------------------------+-------------------------+-----------------------------+
| m | 35.484% (11) |
42.105% (
8) | |
+----------------------------+-------------------------+-------------------------+-----------------------------+
|Primary Symptoms : Depressed| 41.935% (13) |
63.158%
(12) | Chi-square=2.12 d.f.=1 P<0.5|
+----------------------------+-------------------------+-------------------------+-----------------------------+
| Hangnail | 48.387% (15) |
42.105% (
8) |Chi-square=0.19 d.f.=1 P=0.67|
+----------------------------+-------------------------+-------------------------+-----------------------------+
| Stomach Ache | 45.161% (14) |
68.421%
(13) | Chi-square=2.57 d.f.=1 P<0.5|
+----------------------------+-------------------------+-------------------------+-----------------------------+
| Muscle Ache | 54.839% (17) |
26.316% (
5) | Chi-square=3.89 d.f.=1 P<0.5|
+----------------------------+-------------------------+-------------------------+-----------------------------+
| Headache | 51.613% (16) |
36.842% (
7) | Chi-square=1.03 d.f.=1 P<0.5|
+----------------------------+-------------------------+-------------------------+-----------------------------+
I did not see an instance of P < 0.5 that was not replaced by
"P<0.5". This is an unusual cutoff, and you are printing many more
digits of precision than offered by the data.
For example 'Hangnail', p-value is printed as 'P=0.67' instead of
'P<0.5'. I know this is an unusual cutoff, I don't remember why I chose
that for this example...