permci | R Documentation |
Calculate a randomization-based confidence interval (CI) for a regression parameter.
permci(model, trtname, runit, strat = NULL, data, nperm = 1000,
nburn = 0, level = 0.95, init, initmethod = "perm", ncores = 1,
seed, quietly = F, method = "G", m, k, Ps = NULL, n)
model |
an appropriate fitted model object, see Details |
trtname |
character string specifying the name of randomized treatment
variable in |
runit |
character string specifying the name of unit of randomization
in |
strat |
an optional character string specifying the name of the variable
in |
data |
a data frame containing the variables in the model. This argument
is passed to the corresponding regression function, e.g.
|
nperm |
number of permutations for each randomization CI bound |
nburn |
number of “burn-in” permutations. I.e. algorithm will start at
|
level |
two-sided confidence level (e.g. level = 0.95 for 95% CI) |
init |
vector of initial values for CI, with lower bound as
first element and upper bound as second. If |
initmethod |
character; indicates the method to be used for initial
values for CI. If "asymp", initial bounds are based on asymptotic
approximation (e.g. Wald CI for GLM). If "perm" (default), initial bounds are based
on the permutation approach used in Garthwaite (1996) with |
ncores |
number of cores to use for computation. If |
seed |
a numerical seed to use, passed to |
quietly |
logical; if TRUE (and if ncores == 1), status updates will be printed to Console otherwise, suppress updates. |
method |
if method = 'G' (default), then search is carried out as described in Garthwaite (1996). For longer searches (nperm >= 200,000), method = 'GJ' is recommended and carried out as outlined in Garthwaite and Jones (2009). |
m |
an optional initial magnitude of the steps; if left unspecified, m defaults to recommended value proposed in Garthwaite and Buckland (1992) |
k |
step length multiplier |
Ps |
if method = 'GJ', vector of search lengths for each phase (if unspecified, defaults to recommended values in Garthwaite and Jones (2009)) |
n |
if method = 'GJ', the unweighted averages of the final |
This function is used to calculate randomization-based confidence intervals (CI) for a regression parameter. These CIs correspond to inverting randomization tests by using an offset to test non-zero "null" values (Rabideau and Wang). To invert the randomization test, these functions adapt a computationally efficient CI algorithm based on the Robbins-Monro search process. Two methods can be used and correspond to Garthwaite (1996) and Garthwaite and Jones (2009).
The argument model
must correspond to a regression model that
accomodates an offset term (see offset) and one for which
coefficients can be extracted in the standard way (see coef).
E.g. an object of class "glm" (see glm), "survreg" (see
survreg), "coxph" (see coxph), etc.
permtest
for a randomization test
# Calculate randomization-based CI for the incidence rate ratio (IRR) of
# bacterial pneumonia episodes between the two intervention groups in
# pneumovac data set. (Note, it will take a few seconds to run 1,000
# permutations)
head(pneumovac) # visualize data
m1 <- glm(bpepisodes ~ spnvac, family = poisson, data = pneumovac) # fit GLM
ci <- permci(m1, trtname = 'spnvac',
runit = 'randunit', data = pneumovac,
nperm = 1000, ncores = 2, seed = 445)
print(ci$ci)
# lower upper
# -0.97314014 0.06265964
plot(ci) # monitor convergence of CI search
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.