| fmat | R Documentation |
The fmat object is the internal dataset used by the outcomerate package.
It holds all definitions for the outcome rates. With the exception of
location rates, these are taken from the AAPOR Standard Definitions (2023).
The data is a 3-dimensional binary array consisting of:
outcome: codes I, P, R, NC, O, UH, UR, UO, eUH,
eUR, eUO, and NE
rate: the shorthand name for the rate (e.g. RR1)
side: numerator (NUM) and denominator (DEN)
Given these three dimensions, each outcome rate can be defined as a rational number (i.e. a fraction) consisting of a summation of frequencies of outcome codes (where the matrix entries are nonzero).
The input parameters given by the user are I, P, R, NC, O, UH,
UR, UO, and NE. The scalar or category-specific values in e are
multiplied by UH, UR, and UO internally to produce the estimated
eligible counts eUH, eUR, and eUO.
The reason for this implementation is:
a) It conforms to a DRY (don't repeat yourself) philosophy by holding all definitions in one place. These definitions can be used as upstream inputs to functions/test suites requiring them.
b) It makes it easier to use intermediate steps in the formula calculations. For instance, it may be of use to a researchers to want to obtain the numerator/denominators of calculations, instead of only the output.
c) it makes it easy to compare the output
d) It is easier to maintain
https://aapor.org/wp-content/uploads/2024/03/Standards-Definitions-10th-edition.pdf
fmat <- outcomerate:::fmat
# Print the dimensions
dimnames(fmat)
# Say we want to know the definition of Response Rate 2, RR2. We see
# below that the numerator (NUM) column is defined by the entries with a 1,
# or (I + P). Likewise, the denominator (DEN) is defined as
# (I + P + R + NC + O + UH + UR + UO)
fmat[, "RR2", ]
# To use linear algebra, we define a zero-one numerator matrix 'N'
# and a zero-one denominator matrix 'D'. Our count of disposition codes
# is given here manually as 'x' (in the same order as N and D).
N = fmat[ , , 1]
D = fmat[ , , 2]
x <- c(I = 5, P = 2, R = 1, NC = 7, O = 3,
UH = 4, UR = 2, UO = 8, NE = 1,
eUH = 3, eUR = 1.5, eUO = 6)
# Return all rates
(x %*% N) / (x %*% D)
# The same thing can be achieved with the apply family of functions
numden <- apply(x * fmat, 2:3, sum)
numden[, 1] / numden[, 2]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.