find_tor_probs: Find the pair of probabilities that average to a target...

find_tor_probsR Documentation

Find the pair of probabilities that average to a target probability and yield a target odds-ratio.

Description

Given an input probability (mp) and a target odds-ratio (tor), iteratively find a pair of probabilities (p0 and p1) whose mean is equal to the input mean probability (mp) and also yield the target odds-ratio.

Usage

find_tor_probs(mp = 0.5, by = 0.001, tor, direction = "gt")

Arguments

mp

A numeric value for the mean probability. This value must be a positive number in the open unit interval (0,1). It is assumed that this is the unweighted mean probability after pooling data from two groups of equal size.

by

The amount to add or subtract from the mean probability at each iteration to generate each member of the pair of probabilities used to compute the odds-ratio tested against the target odds-ratio. This value must be a positive number in the open unit interval (0,1).

tor

A numeric value for the targets odds-ratio. This value must be greater than zero (tor > 0) and must be finite (tor = Inf yields an error).

direction

A character value of either "gt" or "lt", which respectively indicate whether to solve for a resulting odds-ratio greater than tor (between 1 and Inf) or less than tor (between 0 and 1). The default is "gt".

Details

=============================================================================

This function is intended to facilitate sample size planning calculations. The idea is that one may have some a priori estimate of an average probability of some event occurring, but want to use a binary predictor in a generalized linear model (GLM) or generalized estimating equation (GEE) that has a particular target odds-ratio. Some sample size formulas require you to input the pair of probabilities instead of the odds-ratio. This function allows you to convert the odds-ratio and average probability (ignoring the predictor) into the required pair of probabilities.

The function will keep p0 and p1 inside the open unit interval (0,1). It checks and validates the arguments provided to ensure sensible values have been selected. It assumes that the two proportions are estimated from groups of equal size, so the values of p0 and p1 are incrementally moved away from the mp value in opposite directions until the resulting odds-ratio meets the target value. If either p0 or p1 approaches too close to either 0 or 1, then it will stop changing and then only the other probability will change thereafter to reach the target odds-ratio.

Value

A data frame containing the mean probability (mp), the target odds-ratio (TargetOR), the value of by argument, the pair of target probabilities (p0 and p1), the odds-ratio resulting from them (ResultOR), and the inverse of the resulting odds-ratio (InverseOR).

Examples

find_tor_probs(mp = .75, by = .001, tor = 2)
find_tor_probs(mp = .75, by = .001, tor = 0.5, direction = "lt")


sjpierce/piercer documentation built on Dec. 30, 2024, 3:28 p.m.