permtest_glm | R Documentation |
Carry out a randomization test for a treatment effect using a regression parameter estimate as the test statistic.
permtest_glm(formula, trtname, runit, strat = NULL, family = gaussian,
data, nperm = 1000, ncores = 1, seed, quietly = T)
permtest_survreg(formula, trtname, runit, strat = NULL, data,
dist = "weibull", nperm = 1000, ncores = 1, seed, quietly = T)
permtest_coxph(formula, trtname, runit, strat = NULL, data,
nperm = 1000, ncores = 1, seed, quietly = T)
formula |
an object of class " |
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 |
family |
a description of the error distribution and link function to
be used in the model. This can be a character string naming a family
function, a family function or the result of a call to a family function.
(See |
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 randomization test |
ncores |
number of cores to use for computation. If ncores > 1, permtest runs in parallel. |
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. |
dist |
assumed distribution for y variable. If the argument is a
character string, then it is assumed to name an element from
|
These functions are used to carry out randomization tests for a treatment effect based on a parameter estimate from a regression model. Different functions corrrespond to different regression models:
permtest_glm
: randomization test based on
glm
permtest_survreg
: randomization test based on
survreg
permtest_coxph
: randomization test based on
coxph
To ensure correct specification of the parameters passed to the models above
(e.g. formula
in survreg
), please refer to
their documentation.
permci_glm
,
permci_survreg
, permci_coxph
for corresponding randomization-based CIs
# Carry out a randomization test to determine whether there was a difference
# in the rate of bacterial pneumonia episodes between the two intervention
# groups in pneumovac data set. The test statistic we will use is the
# estimated log incidence rate ratio (IRR) from a Poisson GLM. (Note, it will
# take a few seconds to run 1,000 permutations)
head(pneumovac) # visualize data
test <- permtest_glm(bpepisodes ~ spnvac, trtname = 'spnvac',
runit = 'randunit', family = poisson, data = pneumovac,
nperm = 1000, ncores = 2, seed = 445)
print(c(test$coef, test$pval))
# [1] -0.4466939 0.0560000
plot(test) # visualize Monte Carlo randomization distribution
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.