[R] Accessing more than two coefficients in a plot

FJ M chicagobrownblue at hotmail.com
Sun Mar 25 23:32:06 CEST 2012


I've successfully plotted (in the plot and abline code below) a simple regression of Lambda1_2 on VV1_2. I then successfully regressed Lambda1_2 on VV1_2, VV1_22 and VV1_212 producing lm2.l. When I go to plot lm2.l using abline I get the warning:

"1: In abline(lm2.l, col = "brown", lty = "dotted", lwd = 2) : only using the first two of 4 regression coefficients"

Is there another function like abline that will produce a line using the constant and three coefficients from the lm2.l regression?


lm.l <- lm(Lambda1_2 ~ VV1_2, method = "qr", model = TRUE, x = FALSE, y = FALSE, qr = TRUE) # unweighted regression

lm2.l <- lm(Lambda1_2 ~ VV1_2 + VV1_22 + VV1_212, method = "qr", model = TRUE, x = FALSE, y = FALSE, qr = TRUE) # unweighted regression

plot(VV1_2, Lambda1_2, ylim=yrange, tck=1, main="V(1) Parameters (V, V^2 & V^0.5)", xlab="VV1_2", ylab="Lambda & Beta1_2",pch=19,col="red") 
{abline(lm2.l, col="brown", lty="dotted", lwd=2)
abline(wlm2.l, col="gold",lty="longdash", lwd=2)
points(VV1_2, Beta1_2, pch=19, col="blue")
abline(lm2.b, col="black",lty="dotted", lwd=2)
abline(wlm2.b, col="blue", lty="longdash", lwd=2)
legend("topright", inset=.05, title="Parameters",
labels, lwd=2, lty=c(1, 1, 1, 1, 2), col=colors)
} 		 	   		  


More information about the R-help mailing list