Control for Confounding Variables in a Linear Regression Model

30 ビュー (過去 30 日間)
Johanna Popp
Johanna Popp 2022 年 3 月 12 日
コメント済み: Johanna Popp 2022 年 3 月 14 日
Hi All,
I am trying to fit a multiple linear regression model to my data using the function fitlm(x) and I'm wondering how to go about controlling for some confounding variables in the model, and later the prediction of my dependent variable. Are there different possibilities to do so? I was using the regress(x) function ro regress out the confounding variables & then using the residuals of the independent variables to fit the model. I'm not sure if that's the correct approach and I'm thankful for any suggestions and input!
Thanks,
Johanna

採用された回答

Jeff Miller
Jeff Miller 2022 年 3 月 12 日
Suppose you have a variable X that you would like to predict from a set of predictors P and you want to control for some other variables C. The standard approach is to make a comparison between two models:
% I probably don't have the syntax quite right because I don't use fitlm
% much, but hopefully this will convey the idea:
mdl1 = fitlm(x,C); % predict x from C alone
mdl2 = fitlm(x,[C P]); % predict x from C & P
The improvement of mdl2 over mdl1 (e.g., increase in SSmodel, decrease in SSerror) is then attributed to the predictors in P "controlling for" those in C. For more detail, you might look at Chapter 15 of this online book.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSupport Vector Machine Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by