riskdiff.data.frame {catfun}R Documentation

Risk difference

Description

Calculate risk difference and 95 percent confidence interval using Wald method.

Usage

## S3 method for class 'data.frame'
riskdiff(df, x = NULL, y = NULL, weight = NULL,
  conf.level = 0.95, rev = c("neither", "rows", "columns", "both"),
  ...)

Arguments

df

a dataframe with binary variables x and y.

x

binary predictor/exposure, vector.

y

binary outcome, vector.

weight

an optional vector of count weights.

conf.level

confidence level for confidence interval, default is 0.95.

rev

reverse order of cells. Options are "row", "columns", "both", and "neither" (default).

...

further arguments passed to or from other methods.

Value

a list with class "rdiff" containing the following components:

rd

risk difference

conf.level

specified confidence level

ci

calculated confidence interval

p1

proportion one

p2

proportion two

tab

2x2 table using for calculating risk difference

Examples

trial <- data.frame(
  disease = c(rep("yes", 2), rep("no", 2)),
  treatment = c(rep(c("estrogen", "placebo"), 2)),
  count = c(751, 623, 7755, 7479))

riskdiff(trial, treatment, disease, count, rev = "columns")

[Package catfun version 0.1.4 Index]