Description Usage Arguments Details Value
updateGamma
is the percentile update function called by
percentileSeek
as percentileSeek
attempts to
match a set of grade proportions to a set of desired.props
.
1 2 3 | updateGamma(scores, z, desired.props, gamma.perc, index.to.update,
restaurant.tol = 10, iter = 1, max.iterations = 20, gamma_upper = NA,
gamma_lower = NA, resolve.ties = FALSE)
|
scores |
Numeric vector of size |
z |
Character vector representing ZIP codes. |
desired.props |
Numeric vector representing desired global grade
proportions across the entire jurisdiction. |
gamma.perc |
Numeric vector representing an initial set of percentiles. |
index.to.update |
Integer value in the set
|
restaurant.tol |
Integer value representing the maximum difference in
number of restaurants suggested by |
iter |
Integer value representing the current iteration of |
max.iterations |
Integer value specifying the maximum number of
calls of the |
gamma_upper |
Numeric or NA value representing a value of
|
gamma_lower |
Numeric or NA value representing a value of
|
resolve.ties |
Boolean value specifying interpretation of how the
function's returned percentile will be applied across the subunits see:
percentileSeek. Should as close to (desired.props[1])% of
restaurants in a ZIP code receive an "A" grade, and as close to
(desired.props[2])% of restaurants in a ZIP code receive "B" grades
( |
updateGamma
performs the update of
gamma.perc[index.to.update]
. In particular, gamma.perc[index.to.update]
will
be updated until either the number of updates has reached
max.iterations
, or the difference between the proportion of
(gradeable) restaurants scoring the (index.to.update)
th highest grade
is within (restaurant.tol/ no.gradeable.rests)
of the desired
proportion, where no.gradeable.rests
is the number of gradeable
restaurants (restaurants that have both ZIP code and inspection score
information). Initially, gamma.perc[index.to.update]
is updated
according to the rule gamma.perc[index.to.update] <-
(gamma.perc[index.to.update] - diff.aj.desired)
, where diff.aj.desired
is the difference between the actual proportion of restaurants assigned the grade
of interest and the desired proportion. However, if the algorithm locates
values of gamma.perc[index.to.update]
that produce grade proportions
that are both higher and lower than the desired proportion,
gamma_upper
and gamma_lower
respectively, the update rule
becomes gamma.perc[index.to.update]<- 0.5*(gamma_upper +
gamma_lower)
, as in the bisection root finding method.
A numeric value representing a percentile to be applied to each ZIP code so as to achieve a particular desired proportion of grades.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.