Description Usage Arguments Details Value Author(s) Examples
This function computes the (log-)odds ratio (OR) for a 2 × 2 table (x
must be an object of class 'table'
either by using table
or as.table
). For a data frame
of k variables with 2 categories each, all k · (k − 1) ∕ 2 pairwise (log-)odds-ratios are computed.
1 2 3 4 5 6 7 | odds_ratios(x)
## S3 method for class 'REdaS_ORs'
print(x, ...)
## S3 method for class 'REdaS_ORs'
summary(object, ...)
|
x |
either a 2 × 2 |
object |
an object of class |
... |
further arguments. |
Note that tables where one or more cells are 0 are not processed and a warning is issued in such cases.
odds_ratios()
returns a list of class 'REdaS_ORs'
:
call |
the issued function call. |
x |
the original data. |
tables |
a list of one or more tables. |
comps |
a list of the compared variables' names. |
ORs |
a list with (log-)odds-ratios, standard errors, z- and p-values. |
print.REdaS_ORs()
invisibly returns a matrix containing all statistics shown by the print
-method.
Marco J. Maier
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # create a table from a 2 x 2 matrix of frequencies using as.table()
tab <- as.table( matrix(c(49, 1, 5, 45), 2) )
dimnames(tab) <- list("LED on?" = c("no", "yes"),
"PC running?" = c("no", "yes"))
tab
odds_ratios(tab)
# generate a matrix with 3 variables and 100 observations
# note that each variable must have exactly two categories
set.seed(5)
x <- data.frame("A" = as.factor(sample(1:2, 100, TRUE)),
"B" = as.factor(sample(3:4, 100, TRUE)),
"C" = as.factor(sample(5:6, 100, TRUE)))
head(x)
res <- odds_ratios(x)
# print the results and save the summarized information in a matrix
resmat <- print(res)
resmat
# the summary method gives a rather lengthy output with all tables etc.
summary(res)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.