coeftest to test simple effects

I have run fitglme with 2 categorical variables (X1, X2) and an interaction term as predictors. Each categorical variable has 2 levels - let's call the levels A and B. I would like to use coefTest to test, say, whether X1 level A vs. X1 level B are significantly different but only at X2 level B. I would also like to test whether X1 level A and X2 level A are significantly different from one another.
I understand that the columns of coefTest are the predictors but I don't really understand what's on the rows? If I make 4 rows what are the 3rd and 4th rows?
Thanks for any insight you can offer.

4 Kommentare

jgg
jgg am 18 Dez. 2015
I'm not exactly clear what you are trying to do here. What do you mean the columns of coefTest? This function should only return between 1 and 4 scalars if I understand what you are doing correct ( see here ).
Perhaps you could post the code you are working on so we can understand better?
Alex
Alex am 18 Dez. 2015
Bearbeitet: Alex am 18 Dez. 2015
In the link you sent it says:
"Fixed-effects contrasts, specified as an m-by-p matrix, where p is the number of fixed-effects coefficients in glme. Each row of H represents one contrast. The columns of H (left to right) correspond to the rows of the p-by-1 fixed-effects vector beta (top to bottom) whose estimate is returned by the fixedEffects method."
So it says that each row represents one contrast but you can enter like 4 rows in the matrix and it returns a single p-value. So I don't fully understand what the rows are.
Here's an example: a2 is my glme object. So I can do this:
>> anova(a2)
ans =
ANOVA marginal tests: DFMethod = 'residual'
Term FStat DF1 DF2 pValue
'(Intercept)' 116.28 1 12636 5.4112e-27
'cond' 6.3078 1 12636 0.012033
'resp' 1.6377 1 12636 0.20066
'cond:resp' 29.531 1 12636 5.6058e-08
This next code will compare the two levels of the cond factor which is the same thing the anova does and it returns the same p-value
coefTest(a2,[0 1 0 0; 0 -1 0 0])
ans =
0.0120
Now I'd like to do the same exact thing but rather compare the 2 levels of cond across both levels of resp, I'd like to compare the 2 levels of cond at one level of resp but I don't know how to specify this in coefTest. And then more generally, what would it mean to have a third and fourth row in the matrix specified inside coefTest?
Does that make more sense? Thanks for your help.
jgg
jgg am 22 Jul. 2016
I think your confusion is because it's performing the joint hypothesis test that Hb = 0; so it will only return a single p value for the F test of this hypothesis.
The key is to figure out how you can write your hypothesis as a linear combination of the coefficients in your model.
John Hartman
John Hartman am 27 Jun. 2019
As mentioned by jgg, you must test linear combinations of the model coefficients. Sometimes though, your model may change or you may have a lot of coefficients which can make manually defining long contrast vectors tedious. People frequently use more interpretable linear combinations of the coefficients, i.e. estimated marginal (or predicted, or least squares) means. Then, these functions may be of use https://www.mathworks.com/matlabcentral/fileexchange/71970-emmeans

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Rohan Joshi
Rohan Joshi am 21 Jul. 2016

1 Stimme

I am looking for an answer to the exact same question!

1 Kommentar

Alexis
Alexis am 7 Jun. 2020
Same, as are many here. I keep finding my own posts from more than a year ago asking the same questions. TMW, please either deal with the backlog of questions or improve the documentation!

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 18 Dez. 2015

Kommentiert:

am 7 Jun. 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by