# anova

**Class: **GeneralizedLinearMixedModel

Analysis of variance for generalized linear mixed-effects model

## Description

returns
a table, `stats`

= anova(`glme`

,`Name,Value`

)`stats`

, using additional options specified
by one or more `Name,Value`

pair arguments. For example,
you can specify the method used to compute the approximate denominator
degrees of freedom for the *F*-tests.

## Input Arguments

`glme`

— Generalized linear mixed-effects model

`GeneralizedLinearMixedModel`

object

Generalized linear mixed-effects model, specified as a `GeneralizedLinearMixedModel`

object.
For properties and methods of this object, see `GeneralizedLinearMixedModel`

.

### Name-Value Arguments

Specify optional pairs of arguments as
`Name1=Value1,...,NameN=ValueN`

, where `Name`

is
the argument name and `Value`

is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.

*
Before R2021a, use commas to separate each name and value, and enclose*
`Name`

*in quotes.*

`DFMethod`

— Method for computing approximate denominator degrees of freedom

`'residual'`

(default) | `'none'`

Method for computing approximate denominator degrees of freedom
to use in the *F*-test, specified as the comma-separated
pair consisting of `'DFMethod'`

and one of the following.

Value | Description |
---|---|

`'residual'` | The degrees of freedom are assumed to be constant and equal
to n – p, where n is
the number of observations and p is the number
of fixed effects. |

`'none'` | All degrees of freedom are set to infinity. |

The denominator degrees of freedom for the *F*-statistic
correspond to the column `DF2`

in the output structure `stats`

.

**Example: **`'DFMethod','none'`

## Output Arguments

`stats`

— Results of *F*-tests for fixed-effects terms

table

Results of *F*-tests for fixed-effects terms,
returned as a table with one row for each fixed-effects term in `glme`

and
the following columns.

Column Name | Description |
---|---|

`Term` | Name of the fixed-effects term |

`FStat` | F-statistic for the term |

`DF1` | Numerator degrees of freedom for the F-statistic |

`DF2` | Denominator degrees of freedom for the F-statistic |

`pValue` | p-value for the term |

Each fixed-effects term is a continuous variable, a grouping
variable, or an interaction between two or more continuous or grouping
variables. For each fixed-effects term, `anova`

performs
an *F*-test (marginal test) to determine if all coefficients
representing the fixed-effects term are equal to 0.

To perform tests for the type III hypothesis, when fitting the
generalized linear mixed-effects model `fitglme`

,
you must use the `'effects'`

contrasts for the `'DummyVarCoding'`

name-value
pair argument.

## Examples

### F-Tests for Fixed Effects

Load the sample data.

`load mfr`

This simulated data is from a manufacturing company that operates 50 factories across the world, with each factory running a batch process to create a finished product. The company wants to decrease the number of defects in each batch, so it developed a new manufacturing process. To test the effectiveness of the new process, the company selected 20 of its factories at random to participate in an experiment: Ten factories implemented the new process, while the other ten continued to run the old process. In each of the 20 factories, the company ran five batches (for a total of 100 batches) and recorded the following data:

Flag to indicate whether the batch used the new process (

`newprocess`

)Processing time for each batch, in hours (

`time`

)Temperature of the batch, in degrees Celsius (

`temp`

)Categorical variable indicating the supplier (

`A`

,`B`

, or`C`

) of the chemical used in the batch (`supplier`

)Number of defects in the batch (

`defects`

)

The data also includes `time_dev`

and `temp_dev`

, which represent the absolute deviation of time and temperature, respectively, from the process standard of 3 hours at 20 degrees Celsius.

Fit a generalized linear mixed-effects model using `newprocess`

, `time_dev`

, `temp_dev`

, and `supplier`

as fixed-effects predictors. Include a random-effects term for intercept grouped by `factory`

, to account for quality differences that might exist due to factory-specific variations. The response variable `defects`

has a Poisson distribution, and the appropriate link function for this model is log. Use the Laplace fit method to estimate the coefficients. Specify the dummy variable encoding as `'effects'`

, so the dummy variable coefficients sum to 0.

The number of defects can be modeled using a Poisson distribution

$${\text{defect}}_{ij}\sim \text{}\text{Poisson}({\mu}_{ij})$$

This corresponds to the generalized linear mixed-effects model

$$\mathrm{log}{\mu}_{ij}={\beta}_{0}+{\beta}_{1}{\text{newprocess}}_{ij}+{\beta}_{2}{\text{time}\text{\_}\text{dev}}_{ij}+{\beta}_{3}{\text{temp}\text{\_}\text{dev}}_{ij}+{\beta}_{4}{\text{supplier}\text{\_}\text{C}}_{ij}+{\beta}_{5}{\text{supplier}\text{\_}\text{B}}_{ij}+{b}_{i},$$

where

$${\text{defects}}_{ij}$$ is the number of defects observed in the batch produced by factory $$i$$ during batch $$j$$.

