Control for Confounding Variables in a Linear Regression Model
26 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Johanna Popp
am 12 Mär. 2022
Kommentiert: Johanna Popp
am 14 Mär. 2022
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
0 Kommentare
Akzeptierte Antwort
Jeff Miller
am 12 Mär. 2022
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!