[R] summary.formula: method reverse does not use fun argument
Frank E Harrell Jr
fharrell at virginia.edu
Fri Apr 11 20:00:10 CEST 2003
Thanks also to Thomas Lumley for his reply concerning summary.formula in the Hmisc package. See below for some more notes. -FH
On Fri, 11 Apr 2003 10:25:41 +0200
Thomas Gerds <gerds at fdm.uni-freiburg.de> wrote:
> hi,
>
> recently i discovered the functionability summary.formula, awesome!
> from the help page i understand that method=reverse allows to
> summarize all variables on the right hand side of formula
> (the help page on line 229 wrongly refers to the left? hand side variables)
> in categories which are determined by a single left hand side
> variable.
Sorry about the typo. You are correct, that should have been "right hand side variables".
>
> my problem is that the argument fun seems not to be compatible with
> method=reverse!? every continuous variable is summarized in three
> quantiles.
As stated in the documentation, fun applies only to method='response' and method='cross'.
>
> here is an example:
>
> hist is a factor, PET and CT are "numeric"
>
> summary(PET~hist,data=her,fun=sum)
> PET N=47
>
> +-------+------------------+--+---+
> | | |N |PET|
> +-------+------------------+--+---+
> |hist |Morbus Hodgkin |18| 81|
> | |Niedrigmaligne NHL|11| 39|
> | |Hochmaligne NHL |18| 49|
> +-------+------------------+--+---+
> |Overall| |47|169|
> +-------+------------------+--+---+
>
> > summary(CT~hist,data=her,fun=sum)
> CT N=47
>
> +-------+------------------+--+---+
> | | |N |CT |
> +-------+------------------+--+---+
> |hist |Morbus Hodgkin |18| 70|
> | |Niedrigmaligne NHL|11| 16|
> | |Hochmaligne NHL |18| 32|
> +-------+------------------+--+---+
> |Overall| |47|118|
> +-------+------------------+--+---+
>
> it would be desirable to combine both tables such that there is one
> column for PET and one for CT ... is this possible?
Yes, see the documentation. Create a bivariate response variable with cbind and use a bivariate summarization function as 'fun'. And note that using 'stratify(someothervariable)' you can create multiple groups across columns as with method='reverse'; you just can't get statistical tests for them with method='response'.
Frank Harrell
>
> trying method=reverse gives:
>
> summary(hist~PET+CT,data=her,fun=sum,method="reverse")
>
> Descriptive Statistics by hist
>
> +------+---------------+-------------------+----------------+
> | |Morbus Hodgkin |Niedrigmaligne NHL |Hochmaligne NHL |
> | |(N=18) |(N=11) |(N=18) |
> +------+---------------+-------------------+----------------+
> |PET |3.00/3.50/6.75 |1.50/3.00/6.00 |1.00/2.00/3.75 |
> +------+---------------+-------------------+----------------+
> |CT : 0| 0% (0) | 36% (4) | 28% (5) |
> +------+---------------+-------------------+----------------+
> | 1 | 11% (2) | 9% (1) | 28% (5) |
> +------+---------------+-------------------+----------------+
> | 2 | 28% (5) | 36% (4) | 11% (2) |
> +------+---------------+-------------------+----------------+
> | 3 | 17% (3) | 9% (1) | 11% (2) |
> +------+---------------+-------------------+----------------+
> | 4 | 11% (2) | 9% (1) | 17% (3) |
> +------+---------------+-------------------+----------------+
> | 5 | 6% (1) | 0% (0) | 6% (1) |
> +------+---------------+-------------------+----------------+
> | 6 | 6% (1) | 0% (0) | 0% (0) |
> +------+---------------+-------------------+----------------+
> | 7 | 11% (2) | 0% (0) | 0% (0) |
> +------+---------------+-------------------+----------------+
> | 8 | 11% (2) | 0% (0) | 0% (0) |
> +------+---------------+-------------------+----------------+
>
> thanks a lot in advance,
> tomy
---
Frank E Harrell Jr Prof. of Biostatistics & Statistics
Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine http://hesweb1.med.virginia.edu/biostat
More information about the R-help
mailing list