Documentation Center

  • Trial Software
  • Product Updates

fixedEffects

Class: LinearMixedModel

Estimates of fixed effects and related statistics

Syntax

  • beta = fixedEffects(lme)
  • [beta,betanames] = fixedEffects(lme) example
  • [beta,betanames,stats] = fixedEffects(lme) example
  • [beta,betanames,stats] = fixedEffects(lme,Name,Value) example

Description

beta = fixedEffects(lme) returns the estimated fixed-effects coefficients, beta, of the linear mixed-effects model lme.

example

[beta,betanames] = fixedEffects(lme) also returns the names of estimated fixed-effects coefficients in betanames. Each name corresponds to a fixed-effects coefficient in beta.

example

[beta,betanames,stats] = fixedEffects(lme) also returns the estimated fixed-effects coefficients of the linear mixed-effects model lme and related statistics in stats.

example

[beta,betanames,stats] = fixedEffects(lme,Name,Value) also returns the estimated fixed-effects coefficients of the linear mixed-effects model lme and related statistics with additional options specified by one or more Name,Value pair arguments.

Input Arguments

expand all

lme — Linear mixed-effects modelLinearMixedModel object

Linear mixed-effects model, returned as a LinearMixedModel object.

For properties and methods of this object, see LinearMixedModel.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'Alpha' — Confidence level0.05 (default) | scalar value in the range 0 to 1

Confidence 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 the t-statistic that tests the fixed-effects coefficients against 0, 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 np, 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'

Output Arguments

expand all

beta — Fixed-effects coefficients estimatesvector

Fixed-effects coefficients estimates of the fitted linear mixed-effects model lme, returned as a vector.

betanames — Names of fixed-effects coefficientstable

Names of fixed-effects coefficients in beta, returned as a table.

stats — Fixed-effects estimates and related statisticsdataset array

Fixed-effects estimates and related statistics, returned as a dataset array that has one row for each of the fixed effects and one column for each of the following statistics.

NameName of the fixed effect coefficient
EstimateEstimated coefficient value
SEStandard error of the estimate
tStatt-statistic for a test that the coefficient is zero
DFEstimated degrees of freedom for the t-statistic
pValuep-value for the t-statistic
LowerLower limit of a 95% confidence interval for the fixed-effect coefficient
UpperUpper limit of a 95% confidence interval for the fixed-effect coefficient

Examples

expand all

Display Fixed-Effects Coefficient Estimates and Names

Navigate to a folder containing sample data.

cd(matlabroot)
cd('help/toolbox/stats/examples')

Load the sample data.

load weight

The data set 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 = tbl(InitWeight,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 week and program are the fixed effects. The intercept and week vary by subject.

lme = fitlme(tbl,'y ~ InitWeight + Program*Week + (Week|Subject)');

Display the fixed-effects coefficient estimates and corresponding fixed-effects names.

[beta,betanames] = fixedEffects(lme);
beta =

    0.6610
    0.0032
    0.3608
   -0.0333
    0.1132
    0.1732
    0.0388
    0.0305
    0.0331


betanames = 

    Name                
    '(Intercept)'       
    'InitWeight'        
    'Program_B'         
    'Program_C'         
    'Program_D'         
    'Week'              
    'Program_B:Week'    
    'Program_C:Week'    
    'Program_D:Week'  

Compute Coefficient Estimates and Related Statistics

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 potentially correlated random effects 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 coefficients estimates and related statistics.

[~,~,stats] = fixedEffects(lme)
stats = 

    Fixed effect coefficients: DFMethod = 'Residual', Alpha = 0.05

    Name                  Estimate    SE           tStat      DF     pValue        Lower       Upper   
    '(Intercept)'           50.133       2.2652     22.132    389    7.7727e-71      45.679      54.586
    'Acceleration'        -0.58327      0.13394    -4.3545    389    1.7075e-05    -0.84661    -0.31992
    'Horsepower'          -0.16954    0.0072609     -23.35    389     5.188e-76    -0.18382    -0.15527

The small p-values (under pValue) indicate that all fixed-effects coefficients are significant.

Compute Confidence Intervals with Specified Options

Navigate to a folder containing sample data.

cd(matlabroot)
cd('help/toolbox/stats/examples')

Load the sample data.

load shift

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 performance significantly differs according to the time of the shift.

lme = fitlme(shift,'QCDev ~ Shift + (1|Operator)');

Compute the 99% confidence intervals for fixed-effects coefficients, using the residual method to compute the degrees of freedom. This is the default method.

[~,~,stats] = fixedEffects(lme,'alpha',0.01)
stats = 


    Fixed effect coefficients: DFMethod = 'Residual', Alpha = 0.01

    Name                   Estimate    SE         tStat       DF    pValue       Lower      Upper 
    '(Intercept)'           3.1196     0.88681      3.5178    12    0.0042407    0.41081    5.8284
    'Shift_Morning'        -0.3868     0.48344    -0.80009    12      0.43921    -1.8635    1.0899
    'Shift_Night'           1.9856     0.48344      4.1072    12    0.0014535     0.5089    3.4623

Compute the 99% confidence intervals for fixed-effects coefficients, using the Satterthwaite approximation to compute the degrees of freedom.

[~,~,stats] = fixedEffects(lme,'DFMethod','Satterthwaite','alpha',0.01)
stats = 


    Fixed effect coefficients: DFMethod = 'Satterthwaite', Alpha = 0.01

    Name                   Estimate    SE         tStat       DF       pValue     Lower       Upper 
    '(Intercept)'           3.1196     0.88681      3.5178    6.123    0.01214    -0.14122    6.3804
    'Shift_Morning'        -0.3868     0.48344    -0.80009       10    0.44225      -1.919    1.1454
    'Shift_Night'           1.9856     0.48344      4.1072       10    0.00212     0.45343    3.5178

The Satterthwaite approximation usually produces smaller DF values than the residual method. That is why it produces larger p-values (pValue) and larger confidence intervals (see Lower and Upper).

See Also

| | | |

Was this topic helpful?