[R] mChoice prb in rms

moleps moleps2 at gmail.com
Thu Jun 2 15:02:23 CEST 2011


Dear all,
I´m trying to get a output table for age and the summary of a and b, stratified by epo as follows using summary.formula 

h<-data.frame(a=sample(c("A",NA),100,replace=T),b=sample(c("B",NA),100,replace=T),age=rnorm(100,50,25),epo=sample(c("Y","N"),100,T))

library(rms)

summary.formula(epo~age+mChoice(a,b,label="test"),method="reverse",data=h,na.rm=TRUE,test=T)



Descriptive Statistics by epo

+---------+-------------------+-------------------+------------------------+
|         |N                  |Y                  |  Test                  |
|         |(N=51)             |(N=49)             |Statistic               |
+---------+-------------------+-------------------+------------------------+
|age      |     43.8/53.5/74.6|     30.8/48.8/69.3|F=1.68 d.f.=1,98 P=0.198|
+---------+-------------------+-------------------+------------------------+
|test : NA|         0% (0)    |         0% (0)    |                        |
+---------+-------------------+-------------------+------------------------+
|    A    |         0% (0)    |         0% (0)    |                        |
+---------+-------------------+-------------------+------------------------+
|    B    |         0% (0)    |         0% (0)    |                        |
+---------+-------------------+-------------------+------------------------+


Digging deeper I find that

>summary(mChoice(h$a,h$b))
h$a   4 unique combinations
Frequencies of Numbers of Choices Per Observation

nchoices
 1  2 
30 70 

Pairwise Frequencies (Diagonal Contains Marginal Frequencies)
<0 x 0 matrix>

 Frequencies of All Combinations 

  NA  A;B NA;A NA;B 
  30   24   23   23 


Somehow this doesnt carry over into the summary.formula output...

Also, running example(mChoice) reproduces this whereby the 0% categories are also shown.

Any ideas?

//M



More information about the R-help mailing list