rtmhs
Regression to the mean at selected hot spots
rtmhs(x1, x2, cut, w = NULL)crimlab.rtmhs(x1, x2, cut, w=None)crimlab rtmhs --x1 VALUE --x2 VALUE --cut VALUE [--w VALUE]Places chosen because their count in a first period exceeds a cut show a
fall in the next period even with no treatment and no trend: if the two
periods are exchangeable, the selected places’ mean change is never
positive, and places chosen for being low never fall on average. This
reports the change at the selected places next to the same statistic on
the data together with its period-swapped copy, which is exchangeable by
construction and so never positive; the excess of the first over the
second is the part of the fall that selection alone does not explain. A
treatment effect needs a control group selected the same way. See
proof("rtmhs").
Parameters
Section titled “Parameters”x1Counts by place in the first period: finite numbers.
x2Counts by place in the second period: same length; when
x1,x2(andw) are all named with unique names, they are matched by name.cutThe selection cut: places with
x1 > cutare selected.wNULLfor equal weights, or one non-negative weight per place.
Returns
Section titled “Returns”A named numeric vector: nsel (the weight selected), change
(the weighted mean of x2 - x1 at the selected places), mirror (the
mean of x1 - x2 at places with x2 > cut), sym (the change in the
data with its swapped copy; never positive), excess (change - sym),
low (the mean change at places with x1 < cut) and lowsym (its
swapped-copy version; never negative). NaN where no place qualifies.
References
Section titled “References”Barnett, A. G., van der Pols, J. C. and Dobson, A. J. (2005). Regression to the mean: what it is and how to deal with it. International Journal of Epidemiology, 34(1), 215-220. doi:10.1093/ije/dyh299
Examples
Section titled “Examples”set.seed(5)mu <- rgamma(300, 2, 0.5)x1 <- rpois(300, mu)x2 <- rpois(300, mu)rtmhs(x1, x2, cut = quantile(x1, 0.9))Generated from the R help page: rtmhs in the R reference.