Class: LinearMixedModel
Confidence intervals for coefficients of linear mixed-effects model
returns
the 95% confidence intervals for the fixed-effects coefficients in
the linear mixed-effects model feCI
= coefCI(lme
,Name,Value
)lme
with additional
options specified by one or more Name,Value
pair
arguments.
For example, you can specify the confidence level or method to compute the degrees of freedom.
lme
— Linear mixed-effects modelLinearMixedModel
objectLinear mixed-effects model, specified as a LinearMixedModel
object constructed using fitlme
or fitlmematrix
.
Specify optional
comma-separated pairs of Name,Value
arguments. Name
is
the argument name and Value
is the corresponding value.
Name
must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN
.
'Alpha'
— Significance levelSignificance level, specified as the comma-separated pair consisting of
'Alpha'
and a scalar value in the range 0 to 1. For a value α,
the confidence level is 100*(1–α)%.
For example, for 99% confidence intervals, you can specify the confidence level as follows.
Example: 'Alpha',0.01
Data Types: single
| double
'DFMethod'
— Method for computing approximate degrees of freedom'residual'
(default) | 'satterthwaite'
| 'none'
Method for computing approximate degrees of freedom for confidence
interval computation, specified as the comma-separated pair consisting
of 'DFMethod'
and one of the following.
'residual' | Default. 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. |
'satterthwaite' | Satterthwaite approximation. |
'none' | All degrees of freedom are set to infinity. |
For example, you can specify the Satterthwaite approximation as follows.
Example: 'DFMethod','satterthwaite'
feCI
— Fixed-effects confidence intervalsFixed-effects confidence intervals, returned as a p-by-2
matrix. feCI
contains the confidence limits that
correspond to the p fixed-effects estimates in
the vector beta
returned by the fixedEffects
method.
The first column of feCI
has the lower confidence
limits and the second column has the upper confidence limits.
reCI
— Random-effects confidence intervalsRandom-effects confidence intervals, returned as a q-by-2
matrix. reCI
contains the confidence limits corresponding
to the q random-effects estimates in the vector B
returned
by the randomEffects
method. The first column of reCI
has
the lower confidence limits and the second column has the upper confidence
limits.
Load the sample data.
load('weight.mat')
weight
contains data from a longitudinal study, where 20 subjects are randomly assigned to 4 exercise programs, and their weight loss is recorded over six 2-week time periods. This is simulated data.
Store the data in a table. Define Subject
and Program
as categorical variables.
tbl = table(InitialWeight, Program, Subject,Week, y); tbl.Subject = nominal(tbl.Subject); tbl.Program = nominal(tbl.Program);
Fit a linear mixed-effects model where the initial weight, type of program, week, and the interaction between the week and type of program are the fixed effects. The intercept and week vary by subject.
lme = fitlme(tbl,'y ~ InitialWeight + Program*Week + (Week|Subject)');
Compute the fixed-effects coefficient estimates.
fe = fixedEffects(lme)
fe = 9×1
0.6610
0.0032
0.3608
-0.0333
0.1132
0.1732
0.0388
0.0305
0.0331
The first estimate, 0.6610, corresponds to the constant term. The second row, 0.0032, and the third row, 0.3608, are estimates for the coefficient of initial weight and week, respectively. Rows four to six correspond to the indicator variables for programs B-D, and the last three rows correspond to the interaction of programs B-D and week.
Compute the 95% confidence intervals for the fixed-effects coefficients.
fecI = coefCI(lme)
fecI = 9×2
0.1480 1.1741
0.0005 0.0059
0.1004 0.6211
-0.2932 0.2267
-0.1471 0.3734
0.0395 0.3069
-0.1503 0.2278
-0.1585 0.2196
-0.1559 0.2221
Some confidence intervals include 0. To obtain specific -values for each fixed-effects term, use the fixedEffects
method. To test for entire terms use the anova
method.
Load the sample data.
load carbig
Fit a linear mixed-effects model for miles per gallon (MPG), with fixed effects for acceleration and horsepower, and a potentially correlated random effect for intercept and acceleration grouped by model year. First, store the data in a table.
tbl = table(Acceleration,Horsepower,Model_Year,MPG);
Fit the model.
lme = fitlme(tbl, 'MPG ~ Acceleration + Horsepower + (Acceleration|Model_Year)');
Compute the fixed-effects coefficient estimates.
fe = fixedEffects(lme)
fe = 3×1
50.1325
-0.5833
-0.1695
Compute the 99% confidence intervals for fixed-effects coefficients using the residuals method to determine the degrees of freedom. This is the default method.
feCI = coefCI(lme,'Alpha',0.01)
feCI = 3×2
44.2690 55.9961
-0.9300 -0.2365
-0.1883 -0.1507
Compute the 99% confidence intervals for fixed-effects coefficients using the Satterthwaite approximation to compute the degrees of freedom.
feCI = coefCI(lme,'Alpha',0.01,'DFMethod','satterthwaite')
feCI = 3×2
44.0949 56.1701
-0.9640 -0.2025
-0.1884 -0.1507
The Satterthwaite approximation produces similar confidence intervals than the residual method.
Load the sample data.
load('shift.mat')
The data shows the deviations from the target quality characteristic measured from the products that five operators manufacture during three shifts: morning, evening, and night. This is a randomized block design, where the operators are the blocks. The experiment is designed to study the impact of the time of shift on the performance. The performance measure is the deviation of the quality characteristics from the target value. This is simulated data.
Shift
and Operator
are nominal variables.
shift.Shift = nominal(shift.Shift); shift.Operator = nominal(shift.Operator);
Fit a linear mixed-effects model with a random intercept grouped by operator to assess if there is significant difference in the performance according to the time of the shift.
lme = fitlme(shift,'QCDev ~ Shift + (1|Operator)');
Compute the estimate of the BLUPs for random effects.
randomEffects(lme)
ans = 5×1
0.5775
1.1757
-2.1715
2.3655
-1.9472
Compute the 95% confidence intervals for random effects.
[~,reCI] = coefCI(lme)
reCI = 5×2
-1.3916 2.5467
-0.7934 3.1449
-4.1407 -0.2024
0.3964 4.3347
-3.9164 0.0219
Compute the 99% confidence intervals for random effects using the residuals method to determine the degrees of freedom. This is the default method.
[~,reCI] = coefCI(lme,'Alpha',0.01)
reCI = 5×2
-2.1831 3.3382
-1.5849 3.9364
-4.9322 0.5891
-0.3951 5.1261
-4.7079 0.8134
Compute the 99% confidence intervals for random effects using the Satterthwaite approximation to determine the degrees of freedom.
[~,reCI] = coefCI(lme,'Alpha',0.01,'DFMethod','satterthwaite')
reCI = 5×2
-2.6840 3.8390
-2.0858 4.4372
-5.4330 1.0900
-0.8960 5.6270
-5.2087 1.3142
The Satterthwaite approximation might produce smaller DF
values than the residual method. That is why these confidence intervals are larger than the previous ones computed using the residual method.
You have a modified version of this example. Do you want to open this example with your edits?