Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

RepeatedMeasuresModel class

Repeated measures model class

Description

A `RepeatedMeasuresModel` object represents a model fitted to data with multiple measurements per subject. The object comprises data, fitted coefficients, covariance parameters, design matrix, error degrees of freedom, and between- and within-subjects factor names for a repeated measures model. You can predict model responses using the `predict` method and generate random data at new design points using the `random` method.

Construction

You can fit a repeated measures model using `fitrm(t,modelspec)`.

Input Arguments

expand all

Input data, which includes the values of the response variables and the between-subject factors to use as predictors in the repeated measures model, specified as a table.

Data Types: `table`

Formula for model specification, specified as a character vector of the form `'y1-yk ~ terms'`. Specify the terms using Wilkinson notation. `fitrm` treats the variables used in model terms as categorical if they are categorical (nominal or ordinal), logical, character arrays, or a cell array of character vectors.

Example: `'y1-y4 ~ x1 + x2 * x3'`

Properties

expand all

Design for between-subject factors and values of repeated measures, stored as a table.

Data Types: `table`

Model for between-subjects factors, stored as a character vector. This character vector is the text representation to the right of the tilde in the model specification you provide when fitting the repeated measures model using `fitrm`.

Data Types: `char`

Names of variables used as between-subject factors in the repeated measures model, `rm`, stored as a cell array of character vectors.

Data Types: `cell`

Names of variables used as response variables in the repeated measures model, `rm`, stored as a cell array of character vectors.

Data Types: `cell`

Values of the within-subject factors, stored as a table.

Data Types: `table`

Model for within-subjects factors, stored as a character vector.

Data Types: `char`

Names of the within-subject factors, stored as a cell array of character vectors.

Data Types: `cell`

Values of the estimated coefficients for fitting the repeated measures as a function of the terms in the between-subjects model, stored as a table.

`fitrm'` defines the coefficients for a categorical term using 'effects' coding, which means coefficients sum to 0. There is one coefficient for each level except the first. The implied coefficient for the first level is the sum of the other coefficients for the term.

You can display the coefficient values as a matrix rather than a table using `coef = r.Coefficients{:,:}`.

You can display marginal means for all levels using the `margmean` method.

Data Types: `table`

Estimated response covariances, that is, covariance of the repeated measures, stored as a table. `fitrm` computes the covariances around the mean returned by the fitted repeated measures model `rm`.

You can display the covariance values as a matrix rather than a table using `coef = r.Covariance{:,:}`.

Data Types: `table`

Error degrees of freedom, stored as a scalar value. `DFE` is the number of observations minus the number of estimated coefficients in the between-subjects model.

Data Types: `double`

Methods

 anova Analysis of variance for between-subject effects epsilon Epsilon adjustment for repeated measures anova grpstats Compute descriptive statistics of repeated measures data by group manova Multivariate analysis of variance margmean Estimate marginal means mauchly Mauchly’s test for sphericity multcompare Multiple comparison of estimated marginal means plot Plot data with optional grouping plotprofile Plot expected marginal means with optional grouping predict Compute predicted values given predictor values random Generate new random response values given predictor values ranova Repeated measures analysis of variance

Examples

expand all

Load the sample data.

```load fisheriris ```

The column vector, `species`, consists of iris flowers of three different species: setosa, versicolor, virginica. The double matrix `meas` consists of four types of measurements on the flowers: the length and width of sepals and petals in centimeters, respectively.

Store the data in a table array.

```t = table(species,meas(:,1),meas(:,2),meas(:,3),meas(:,4),... 'VariableNames',{'species','meas1','meas2','meas3','meas4'}); Meas = table([1 2 3 4]','VariableNames',{'Measurements'}); ```

Fit a repeated measures model, where the measurements are the responses and the species is the predictor variable.

```rm = fitrm(t,'meas1-meas4~species','WithinDesign',Meas) ```
```rm = RepeatedMeasuresModel with properties: Between Subjects: BetweenDesign: [150x5 table] ResponseNames: {'meas1' 'meas2' 'meas3' 'meas4'} BetweenFactorNames: {'species'} BetweenModel: '1 + species' Within Subjects: WithinDesign: [4x1 table] WithinFactorNames: {'Measurements'} WithinModel: 'separatemeans' Estimates: Coefficients: [3x4 table] Covariance: [4x4 table] ```

Display the coefficients.

```rm.Coefficients ```
```ans = 3x4 table meas1 meas2 meas3 meas4 ________ ________ ______ ________ (Intercept) 5.8433 3.0573 3.758 1.1993 species_setosa -0.83733 0.37067 -2.296 -0.95333 species_versicolor 0.092667 -0.28733 0.502 0.12667 ```

`fitrm` uses the `'effects'` contrasts, which means that the coefficients sum to 0. The `rm.DesignMatrix` has one column of 1s for the intercept, and two other columns `species_setosa` and `species_versicolor`, which are as follows:

and

Display the covariance matrix.

```rm.Covariance ```
```ans = 4x4 table meas1 meas2 meas3 meas4 ________ ________ ________ ________ meas1 0.26501 0.092721 0.16751 0.038401 meas2 0.092721 0.11539 0.055244 0.03271 meas3 0.16751 0.055244 0.18519 0.042665 meas4 0.038401 0.03271 0.042665 0.041882 ```

Display the error degrees of freedom.

```rm.DFE ```
```ans = 147 ```

The error degrees of freedom is the number of observations minus the number of estimated coefficients in the between-subjects model, e.g. 150 – 3 = 147.

expand all

See Also

Topics

Was this topic helpful?

Download now