Hi there I have been given code that has been used to produce a multiple regression line on a 2D plot, the code is provided below. I have got my head around what multiple regression is but am unsure exactly what is happening in the code to produce the regression line and what the two predictors being used to predict the response actually are. The arrays being used AFall(4,:) refers to an RR value and AFall(1,:) refers to a QTc value. These are labelled as the axis of the attached figure.
scatter(( AFall(4,:) ),AFall(1,:)); %plot QTc against RR
hold on;%keep the plotted data in the graph
%set bQTc coefficient estimates for y responses on x predictors
bQTc2 = regress(AFall(1,:)',[ones(length (AFall(1,:)),1) AFall(4,:)']); %plot multiple linear regression response against RR
scatter(( AFall(4,:) ), bQTc2(1)+ bQTc2(2)*AFall(4,:),'xr'); legend('AF group'); %add label to graph
It is the line starting with bQTc2 that I am having the most trouble with, it creates two values for bQTc2 (I am guessing as coeffecients for the two x predictors). I think the first predictor bQTc2(1) is based solely on the RR values (please correct me if I am wrong) but I am not sure what the bQTc2(2) values is referenced to as I don't fully understand what is happening in the code.
If someone could provide information as to what exactly is happening in the code here I would be very grateful.
Many Thanks,
Ross
Best Answer