[R] odds ratios in multiway tables (stratified)
Marc Schwartz
marc_schwartz at comcast.net
Thu Jul 31 17:31:06 CEST 2008
on 07/31/2008 07:40 AM Wim Bertels wrote:
> On Wed, 2008-07-30 at 12:13 -0500, Marc Schwartz wrote:
>> on 07/30/2008 08:48 AM Wim Bertels wrote:
>>> Hi,
>>>
>>> does anyone know of a function to calculate odds ratios in multiway
>>> tables (stratified) (+ the other usual statistics involved)
>>>
>>> i mean:
>>> say we have a table r*c*d,
>>> For every d (depth) we have a r*c table,
>>> and in this table the odds ratio's are calculated for every 2*2 subtable
>>> in it.
>>>
>>> logically this function would look like):
>>> ORs(multiwaytable)
>>> or
>>> ORs(data$var1r,data$var2c,data$var3d)
>>>
>>> (eg. not taking the lot together, keeping the paradox of simpson in
>>> mind)
>>>
>>> mvg,
>>> Wim
>> In ?mantelhaen.test, there is some code in the examples using the
>> UCBAdmissions data set. There is also code for the Woolf test in the
>> same example.
>
> thanks Marc,
> but CMH testing supposes a common odds ratio, (hence the woolf test)
Strictly speaking that is not correct, whether one is using the Woolf
test or the Breslow-Day test. In fact, since you reference SAS below, my
copy of "Categorical Data Analysis Using the SAS System" by Stokes et al
from 1995 (back in the days when I was using SAS) notes this in the
chapter on stratified 2x2 tables (second para on page 53).
This is also noted in CDA 2nd Edition, Agresti (2002), on page 235.
That being said, a significant Woolf or BD test should give you pause
relative to the validity of the _common_ odds ratio and to consider
alternatives that enable the analysis of more interesting relationships
in your data.
> i am looking for a way to just get all the odds ratios calculated, with
> a family p-values (for each one) and/or family confidence intervals
> (since i am doing multiple testing then,.. data snooping..)
> [i know this is easily done in SAS, but i prefer R..]
>
>> In addition, there is similar code in the 'vcd' and 'rmeta' CRAN packages.
>
> tnx,
> structplot looks nice as an extra
I presume that is strucplot in the vcd package?
You might also want to look at the mh() function in the Epi package,
which I noted doing a quick search this morning.
Also, if the assumption of the homogeneity of odds ratio is not valid in
this situation, you may want to consider that there is an interaction
going on and that an alternative analytic approach, such as logistic
regression with an appropriate interaction term might make sense here.
This came up in a prior thread, which you might find helpful:
https://stat.ethz.ch/pipermail/r-help/2007-February/126254.html
Regards,
Marc
More information about the R-help
mailing list