I conducted a multiple regression with several continuous predictors, some of which turned out significant, and I would like to create a scatter chart or a scatter chart of my DV against one of the predictors, including the "regression line", How can I do this?
My plot is as follows
D = my.data; plot( D$probCategorySame, D$posttestScore )
If it were a simple regression, I could add a regression line as follows:
lmSimple <- lm( posttestScore ~ probCategorySame, data=D ) abline( lmSimple )
But my actual model looks like this:
lmMultiple <- lm( posttestScore ~ pretestScore + probCategorySame + probDataRelated + practiceAccuracy + practiceNumTrials, data=D )
I would like to add a regression line that reflects the coefficient and interception from the actual model instead of the simplified one. I think that I would be happy to suggest averages for all other predictors to do this, although I am ready to hear advice on the contrary.
It does not matter, but just in case, I mentioned that the situation is a little complicated by the fact that I probably do not want to build the source data. Instead, I would like to calculate the average DV values ββfor the predictor bin values, for example:
D[,'probCSBinned'] = cut( my.data$probCategorySame, as.numeric( seq( 0,1,0.04 ) ), include.lowest=TRUE, right=FALSE, labels=FALSE ) D = aggregate( posttestScore~probCSBinned, data=D, FUN=mean ) plot( D$probCSBinned, D$posttestScore )
Just because it looks a lot cleaner for my data when I do it like this.