Hello! I would like to add a plot of the regression surface to my cloud plot . Is it possible? Thanks Anne [[alternative HTML version deleted]]
Dear Anne, You can make such plots with the rgl package. You'll find an example at <http://socserv.socsci.mcmaster.ca/jfox/Courses/S-course/index.html>. I hope this helps, John> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Anne > Sent: Monday, April 26, 2004 8:15 AM > To: R list > Subject: [R] Adding regression surface to cloud plot > > Hello! > I would like to add a plot of the regression surface to my > cloud plot . Is it possible? > Thanks > > Anne
Dear Anne, I should have mentioned that the Rcmdr package contains a function -- scatter3D -- to make these kinds of graphs. (I'm copying this response to the r-help list -- I hope that's OK.) John> -----Original Message----- > From: Anne [mailto:anne.piotet at urbanet.ch] > Sent: Tuesday, April 27, 2004 1:45 AM > To: John Fox > Subject: Re: [R] Adding regression surface to cloud plot > > Thanks I 'll try > Anne > ----- Original Message ----- > From: "John Fox" <jfox at mcmaster.ca> > To: "'Anne'" <anne.piotet at urbanet.ch> > Cc: "'R list'" <r-help at stat.math.ethz.ch> > Sent: Monday, April 26, 2004 3:57 PM > Subject: RE: [R] Adding regression surface to cloud plot > > > > Dear Anne, > > > > You can make such plots with the rgl package. You'll find > an example > > at > <http://socserv.socsci.mcmaster.ca/jfox/Courses/S-course/index.html>. > > > > I hope this helps, > > John > > > > > -----Original Message----- > > > From: r-help-bounces at stat.math.ethz.ch > > > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Anne > > > Sent: Monday, April 26, 2004 8:15 AM > > > To: R list > > > Subject: [R] Adding regression surface to cloud plot > > > > > > Hello! > > > I would like to add a plot of the regression surface to my cloud > > > plot . Is it possible? > > > Thanks > > > > > > Anne > > >
On Monday 26 April 2004 08:14, Anne wrote:> Hello! > I would like to add a plot of the regression surface to my cloud plot > . Is it possible? ThanksPossible (since 1.9.0), but not easy. Technically, the biggest problem is deciding which points are 'behind' the surface and which 'in front' (that would decide the order of plotting). Otherwise, all the pieces are in place. The following should work for regression surfaces, but may need an inequality to be changed for specific viewpoints: panel.3dreg <- function(x, y, z, rot.mat, distance, xlim.scaled, ylim.scaled, nmesh = 21, ...) { fm <- lm(z ~ x + y) id <- predict(fm) < z ## may need to be reversed panel.3dscatter(x[id], y[id], z[id], rot.mat, distance, xlim.scaled = xlim.scaled, ylim.scaled = ylim.scaled, ...) x.locs <- seq(xlim.scaled[1], xlim.scaled[2], length = nmesh) y.locs <- seq(ylim.scaled[1], ylim.scaled[2], length = nmesh) grid <- expand.grid(y = y.locs, x = x.locs) grid$z <- predict(fm, newdata = grid) panel.3dwire(x = x.locs, y = y.locs, z = grid$z, rot.mat, distance, xlim.scaled = xlim.scaled, ylim.scaled = ylim.scaled, ..., col.at = .5, col.regions = "transparent") panel.3dscatter(x[!id], y[!id], z[!id], rot.mat, distance, xlim.scaled = xlim.scaled, ylim.scaled = ylim.scaled, ...) } ## example data(rock) cloud(area ~ peri * shape, rock, panel.3d.cloud = panel.3dreg, nmesh = 40, pch = 16) - Deepayan