excessRisk {DAAGxtras} | R Documentation |
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.
excessRisk(form = weight ~ seatbelt + airbag, response = "dead", margin = "airbag", data = nassCDS, decpl = 4)
form |
form is a formula in which classifying factors
appear on the right, with an optional weight variable on the left. |
response |
response is a binary variable or two-level
factor such that the response of interest is the relative number
in the two levels.
|
margin |
margin is the factor whose effect on the
response,
after accounting for other classifying factors, is of interest |
data |
data is a data frame in which variables and
factors may be found |
decpl |
decpl is the number of decimal places in
proportions that appear in the output |
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.
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
|
Count for level 2 of response & level 1 of margin |
|
Total tount for level 1 of margin |
|
Count for level 2 of response & level 2 of margin |
|
Total count for level 2 of margin |
|
Proportion; divide count for level 1 or margin by total |
|
Proportion; divide count for level 2 or margin by total |
|
Excess count for level 2 of response in that row; relative to
the assumption that, in that row, there is no association between
response and texttt{margin}. (For the airbag data; this
column gives excess deaths due to airbags, with negative values
favouring airbags.) |
John Maindonald
See help(nassCDS)
xtabs
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)