$${\mu}_{ij}$$ is the mean number of defects corresponding to factory $$i$$ (where $$i=1,2,...,20$$) during batch $$j$$ (where $$j=1,2,...,5$$).

$${\text{newprocess}}_{ij}$$, $${\text{time}\text{\_}\text{dev}}_{ij}$$, and $${\text{temp}\text{\_}\text{dev}}_{ij}$$ are the measurements for each variable that correspond to factory $$i$$ during batch $$j$$. For example, $${\text{newprocess}}_{ij}$$ indicates whether the batch produced by factory $$i$$ during batch $$j$$ used the new process.

$${\text{supplier}\text{\_}\text{C}}_{ij}$$ and $${\text{supplier}\text{\_}\text{B}}_{ij}$$ are dummy variables that use effects (sum-to-zero) coding to indicate whether company

`C`

or`B`

, respectively, supplied the process chemicals for the batch produced by factory $$i$$ during batch $$j$$.$${b}_{i}\sim N(0,{\sigma}_{b}^{2})$$ is a random-effects intercept for each factory $$i$$ that accounts for factory-specific variation in quality.

glme = fitglme(mfr,'defects ~ 1 + newprocess + time_dev + temp_dev + supplier + (1|factory)',... 'Distribution','Poisson','Link','log','FitMethod','Laplace','DummyVarCoding','effects')

glme = Generalized linear mixed-effects model fit by ML Model information: Number of observations 100 Fixed effects coefficients 6 Random effects coefficients 20 Covariance parameters 1 Distribution Poisson Link Log FitMethod Laplace Formula: defects ~ 1 + newprocess + time_dev + temp_dev + supplier + (1 | factory) Model fit statistics: AIC BIC LogLikelihood Deviance 416.35 434.58 -201.17 402.35 Fixed effects coefficients (95% CIs): Name Estimate SE tStat DF pValue Lower Upper {'(Intercept)'} 1.4689 0.15988 9.1875 94 9.8194e-15 1.1515 1.7864 {'newprocess' } -0.36766 0.17755 -2.0708 94 0.041122 -0.72019 -0.015134 {'time_dev' } -0.094521 0.82849 -0.11409 94 0.90941 -1.7395 1.5505 {'temp_dev' } -0.28317 0.9617 -0.29444 94 0.76907 -2.1926 1.6263 {'supplier_C' } -0.071868 0.078024 -0.9211 94 0.35936 -0.22679 0.083051 {'supplier_B' } 0.071072 0.07739 0.91836 94 0.36078 -0.082588 0.22473 Random effects covariance parameters: Group: factory (20 Levels) Name1 Name2 Type Estimate {'(Intercept)'} {'(Intercept)'} {'std'} 0.31381 Group: Error Name Estimate {'sqrt(Dispersion)'} 1

Perform an $$F$$-test to determine if all fixed-effects coefficients are equal to 0.

stats = anova(glme)

stats = ANOVA MARGINAL TESTS: DFMETHOD = 'RESIDUAL' Term FStat DF1 DF2 pValue {'(Intercept)'} 84.41 1 94 9.8194e-15 {'newprocess' } 4.2881 1 94 0.041122 {'time_dev' } 0.013016 1 94 0.90941 {'temp_dev' } 0.086696 1 94 0.76907 {'supplier' } 0.59212 2 94 0.5552

The $$p$$-values for the intercept, `newprocess`

, `time_dev`

, and `temp_dev`

are the same as in the coefficient table of the `glme`

display. The small $$p$$-values for the intercept and `newprocess`

indicate that these are significant predictors at the 5% significance level. The large $$p$$-values for `time_dev`

and `temp_dev`

indicate that these are not significant predictors at this level.

The $$p$$-value of 0.5552 for `supplier`

measures the combined significance for both coefficients representing the categorical variable `supplier`

. This includes the dummy variables `supplier_C`

and `supplier_B`

as shown in the coefficient table of the `glme`

display. The large $$p$$-value indicates that `supplier`

is not a significant predictor at the 5% significance level.

## Tips

For each fixed-effects term,

`anova`

performs an*F*-test (marginal test) to determine if all coefficients representing the fixed-effects term are equal to 0.When fitting a generalized linear mixed-effects (GLME) model using

`fitglme`

and one of the maximum likelihood fit methods (`'Laplace'`

or`'ApproximateLaplace'`

):If you specify the

`'CovarianceMethod'`

name-value pair argument as`'conditional'`

, then the*F*-tests are conditional on the estimated covariance parameters.If you specify the

`'CovarianceMethod'`

name-value pair as`'JointHessian'`

, then the*F*-tests account for the uncertainty in estimation of covariance parameters.

When fitting a GLME model using

`fitglme`

and one of the pseudo likelihood fit methods (`'MPL'`

or`'REMPL'`

),`anova`

uses the fitted linear mixed effects model from the final pseudo likelihood iteration for inference on fixed effects.

## See Also

`GeneralizedLinearMixedModel`

| `fitglme`

| `coefTest`

| `coefCI`

| `fixedEffects`

## Comando MATLAB

Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:

Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)