I have a matrix Expr
with rows representing variables and columns samples.
I have a categorical vector called groups
(containing either "A","B", or "C")
I want to test which of variables 'Expr' can be explained by the fact that the sample belong to a group
.
My strategy would be modelling the problem with a generalized additive model (with a negative binomial distribution). And then I want use a likelihood ratio test in a variable wise way to get a p value for each variable. I do:
require(VGAM)
m <- vgam(Expr ~ group, family=negbinomial)
m_alternative <- vgam(Expr ~ 1, family=negbinomial)
and then:
lr <- lrtest(m, m_alternative)
The last step is wrong because it is testing the overall likelihood ratio of the two model not the variable wise. Instead of a single p value I would like to get a vector of the p-values for every variable.
How should I do it? (I am very new to R, so forgive me my stupidity)