Description Usage Arguments Details Value Author(s) References Examples
Perform random data rotation of a previously initialised object (see
initRandrot
) associated with the
null hypothesis H0: β_coef.h = 0.
1 2 3 4 5 6 7 8 9 10 |
object |
An initialised object of class
|
... |
further arguments passed to
|
This function generates a randomly rotated dataset from an initialised
randrot object (see initRandrot
).
See also package vignette for application examples. Only the numerical matrix
of rotated data is returned, no design matrix, weights or other info is
return for efficiency purposes. Please consider that, if you e.g. use
weights
or if you use
rotateStat
, you may need to forward
the design matrix X
, weights
etc. to subsequent analyses. See
the example in rotateStat
.
Details on the calculation of a rotated dataset are given in
initRandrot
,
\insertCiteLangsrud2005randRotation and \insertCiteHettegger2021randRotation.
numeric
matrix of rotated data under the specified combined
null hypothesis.
Peter Hettegger
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | # For further examples see '?rotateStat' and package vignette.
#set.seed(0)
# Dataframe of phenotype data (sample information)
# We simulate 2 sample classes processed in 3 batches
pdata <- data.frame(batch = rep(1:3, c(10,10,10)),
phenotype = rep(c("Control", "Cancer"), c(5,5)))
features <- 100
# Matrix with random gene expression data
edata <- matrix(rnorm(features * nrow(pdata)), features)
rownames(edata) <- paste("feature", 1:nrow(edata))
mod1 <- model.matrix(~phenotype, pdata)
# Initialisation of the random rotation class
init1 <- initBatchRandrot(Y = edata, X = mod1, coef.h = 2,
batch = pdata$batch)
init1
### Fit model to original data
fit.orig <- lm.fit(mod1, t(edata))
head(t(coef(fit.orig)))
### Fit model to rotated data
edata.rot <- randrot(init1)
fit.rot <- lm.fit(mod1, t(edata.rot))
head(t(coef(fit.rot)))
# Note that the coefficients stay equal if we regress only on the
# non-hypothesis coefficients
mod0 <- model.matrix(~1, pdata)
fit.orig0 <- lm.fit(mod0, t(edata))
fit.rot0 <- lm.fit(mod0, t(edata.rot))
head(t(coef(fit.orig0)))
head(t(coef(fit.rot0)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.