Main Content

coefCI

Class:LinearMixedModel

Confidence intervals for coefficients of linear mixed-effects model

Description

example

feCI= coefCI(lme三个月)returns the 95% confidence intervals for the fixed-effects coefficients in the linear mixed-effects modellme三个月.

example

feCI= coefCI(lme三个月,Name,Value)returns the 95% confidence intervals for the fixed-effects coefficients in the linear mixed-effects modellme三个月with additional options specified by one or moreName,Valuepair arguments.

For example, you can specify the confidence level or method to compute the degrees of freedom.

example

[feCI,reCI] = coefCI(___)also returns the 95% confidence intervals for the random-effects coefficients in the linear mixed-effects modellme三个月.

Input Arguments

expand all

Linear mixed-effects model, specified as aLinearMixedModelobject constructed usingfitlmeorfitlmematrix.

Name-Value Arguments

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, whereNameis the argument name andValueis 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 encloseNamein quotes.

Significance 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

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 tonp, wherenis the number of observations andpis 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'

Output Arguments

expand all

Fixed-effects confidence intervals, returned as ap-by-2 matrix.feCIcontains the confidence limits that correspond to thepfixed-effects estimates in the vectorbetareturned by thefixedEffectsmethod. The first column offeCIhas the lower confidence limits and the second column has the upper confidence limits.

Random-effects confidence intervals, returned as aq-by-2 matrix.reCIcontains the confidence limits corresponding to theqrandom-effects estimates in the vectorBreturned by therandomEffectsmethod. The first column ofreCIhas the lower confidence limits and the second column has the upper confidence limits.

Examples

expand all

Load the sample data.

load('weight.mat')

weightcontains 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. DefineSubjectandProgramas 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)');

计算the fixed-effects coefficient estimates.

fe = fixedEffects(lme)
fe =9×10.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.

计算the 95% confidence intervals for the fixed-effects coefficients.

fecI = coefCI (lme)
fecI =9×20.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 p -values for each fixed-effects term, use thefixedEffectsmethod. To test for entire terms use theanovamethod.

Load the sample data.

loadcarbig

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)');

计算the fixed-effects coefficient estimates.

fe = fixedEffects(lme)
fe =3×150.1325 -0.5833 -0.1695

计算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×244.2690 55.9961 -0.9300 -0.2365 -0.1883 -0.1507

计算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×244.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.

ShiftandOperatorare 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)');

计算the estimate of the BLUPs for random effects.

randomEffects(lme)
ans =5×10.5775 1.1757 -2.1715 2.3655 -1.9472

计算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

计算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

计算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 smallerDFvalues than the residual method. That is why these confidence intervals are larger than the previous ones computed using the residual method.