coefTest and one tailed T-test

조회 수: 10 (최근 30일)
Arman
Arman 2012년 11월 11일
Dear all,
I have fitted a linear model to my data as follows: Var6 ~ 1 + groupVar1 +groupVar2 + groupVar3 +Var4 + Var5
the first 3 variables are dummy variables for the three groups that I have, and I aim to compare groups using GeneralizedLinearModel.fit and adjusting for nuisance variables. Using coefTest with this contrast I get the f statistic of "any group different from zero" while controlling for Var4 and Var5: [0 1 0 0 0 0;0 0 1 0 0 0;0 0 0 1 0 0] and I get a p value, and so on. However, when it comes to one tail t tests for the following two contrasts I get the same significant p value for which does not make sense to me:
contrast 2:Group1 >Group2 coefTest(m, [0 1 -1 0 0 0]) contrast 3:Group2 >Group1 coefTest (m, [0 -1 1 0 0 0])
It would be great if someone could let me know where I'm getting this wrong, as there is no way for a group to be greater and lesser than another group at the same time.
-Arman
  댓글 수: 1
Arman
Arman 2012년 11월 11일
편집: Arman 2012년 11월 13일
So probably I'm just doing an F-test, is there a way to do one tailed t-tests in GeneralizedLinearModel in MATLAB?

댓글을 달려면 로그인하십시오.

채택된 답변

Tom Lane
Tom Lane 2012년 11월 12일
You are right that the result from coefTest is an F-test. There is no built-in way to carry out a one-sided t test.
Here are some commands to reproduce the calculations for the t statistic and its p-value as they appear int the coefficient table:
load carsmall
d = dataset(MPG,Weight);
d.Year = ordinal(Model_Year);
glm = GeneralizedLinearModel.fit(d,'MPG ~ Year + Weight + Weight^2')
glm.Coefficients.Estimate(3)
glm.Coefficients.Estimate(3)/sqrt(glm.CoefficientCovariance(3,3))
2*(1 - tcdf(glm.Coefficients.Estimate(3)/sqrt(glm.CoefficientCovariance(3,3)),glm.DFE))
You could compute a contrast among the coefficients (instead of just taking the third one as I did), use the covariance matrix to compute the variance of this contrast, and so on. Then you could pick the desired tail of the t distribution.
  댓글 수: 2
Arman
Arman 2012년 11월 13일
편집: Arman 2012년 11월 13일
Thanks a lot for your answer. I managed to understand most of the procedure, so back to my model:
responseVariable ~ 1 + groupVar1 +groupVar2 + groupVar3 +nuisanceVar4 + nuisanceVar5
When my contrast is [0 1 -1 0 0 0] to test the hypothesis of whether the mean of second group is lower than that of first, I have difficulty understanding the appropriate coefficient and covariance for the rest of the analysis. I think the correct coefficient for this contrast is the linear combination of that of the "groupVar1" and "groupVar2", is that right? And with regard to the coefficient covariance for t-statistic calculation, is it the linear combination of covariances for each of the regression coefficients (namely, "groupVar1" and "groupVar2" from glm.CoefficientCovariance matrix provided in MATLAB)?
Tom Lane
Tom Lane 2012년 11월 14일
If you have three groups and you include dummy variables for them all, I'd expect that to be collinear with the constant term. But in general for a contrast such as c=[0 1 -1 0 0 0], coefficient vector b, and covariance matrix V, c*b is your estimated contrast and c*V*c' its variance.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by