flipscores | R Documentation |
Provides robust tests for testing in GLMs, by sign-flipping score contributions. The tests are often robust against overdispersion, heteroscedasticity and, in some cases, ignored nuisance variables.
flipscores(formula, family, data, score_type = "standardized",
n_flips = 5000, alternative = "two.sided", id = NULL,
seed = NULL, to_be_tested = NULL, flips = NULL,
precompute_flips=TRUE, ...)
formula |
see |
family |
see |
data |
see |
score_type |
The type of score that is computed. It can be "standardized" "orthogonalized", "effective" or "basic". Both "orthogonalized" and "effective" take into account the nuisance estimation and they provide the same test statistic. In case of small samples "effective score" might have a slight anti-conservative behaviour. "standardized effective score" gives a solution for this issue. "orthogonalized" has a similar intent, note however that in case of a big model matrix, it may be slow. |
n_flips |
The number of random flips of the score contributions. Overwritten with the |
alternative |
It can be "greater", "less" or "two.sided" (default) |
id |
a |
seed |
|
to_be_tested |
vector of indices or names of coefficients of the glm model to be tested (it is faster than computing every scores and p-values of course). |
flips |
matrix fo +1 or -1, the matrix has |
precompute_flips |
|
... |
see |
flipscores
borrows the same parameters from function glm
(and glm.nb
). See these helps for more details about parameters such as formula
,
data
, family
. Note: in order to use Negative Binomial family, family
reference must have quotes (i.e. family="negbinom"
).
Furthermore, flipscores
object contains two extra elements: scores
– i.e. a matrix of n score contributions, one column for each tested coefficient – and Tspace
– i.e. a matrix of size n_flips
times ncol(scores)
. The fist row of Tspace
contains column-wise the test statistics generated by randomly flipping the score contributions, each column refers to the same column of scores
, the vector of observed test statistics (i.e. no flips) is in the first row of Tspace
.
an object of class flipscores
.
See also its methods (summary.flipscores
, anova.flipscores
, print.flipscores
).
Livio Finos, Riccardo De Santis, Jesse Hemerik and Jelle Goeman
"Robust testing in generalized linear models by sign-flipping score contributions" by J.Hemerik, J.Goeman and L.Finos.
anova.flipscores
, summary.flipscores
, flip
set.seed(1)
dt=data.frame(X=rnorm(20),
Z=factor(rep(LETTERS[1:3],length.out=20)))
dt$Y=rpois(n=20,lambda=exp(dt$Z=="C"))
mod=flipscores(Y~Z+X,data=dt,family="poisson",n_flips=1000)
summary(mod)
# Equivalent to:
model=glm(Y~Z+X,data=dt,family="poisson")
mod2=flipscores(model)
summary(mod2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.