fitted
Class: GeneralizedLinearMixedModel
Fitted responses from generalized linear mixed-effects model
Description
Input Arguments
Generalized linear mixed-effects model, specified as a GeneralizedLinearMixedModel
object.
For properties and methods of this object, see GeneralizedLinearMixedModel
.
Indicator for conditional response, specified as one of the following.
Value | Description |
---|---|
true | Contributions from both fixed effects and random effects (conditional) |
false | Contribution from only fixed effects (marginal) |
To obtain fitted marginal response values, fitted
computes the conditional mean of the response with the
empirical Bayes predictor vector of random effects b set
equal to 0. For more information, see Conditional and Marginal Response
Example: Conditional=false
Output Arguments
Fitted response values, returned as an n-by-1 vector, where n is the number of observations.
Examples
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');
Generate the fitted conditional mean values for the model.
mufit = fitted(glme);
Create a scatterplot of the observed values versus fitted values.
figure scatter(mfr.defects,mufit) title('Residuals versus Fitted Values') xlabel('Fitted Values') ylabel('Residuals')
More About
A conditional response includes contributions from both fixed- and random-effects predictors. A marginal response includes contribution from only fixed effects.
Suppose the generalized linear mixed-effects model glme
has
an n-by-p fixed-effects design
matrix X
and an n-by-q random-effects
design matrix Z
. Also, suppose the estimated p-by-1
fixed-effects vector is ,
and the q-by-1 empirical Bayes predictor vector
of random effects is .
The fitted conditional response corresponds to the 'Conditional',true
name-value
pair argument, and is defined as
where is the linear predictor including the fixed- and random-effects of the generalized linear mixed-effects model
The fitted marginal response corresponds to the 'Conditional',false
name-value
pair argument, and is defined as
where is the linear predictor including only the fixed-effects portion of the generalized linear mixed-effects model
See Also
GeneralizedLinearMixedModel
| fitglme
| residuals
| response
| designMatrix
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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)