Learn R Programming

mStats (version 3.2.2)

tabRisks: Calculating Risks and Relative Risks

Description

tabRisks() cross-tabulates two variables and reports risks of failure by among exposed and unexposed levels of explanatory variable .... It is used in cross-sectional studies.

Usage

tabRisks(
  data,
  ...,
  by,
  exp_value = NULL,
  case_value = NULL,
  plot = TRUE,
  na.rm = FALSE,
  rnd = 3
)

Arguments

data

Dataset

...

Variable or multiple variables Colon separator : can be used to specify multiple variables.

by

Varaiable for cross-tabulation

exp_value

value for exposure as reference

case_value

value for outcome as reference

plot

logical value to display plots of rates across a categorical variable

na.rm

A logical value to specify missing values, NA in the table

rnd

specify rounding of numbers. See round.

Details

Risks are sometimes called proportions, incidence proportions or prevalence.

Calculating Risks

$$Risks = Outcome of Interest (A) / Sample Size (n)$$

$$Standard Error, SE = \sqrt(p x (1 - p) / n)$$

$$95\% CI = Risks +/- (1.96 x SE)$$

References

  1. Betty R. Kirkwood, Jonathan A.C. Sterne (2006, ISBN:978<U+2013>0<U+2013>86542<U+2013>871<U+2013>3)

  2. B. Burt Gerstman (2013, ISBN:978-1-4443-3608-5)

  3. Douglas G Altman (2005, ISBN:0 7279 1375 1)

Examples

Run this code
# NOT RUN {
## use infert data
data(infert)

tabRisks(infert, education, by = case, case_value = 1, plot = FALSE)
tabRisks(infert, induced, by = case, plot = FALSE)

tabRisks(infert, education, induced, by = case, plot = FALSE)

# }

Run the code above in your browser using DataLab