This is machine translation

Translated by Microsoft
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.


Class: RepeatedMeasuresModel

Generate new random response values given predictor values


ysim = random(rm,tnew)



ysim = random(rm,tnew) generates random response values from the repeated measures model rm using the predictor variables from table tnew.

Input Arguments

expand all

Repeated measures model, returned as a RepeatedMeasuresModel object.

For properties and methods of this object, see RepeatedMeasuresModel.

New data including the values of the response variables and the between-subject factors used as predictors in the repeated measures model, rm, specified as a table. tnew must contain all of the between-subject factors used to create rm.

Output Arguments

expand all

Random response values random generates, returned as an n-by-r matrix, where n is the number of rows in tnew, and r is the number of repeated measures in rm.


expand all

Load the sample data.

load fisheriris

The column vector species consists of iris flowers of three different species: setosa, versicolor, and 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),...
Meas = dataset([1 2 3 4]','VarNames',{'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);

Randomly generate new response values.

ysim = random(rm);

random uses the predictor values in the original sample data you use to fit the repeated measures model rm in table t.

Load the sample data.

load repeatedmeas

The table between includes the between-subject variables age, IQ, group, gender, and eight repeated measures through as responses. The table within includes the within-subject variables and . This is simulated data.

Fit a repeated measures model, where the repeated measures through are the responses, and age, IQ, group, gender, and the group-gender interaction are the predictor variables. Also specify the within-subject design matrix.

rm = fitrm(between,'y1-y8 ~ Group*Gender + Age + IQ','WithinDesign',within);

Define a table with new values for the predictor variables.

tnew = table(16,93,{'B'},{'Male'},'VariableNames',{'Age','IQ','Group','Gender'})
tnew =

  1x4 table

    Age    IQ    Group    Gender
    ___    __    _____    ______

    16     93    'B'      'Male'

Randomly generate new response values using the values in the new table tnew.

ysim = random(rm,tnew)
ysim =

  Columns 1 through 7

   46.2252   66.8003  -40.4987   -1.9930   27.5213  -37.9809    4.8905

  Column 8



random computes ysim by creating predicted values and adding random noise values. For each row, the noise has a multivariate normal distribution with covariance the same as rm.Covariance.

See Also


Was this topic helpful?