permtest_glm: Randomization test for regression

View source: R/test.R

permtest_glmR Documentation

Randomization test for regression

Description

Carry out a randomization test for a treatment effect using a regression parameter estimate as the test statistic.

Usage

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)

Arguments

formula

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. This argument is passed to the corresponding regression function, e.g. glm (see Details).

trtname

character string specifying the name of randomized treatment variable in data (variable to permute)

runit

character string specifying the name of unit of randomization in data

strat

an optional character string specifying the name of the variable in data upon which randomization was stratified

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 family for details.)

data

a data frame containing the variables in the model. This argument is passed to the corresponding regression function, e.g. glm (see Details).

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 set.seed (if ncores == 1) or registerDoRNG (if ncores > 1).

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 survreg.distributions. These include "weibull", "exponential", "gaussian", "logistic","lognormal" and "loglogistic". Otherwise, it is assumed to be a user defined list conforming to the format described in survreg.distributions.

Details

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.

See Also

permci_glm, permci_survreg, permci_coxph for corresponding randomization-based CIs

Examples

# 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

djrabideau/permuter documentation built on Jan. 9, 2025, 11:45 p.m.