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, user at host.com
--
View this message in context: http://r.789695.n4.nabble.com/graphics-3D-regression-plane-tp3214007p3475718.html
Sent from the R help mailing list archive at Nabble.com.
graphics: 3D regression plane
5 messages · Richard M. Heiberger, agent dunham, Paul Johnson
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110426/eba56ed1/attachment.pl>
Hi, thanks, I think I've changed the previous as you told me but I'm having
this error, what does it mean?
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 <- regr2.plot(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), main="Least-squares",
resid.plot= TRUE, plot.base.points= TRUE, expand=0.5,
ticktype="detailed", theta=-45)
Error en cbind(x, y, z, 1) %*% pmat : argumentos no compatibles
Thanks again, user at host.com
--
View this message in context: http://r.789695.n4.nabble.com/graphics-3D-regression-plane-tp3214007p3477439.html
Sent from the R help mailing list archive at Nabble.com.
Dear community, Thanks for regr2.plot. I've another question. When fixing OLS I used training data and test data. I'd like to know if it's possible to draw the plane I've fixed with the training data, and draw the observed and predicted points achieved with the test data. If so any help or reference would be much appreciated. Thanks in advance, user at host.com -- View this message in context: http://r.789695.n4.nabble.com/graphics-3D-regression-plane-tp3214007p3477510.html Sent from the R help mailing list archive at Nabble.com.
Hi. Comments below
On Wed, Apr 27, 2011 at 2:32 AM, agent dunham <crosspide at hotmail.com> wrote:
Hi, thanks, I think I've changed the previous as you told me but I'm having this error, what does it mean? 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 <- regr2.plot(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), main="Least-squares", ? ? ? ? ? ? resid.plot= TRUE, plot.base.points= TRUE, expand=0.5, ticktype="detailed", theta=-45) Error en cbind(x, y, z, 1) %*% pmat : argumentos no compatibles Thanks again, user at host.com
I've struggled with these 3d things before. You should supply us the
full testable program to fix. Here I've fiddled around and can get a
plot from persp or regr2.plot, but I understand it is not informative.
But the plot does run, and maybe you will see how to fix.
Generally, I would suggest you do the separate work in separate steps,
not all jammed together inside regr2.plot. If you do each bit
separately, then you can inspect the result and be sure it is good.
See:
##PJ 2011-04-27
## testing to address question in r-help on persp and regr2.plot
v1 <- rnorm(100,m=100,s=10)
v2 <- rnorm(100, m=1000, s=100)
v3 <- rnorm(100)
dat <- data.frame(v1,v2,v3)
rm(v1,v2,v3)
model<- lm(log(v1)~log(v2)+v3, data=dat)
rv2 <- range(dat$v2)
plv2 <- seq(rv2[1], rv2[2], length.out=100)
rv3 <- range(dat$v3)
plv3 <- seq(rv3[1], rv3[2], length.out=100)
newax<- expand.grid(
v2 = plv2,
v3= plv3)
fit <- predict(model,newax)
zmat <- matrix(fit,100,100)
persp(x=plv2, y=plv3, z=zmat)
require(HH)
graph <- regr2.plot(x= plv2,
y=plv3,
z=zmat, main="Least-squares",
resid.plot= TRUE, plot.base.points= TRUE, expand=0.5,
ticktype="detailed", theta=-45)
______________________________________________ R-help at 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.
Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas