[R] Surface plot for polynomial regression
John Fox
jfox at mcmaster.ca
Thu Mar 31 18:31:14 CEST 2005
Dear Johannes and Brian,
scatter3d() in the Rcmdr packages does indeed fit a full quadratic surface
including the product term, which can you verify by setting the argument
model.summary=TRUE in the call to the function. Perhaps the grid over which
scatter3d evaluates the fitted surface is too coarse to resolve all of the
features of the surface in which you're interested; this is currently fixed
at 26*26 but could easily be changed, and really should be an argument to
the function. I'll do that that in the next version.
I hope this helps,
John
--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox
--------------------------------
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Prof
> Brian Ripley
> Sent: Thursday, March 31, 2005 10:58 AM
> To: Johannes Ullrich
> Cc: r-help at stat.math.ethz.ch
> Subject: Re: [R] Surface plot for polynomial regression
>
> Please note there is no `scatter3d' function in R.
> There is one in John Fox's package Rcmdr: please give credit
> where it is due.
>
> However, I think you have overlooked functions like persp,
> image, contour, cloud wireframe and levelplot (lattice), all
> of which can plot any function of two variables and whose
> examples (and some of the demos) show you how. You might
> also want to look at rgl.surface (package rgl).
>
> On Thu, 31 Mar 2005, Johannes Ullrich wrote:
>
> > Dear R-experts,
> >
> > my goal is to visualize the following polynomial regression
> as a 3D-surface:
>
> It is a 2D surface, by any reasonable definition of `dimension'.
>
> > Z = b0 + b1*X + b2*Y + b3*XY + b4*X^2 + b5*Y^2
> >
> > I believe that a solution to this problem may be of interest to a
> > wider range of scientists because the problem is a derivative of a
> > more general problem, i.e.: how to describe the
> relationship between
> > one dependent variable and the DIFFERENCE between two other
> variables.
> > There are numerous problems associated with difference
> scores (e.g.,
> > reliability). One suggested alternative consists of using the
> > components of the difference score separately in polynomial
> > regression. So this is how I ended up with the above
> regression, which is essentially a reformulation of b1*(X-Y)^2.
> >
> > After consulting the help pages and archives my best guess was that
> > the function scatter3d could be rewritten in part to
> produce the desired output.
> > In fact, the quadratic fit output of the scatter3d function comes
> > closest to what I have in mind. However, I think the XY term is
> > missing from the quadratic fit equation. When I use wireframe to
> > visualize the raw data, there is a peak of the dependent
> variable when
> > both X AND Y are high. Yet this peak does not appear in the
> quadratic fit of scatter3d.
> >
> > Any pointers would be welcome. I should add that I am not a
> programmer
> > and mainly work with high-level functions.
> >
> > Thank you very much for R and for your help
> >
> > Johannes
> >
> > Dipl.-Psych. Johannes Ullrich
> > Philipps-Universität Marburg
> > Germany
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> >
>
> --
> Brian D. Ripley, ripley at stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list