How do I Plot a Regression Line (not simple regression) on gscatter?
2 views (last 30 days)
I have a scatter plot that I made in gscatter. I wish to add a regression line (which I already have paremeters such as slope for calculated). I can't add a simple regression line (as most existing code and examples use) as I need a Model II regression (I have code for this, to calculate slope, y-intercept, etc.), but I am unsure how to add a Model II regression line, given that I have the slope, etc., onto this gscatter plot. Does anyone have any idea as to possible solutions?
Thank you for your time.
Jeff Miller on 23 Jun 2022
Something like this should work, after your gscatter:
lowX = 0; % set low & hi X to span the x-axis range that you want the line to cover.
hiX = 100;
predYatlowX = intercept * slope*lowX; % using the slope & intercept values from your model
predYathiX = intercept * slope*hiX;
plot([lowX, hiX],[predYatlowX, predYathiX],'-')