excessRisk {DAAG} | R Documentation |
Create and analyze multiway frequency or weighted frequency table
Description
This function creates a multi-way table of counts
for the response
given a set of classifying factors. Output
facilitates a check on how the factor specified as margin
may, after accounting for other classifying factors, affect the
response.
Usage
excessRisk(form = weight ~ seatbelt + airbag, response = "dead", margin = "airbag",
data = DAAG::nassCDS, decpl = 4, printResults = TRUE)
Arguments
form |
|
response |
|
margin |
|
data |
|
decpl |
|
printResults |
if |
Details
The best way to understand what this function does may be to run it with the default parameters, and/or with examples that appear below.
Value
The function returns a data frame, with one row for each combination of
levels of factors on the right of the formula, but excluding the
factor specified as margin
.
The final three columns show the count for level 1 as a fraction
of the margin by total, the count for level 2 as a fraction of
the margin by total, and the excess count for level 2 of response in
the row, under the assumption that, in that row, there is no association
between response
and margin
. This is the observed response
(for the default arguments, number of dead) for level 2 (airbag deployed),
less the number that would have been expected if the proportion
had been that for level 1. (Negative values favor airbags.)
Author(s)
John Maindonald
References
See help(nassCDS)
See Also
xtabs
Examples
excessRisk()
excessRisk(weight ~ airbag+seatbelt+dvcat)
UCB <- as.data.frame.table(UCBAdmissions)
excessRisk(Freq~Gender, response="Admit", margin="Gender",data=UCB)
excessRisk(Freq~Gender+Dept, response="Admit", margin="Gender",data=UCB)