Hi R folks, In my previous post I forgot to mention that I was new to R. I was really grateful for your quick help. I have two further questions: 1) In the graph of a regression line I would like to show one specific residual yi obs - yi pred (let's take the person whose residual is 76). How do I add a bracket to this vertical distance and name it? I'am getting stuck after the "textxy" function. Age <- c(39, 47, 45, 47, 65, 46, 67, 42, 67, 56, 64, 56, 59, 34, 42, 48, 45, 17, 20, 19, 36, 50, 39, 21, 44, 53, 63, 29, 25, 69) BloodPressure <- c(144, 220, 138, 145, 162, 142, 170, 124, 158, 154, 162, 150, 140, 110, 128, 130, 135, 114, 116, 124, 136, 142, 120, 120, 160, 158, 144, 130, 125, 175) mean(Age) mean(BloodPressure) SimpleLinearReg1 <- lm(BloodPressure ~ Age) summary(SimpleLinearReg1) coeff <-coefficients(SimpleLinearReg1) coeff eq <- as.formula( paste0("y ~ ", round(coefficients(SimpleLinearReg1)[1],2), "", paste(sprintf(" %+.2f*%s ", coefficients(SimpleLinearReg1)[-1], names(coefficients(SimpleLinearReg1)[-1])), collapse=""))) eq <- paste0("y = ", round(coeff[2],1), "x + ", round(coeff[1],1)) plot(Age, BloodPressure, pch = 16, cex = 1.3, col = "blue", main = "Graphe de la relation entre l'âge et la pression artérielle", xlab = "Age (année)", ylab = "Pression artérielle (mmHg)") abline(SimpleLinearReg1, col="red") res <- signif(residuals(SimpleLinearReg1), 2) pre <- predict(SimpleLinearReg1) segments(Age, BloodPressure, Age, pre, col="red") library(calibrate) textxy(Age, BloodPressure, res, cex=0.7) 2)
2) I also need your help plotting a hyperplan for a multiple regression and here I am really stuck... inc <- c(25000, 28000, 17500, 30000, 25000, 32000, 30000, 29000, 26000, 40000) age <- c(60, 36, 21, 35, 33, 43, 29, 45, 41, 48) educ <- c(12, 12, 13, 16, 16, 12, 13, 15, 15, 20) MultLinearReg1 <- lm(inc ~ age + educ) summary(MultLinearReg1) Thank you so much! ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.