Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

# coefTest

Linear hypothesis test on generalized linear regression model coefficients

## Syntax

```p = coefTest(mdl) p = coefTest(mdl,H) p = coefTest(mdl,H,C) [p,F] = coefTest(mdl,...) [p,F,r] = coefTest(mdl,...) ```

## Description

`p = coefTest(mdl)` computes the p-value for an F test that all coefficient estimates in `mdl` are zero, except for the intercept term.

`p = coefTest(mdl,H)` performs an F test that `H*B = 0`, where `B` represents the coefficient vector.

`p = coefTest(mdl,H,C)` performs an F test that `H*B = C`.

```[p,F] = coefTest(mdl,...)``` returns the F test statistic.

```[p,F,r] = coefTest(mdl,...)``` returns the numerator degrees of freedom for the test.

## Input Arguments

 `mdl` Generalized linear model, specified as a full `GeneralizedLinearModel` object constructed using `fitglm` or `stepwiseglm`, or a compacted `CompactGeneralizedLinearModel` object constructed using `compact`. `H` Numeric matrix having one column for each coefficient in the model. When `H` is an input, the output `p` is the p-value for an F test that `H*B = 0`, where `B` represents the coefficient vector. `C` Numeric vector with the same number of rows as `H`. When `C` is an input, the output `p` is the p-value for an F test that `H*B = C`, where `B` represents the coefficient vector.

## Output Arguments

 `p` p-value of the F test (see Definitions). `F` Value of the test statistic for the F test (see Definitions). `r` Numerator degrees of freedom for the F test (see Definitions). The F statistic has `r` degrees of freedom in the numerator and `mdl.DFE` degrees of freedom in the denominator.

## Examples

expand all

Test a generalized linear model to see if its coefficients differ from zero.

Create a generalized linear regression model of Poisson data.

```X = 2 + randn(100,1); mu = exp(1 + X/2); y = poissrnd(mu); mdl = fitglm(X,y,'y ~ x1','distr','poisson');```

Test whether the fitted model has coefficients that differ significantly from zero.

`p = coefTest(mdl)`
```p = 3.1394e-36 ```

There is no doubt that the coefficient of `x1` is nonzero.

expand all

## Alternatives

The values of commonly used test statistics are available in the `mdl.Coefficients` table.