coefCI
Class: GeneralizedLinearMixedModel
Confidence intervals for coefficients of generalized linear mixed-effects model
Description
returns
the confidence intervals using additional options specified by one
or more feCI
= coefCI(glme
,Name,Value
)Name,Value
pair arguments. For example,
you can specify a different confidence level or the method used to
compute the approximate degrees of freedom.
Input Arguments
glme
— Generalized linear mixed-effects model
GeneralizedLinearMixedModel
object
Generalized linear mixed-effects model, specified as a GeneralizedLinearMixedModel
object.
For properties and methods of this object, see GeneralizedLinearMixedModel
.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is 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 enclose
Name
in quotes.
Alpha
— Significance level
0.05 (default) | scalar value in the range [0,1]
Significance level, specified as the comma-separated pair consisting of
'Alpha'
and a scalar value in the range [0,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) | 'none'
Method for computing approximate degrees of freedom, specified
as the comma-separated pair consisting of 'DFMethod'
and
one of the following.
Value | Description |
---|---|
'residual' | The degrees of freedom value is assumed to be constant and equal to n – p, where n is the number of observations and p is the number of fixed effects. |
'none' | The degrees of freedom is set to infinity. |
Example: 'DFMethod','none'
Output Arguments
feCI
— Fixed-effects confidence intervals
p-by-2 matrix
Fixed-effects confidence intervals, returned as a p-by-2
matrix. feCI
contains the confidence limits that
correspond to the p-by-1 fixed-effects vector returned
by the fixedEffects
method. The first column of feCI
contains
the lower confidence limits and the second column contains the upper
confidence limits.
When fitting a GLME model using fitglme
and
one of the maximum likelihood fit methods ('Laplace'
or 'ApproximateLaplace'
):
If you specify the
'CovarianceMethod'
name-value pair argument as'conditional'
, then the confidence intervals are conditional on the estimated covariance parameters.If you specify the
'CovarianceMethod'
name-value pair argument as'JointHessian'
, then the confidence intervals account for the uncertainty in the estimated covariance parameters.
When fitting a GLME model using fitglme
and
one of the pseudo likelihood fit methods ('MPL'
or 'REMPL'
), coefci
uses
the fitted linear mixed effects model from the final pseudo likelihood
iteration to compute confidence intervals on the fixed effects.
reCI
— Random-effects confidence intervals
q-by-2 matrix
Random-effects confidence intervals, returned as a q-by-2
matrix. reCI
contains the confidence limits corresponding
to the q-by-1 random-effects vector B
returned
by the randomEffects
method. The first column of reCI
contains
the lower confidence limits, and the second column contains the upper
confidence limits.
When fitting a GLME model using fitglme
and
one of the maximum likelihood fit methods ('Laplace'
or 'ApproximateLaplace'
), coefCI
computes
the confidence intervals using the conditional mean squared error
of prediction (CMSEP) approach conditional on the estimated covariance
parameters and the observed response. Alternatively, you can interpret
the confidence intervals from coefCI
as approximate
Bayesian credible intervals conditional on the estimated covariance
parameters and the observed response.
When fitting a GLME model using fitglme
and
one of the pseudo likelihood fit methods ('MPL'
or 'REMPL'
), coefci
uses
the fitted linear mixed effects model from the final pseudo likelihood
iteration to compute confidence intervals on the random effects.
Examples
95% Confidence Intervals for Fixed Effects
Load the sample data.
load mfr
This simulated data is from a manufacturing company that operates 50 factories across the world, with each factory running a batch process to create a finished product. The company wants to decrease the number of defects in each batch, so it developed a new manufacturing process. To test the effectiveness of the new process, the company selected 20 of its factories at random to participate in an experiment: Ten factories implemented the new process, while the other ten continued to run the old process. In each of the 20 factories, the company ran five batches (for a total of 100 batches) and recorded the following data:
Flag to indicate whether the batch used the new process (
newprocess
)Processing time for each batch, in hours (
time
)Temperature of the batch, in degrees Celsius (
temp
)Categorical variable indicating the supplier (
A
,B
, orC
) of the chemical used in the batch (supplier
)Number of defects in the batch (
defects
)
The data also includes time_dev
and temp_dev
, which represent the absolute deviation of time and temperature, respectively, from the process standard of 3 hours at 20 degrees Celsius.
Fit a generalized linear mixed-effects model using newprocess
, time_dev
, temp_dev
, and supplier
as fixed-effects predictors. Include a random-effects term for intercept grouped by factory
, to account for quality differences that might exist due to factory-specific variations. The response variable defects
has a Poisson distribution, and the appropriate link function for this model is log. Use the Laplace fit method to estimate the coefficients. Specify the dummy variable encoding as 'effects'
, so the dummy variable coefficients sum to 0.
The number of defects can be modeled using a Poisson distribution
This corresponds to the generalized linear mixed-effects model
where
is the number of defects observed in the batch produced by factory during batch .
is the mean number of defects corresponding to factory (where ) during batch (where ).
, , and are the measurements for each variable that correspond to factory during batch . For example, indicates whether the batch produced by factory during batch used the new process.
and are dummy variables that use effects (sum-to-zero) coding to indicate whether company
C
orB
, respectively, supplied the process chemicals for the batch produced by factory during batch .is a random-effects intercept for each factory that accounts for factory-specific variation in quality.
glme = fitglme(mfr,'defects ~ 1 + newprocess + time_dev + temp_dev + supplier + (1|factory)','Distribution','Poisson','Link','log','FitMethod','Laplace','DummyVarCoding','effects');
Use fixedEffects
to display the estimates and names of the fixed-effects coefficients in glme
.
[beta,betanames] = fixedEffects(glme)
beta = 6×1
1.4689
-0.3677
-0.0945
-0.2832
-0.0719
0.0711
betanames=6×1 table
Name
_______________
{'(Intercept)'}
{'newprocess' }
{'time_dev' }
{'temp_dev' }
{'supplier_C' }
{'supplier_B' }
Each row of beta
contains the estimated value for the coefficient named in the corresponding row of betanames
. For example, the value –0.0945 in row 3 of beta
is the estimated coefficient for the predictor variable time_dev
.
Compute the 95% confidence intervals for the fixed-effects coefficients.
feCI = coefCI(glme)
feCI = 6×2
1.1515 1.7864
-0.7202 -0.0151
-1.7395 1.5505
-2.1926 1.6263
-0.2268 0.0831
-0.0826 0.2247
Column 1 of feCI
contains the lower bound of the 95% confidence interval. Column 2 contains the upper bound. Row 1 corresponds to the intercept term. Rows 2, 3, and 4 correspond to newprocess
, time_dev
, and temp_dev
, respectively. Rows 5 and 6 correspond to the indicator variables supplier_C
and supplier_B
, respectively. For example, the 95% confidence interval for the coefficient for time_dev
is [-1.7395 , 1.5505]. Some of the confidence intervals include 0, which indicates that those predictors are not significant at the 5% significance level. To obtain specific -values for each fixed-effects term, use fixedEffects
. To test significance for entire terms, use anova
.
99% Confidence Intervals for Random Effects
Load the sample data.
load mfr
This simulated data is from a manufacturing company that operates 50 factories across the world, with each factory running a batch process to create a finished product. The company wants to decrease the number of defects in each batch, so it developed a new manufacturing process. To test the effectiveness of the new process, the company selected 20 of its factories at random to participate in an experiment: Ten factories implemented the new process, while the other ten continued to run the old process. In each of the 20 factories, the company ran five batches (for a total of 100 batches) and recorded the following data:
Flag to indicate whether the batch used the new process (
newprocess
)Processing time for each batch, in hours (
time
)Temperature of the batch, in degrees Celsius (
temp
)Categorical variable indicating the supplier (
A
,B
, orC
) of the chemical used in the batch (supplier
)Number of defects in the batch (
defects
)
The data also includes time_dev
and temp_dev
, which represent the absolute deviation of time and temperature, respectively, from the process standard of 3 hours at 20 degrees Celsius.
Fit a generalized linear mixed-effects model using newprocess
, time_dev
, temp_dev
, and supplier
as fixed-effects predictors. Include a random-effects intercept grouped by factory
, to account for quality differences that might exist due to factory-specific variations. The response variable defects
has a Poisson distribution, and the appropriate link function for this model is log. Use the Laplace fit method to estimate the coefficients.
The number of defects can be modeled using a Poisson distribution
This corresponds to the generalized linear mixed-effects model
where
is the number of defects observed in the batch produced by factory during batch .
is the mean number of defects corresponding to factory (where ) during batch (where ).
, , and are the measurements for each variable that correspond to factory during batch . For example, indicates whether the batch produced by factory during batch used the new process.
and are dummy variables that use effects (sum-to-zero) coding to indicate whether company
C
orB
, respectively, supplied the process chemicals for the batch produced by factory during batch .is a random-effects intercept for each factory that accounts for factory-specific variation in quality.
glme = fitglme(mfr,'defects ~ 1 + newprocess + time_dev + temp_dev + supplier + (1|factory)','Distribution','Poisson','Link','log','FitMethod','Laplace','DummyVarCoding','effects');
Use randomEffects
to compute and display the estimates of the empirical Bayes predictors (EBPs) for the random effects associated with factory
.
[B,Bnames] = randomEffects(glme)
B = 20×1
0.2913
0.1542
-0.2633
-0.4257
0.5453
-0.1069
0.3040
-0.1653
-0.1458
-0.0816
⋮
Bnames=20×3 table
Group Level Name
___________ ______ _______________
{'factory'} {'1' } {'(Intercept)'}
{'factory'} {'2' } {'(Intercept)'}
{'factory'} {'3' } {'(Intercept)'}
{'factory'} {'4' } {'(Intercept)'}
{'factory'} {'5' } {'(Intercept)'}
{'factory'} {'6' } {'(Intercept)'}
{'factory'} {'7' } {'(Intercept)'}
{'factory'} {'8' } {'(Intercept)'}
{'factory'} {'9' } {'(Intercept)'}
{'factory'} {'10'} {'(Intercept)'}
{'factory'} {'11'} {'(Intercept)'}
{'factory'} {'12'} {'(Intercept)'}
{'factory'} {'13'} {'(Intercept)'}
{'factory'} {'14'} {'(Intercept)'}
{'factory'} {'15'} {'(Intercept)'}
{'factory'} {'16'} {'(Intercept)'}
⋮
Each row of B
contains the estimated EBPs for the random-effects coefficient named in the corresponding row of Bnames
. For example, the value -0.2633 in row 3 of B
is the estimated coefficient of '(Intercept)'
for level '3'
of factory
.
Compute the 99% confidence intervals of the EBPs for the random effects.
[feCI,reCI] = coefCI(glme,'Alpha',0.01);
reCI
reCI = 20×2
-0.2125 0.7951
-0.3510 0.6595
-0.8219 0.2954
-0.9953 0.1440
0.0730 1.0176
-0.6362 0.4224
-0.1796 0.7877
-0.7044 0.3738
-0.6795 0.3880
-0.6142 0.4509
⋮
Column 1 of reCI
contains the lower bound of the 99% confidence interval. Column 2 contains the upper bound. Each row corresponds to a level of factory
, in the order shown in Bnames
. For example, row 3 corresponds to the coefficient of '(Intercept)'
for level '3'
of factory
, which has a 99% confidence interval of [-0.8219 , 0.2954]. For additional statistics related to each random-effects term, use randomEffects
.
References
[1] Booth, J.G., and J.P. Hobert. “Standard Errors of Prediction in Generalized Linear Mixed Models.” Journal of the American Statistical Association. Vol. 93, 1998, pp. 262–272.
See Also
GeneralizedLinearMixedModel
| anova
| coefTest
| covarianceParameters
| fixedEffects
| randomEffects
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)