On Tue, Apr 26, 2011 at 11:18 AM, agent dunham <crossp...@hotmail.com>wrote:
> Dear community, > > As it's explained I've tried the following: > > model<- lm(log(v1)~log(v2)+v3, data=dat) > newax<- expand.grid( > v2 = seq(min(log(dat$v2)), max(log(dat$v2)), length=100), > v3= seq(min(dat$v3), max(dat$v3), length=100) > ) > fit <- predict(model,newax) > graph <- persp(x=seq(min(log(dat$v2)), max(log(dat$v2)), length=100), > y=seq(min(dat$v3), max(dat$v3), length=100), > z= matrix(fit, 100, 100), expand=0.5, ticktype="detailed", > theta=-45) > > question: I'd like to draw a line which links the fitted (x,y,z) point in > the plane, with the observed (x,y,z_o) point. How can I do it? > > Thanks in advance, u...@host.com I suggest you use regr2.plot. If you look closely you will see that regr2.plot is a wrapper for persp, the program that you have chosen to use. Its graphical properties are therefore identical to those of persp. As has been pointed out, you need to use the correct z argument, one value for each point on the grid of x and y. The vertical residuals are available in regr2.plot by specifying resid.plot=TRUE. Rich [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list 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.