# Linear hypothesis test on a simple GLM in MATLAB: linhyptest on glmfit?

I have a very simple GLM in MATLAB $$y=\beta_0+\beta_1x_1+\beta_2x_2+\epsilon,$$ which I fit with glmfit.

Now I wish to test if $\beta_1=\beta_2$ with linear hypothesis test. In MATLAB, this can be done by linhyptest.

One of the parameters requested by linhyptest is dfe -- "the degrees of freedom for the COVB estimate."

The most similar quantity output by glmfit is dfe -- "degrees of freedom for error."

Are these the same thing? If not, how may I derive the correct dfe for linhyptest?

• Yes there are in this context. Having said that you appear to fit a simple linear regression model. In this case the standard regstats would do just fine and you could follow the example in the webpage directly. Is there something caveat that enforces the use of glmfit? Apr 20, 2016 at 6:38
• @usεr11852 thanks! nothing caveat -- it's just I started off with glmfit and have generated all the results with glmfit. So the two dfe are the same? But why "the degrees of freedom for the COVB estimate" = "degrees of freedom for error"? Apr 21, 2016 at 2:09
• Yes, they are the same in the current context. The common use of degrees of freedom is in conjunction with the error. The error itself is related to the $\beta$ estimates. I guess it is a bit unfortunate use of terminology. In both case you are doing an $F$-test and get the $p$-value of the upper tail of the $F$ cumulative distribution function. That's why you provide the dfe to begin with. Apr 23, 2016 at 7:44

As in most cases the term "degrees of freedom" is related to the error/residuals. As this error is directly associated to the $\beta$ estimates of the model used the wording "the degrees of freedom for the COVB estimate" is valid while unfortunately slightly contrived. Nevertheless in both cases what is taking place is an $F$-test about the relevancy of the model examined. You get the associated $p$-value of the upper tail of the $F$-cumulative distribution function. This thread on the mechanics of the General linear hypothesis test statistic gives a nice theoretical overview.
In general linhyptest is a bit of a niche function. I think bootstrapping your model to get confidence intervals will be far more informative than an asymptotic test based on normality assumption for the parameter estimates. As usually an $F$-test tests the null hypothesis that all the $\beta$ is your model are equal to 0 (aside $\beta_0$); this is a more restrictive assumption and I am not sure it is terribly informative in most cases unless you start defining certain complex grouping among your covariates.
Particular to the MATLAB aspect of your question I would suggest using the standard regstats function instead of glmfit given you are not using a particular link-function for your GLM. It will be more computationally efficient as well as more straightforward to use with linhyptest.