Model fitting and hypothesis testing
Show older comments
Dear all,
I have started using MATLAB statistics toolbox and have a few problems in model fitting. I have read the manual for glm, however I'm still confused with my own data. I have 3 groups of patients,with two nuisance covariates and one dependent variable. I would like to compare the measured dependent variable among three groups, controlling for two nuisance covariates. Statistics toolbox provides several functions for model fitting which is a little confusing for me. I'm confused whether I should start with glmfit or GeneralizedLinearModel and how I should proceed, whether with coeftest, glmval . I would be grateful if someone point me where I should begin and proceed.
-Arman
Accepted Answer
More Answers (2)
John
on 20 Feb 2014
Hi Tom,
I'm having a bit of a problem understanding what the coefTest function is doing (and can't seem to find where the root code is to look at it). I ran a fitlm model on some data and got the following stats matrix:
tStat pValue
(Intercept) -7.0023 1.1537e-10
Early 2.4744 0.014615
Correct -0.56112 0.57567
Bins 8.0292 4.7528e-13
Early:Correct -3.0349 0.0028993
Early:Bins -2.8373 0.0052691
Correct:Bins 0.64341 0.52107
Early:Correct:Bins 3.4799 0.00068014
I had someone replicate this same linear regression in STATA and got the same values. Now I want to test the significance between Early x Bins and Correct x Bins. When you do this in STATA (test Bins_Correct = Bins_Early) you get F=12.12 p=.0007. When I run coefTest(stats1,[0 0 0 0 0 1 1 0]), which seems like it should be equivalent, I get p=.2075. When I run coefTest(stats1,[0 0 0 0 0 1 1 1]) I get .0072.
What input do I need to get the equivalent hypothesis test value from STATA? Or at a minimum where do I find the coefTest m-file so I can see what it's doing?
Thanks!
2 Comments
Tom Lane
on 20 Feb 2014
I don't have your data. If you want to test whether two things are equal, this is the same as testing that their difference is 0, so try setting up the vector to specify a difference. Maybe [0 0 0 0 0 1 -1 0].
You can look at the implementation of the method for an object by typing something like
edit LinearModel/coefTest
Alexis
on 5 Nov 2019
Hi Tom, can you explain how to set up the contrast matrix for 2- or 3-way interactions? This isn't covered in the documentation examples at all. Thanks!
John
on 20 Feb 2014
0 votes
Your suggestion nailed it. Thanks Tom!!
Categories
Find more on Hypothesis Tests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!