Regress out a variable using stepwiselm?

8 ビュー (過去 30 日間)
Michaela Warnecke
Michaela Warnecke 2022 年 1 月 19 日
回答済み: Ayush Aniket 2023 年 11 月 29 日
Hi all,
I have a table that contains M x N predictor variables and a M x 1 response variable. The first M/2 x N predictor observations come from the same subject as the remaining M/2 x N observations (i.e. if I have 100 rows, data in rows 1:50 come from subject 1:50, and data in rows 51:100 come from subject 1:50 - they are different measures of the same subject, e.g. left arm length and right arm length).
I want to build a linear model that predicts the response variable from the predictor variables, while accounting for the fact that there is a relationship (i.e. interaction) between rows 1 and 51, rows 2 and 52, rows 3 and 53 etc. I've tried adding an index column to the table -- without much success.
I'm unsure about how to add this term in stepwiselm, or whether another function might be more appropriate?
Thank you!

採用された回答

Ayush Aniket
Ayush Aniket 2023 年 11 月 29 日
Hi Michaela,
I understand that you want to fit a linear model to your data that predicts the response variable from the predictor variables, while accounting for the fact that there is a relationship between rows in the data.
The function “stepwiselmperforms stepwise regression and its goal is to find a model that includes only the predictors that significantly contribute to the model, thereby simplifying the model without sacrificing explanatory power. This will not be suitable for your data which has an inherent relationship between rows.
For your dataset, you can use a mixed-effects model, which allows you to include both fixed effects (the predictor variables) and random effects (the subject-specific effects). In MATLAB, you can use the "fitlme" function from the Statistics and Machine Learning Toolbox to fit a linear mixed-effects model.
The relationship information can be fed to the ‘formula’ argument of the "fitlme" function. For more information about the function and relevant examples, please refer to the following documentation page:
Hope it helps!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeModel Building and Assessment についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by