Get the design matrix from a linear mixed model

조회 수: 3 (최근 30일)
Armand Mensen
Armand Mensen 2016년 11월 4일
답변: Xue Zhang 2021년 5월 7일
When running a linear mixed model, using the fitlme function...
formula = 'dependent ~ predictor1 * predictor2';
model_object = fitlme(dataset, formula);
... you can extract the design matrix after you have run the model using the following code:
% get fixed effect design
design_fixed = designMatrix(model_object, 'fixed');
However, I'd rather not have to run the whole model every time I want to just get the design matrix. So I'm looking for a function that will output the design matrix given the dataset table and the formula used in the model. For example:
design_matrix = designFromFormula(formula, dataset, dummyvarcoding);
Precisely such a function already exists buried deep within the 'LinearMixedModels.m' at line 1392; but this function is private so I cannot access it. Nor can I re-engineer exactly what it is doing.
Does someone know how I could use this private function, or have another way to 'extract' the design matrix for a linear mixed model (just the fixed effects to be specific), without having to actually estimate the model?
Thank you!

답변 (1개)

Xue Zhang
Xue Zhang 2021년 5월 7일
Hi I am also looking for a such solution, have you figured out how to implment designFromFormula?

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by