I have data from survey, and Trying to build a linear regression model using R like A~ B however, want to control C, D, E, F, G. like Age, Sex, and other confounding variables. I tried to make some models using lm, glm, etc. and fitted it to my data.
However, in Multivariate regression models, I cannot get the graph like below. To use 'segmented' function of R to cut-off point, I guess, I should able to get estimated equation between A and B, while all other variables are controlled.
The image above describes what I want to do. linear model between A and B, but actual model includes confounders C, D, F, and somehow'controlled' them. The author described that
fitted the two linear regression models for high B and low B, and calculated the sums of squares of residuals (=observed A -estimated A), from the two models for each B. The models with the lowest residual sums of squares were the best models.
It seems to be drawn from R(and author said so), but I cannot find any good approach.
I'm afraid this question seems to 'tool specific' question/ If so, I'll amend this question, and update it with any help I got.