[R] "Local trend surfaces" Ex from V&R MASS
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Fri Mar 7 15:43:36 CET 2003
On Fri, 7 Mar 2003 Ted.Harding at nessie.mcc.ac.uk wrote:
> Hi Folks,
>
> I'm probably overlooking some small point, but can't see it.
>
> Trying the "Local trend surfaces" example from p.437 of MASS
> (3rd edn) by V&R, all goes well until the line
>
> contour(topo.mar$x, topo.mar$y, topo.lo$fit,
> levels=seq(700,1000,25), xlab="fi t", ylab="")
>
> which produces the response:
>
> Error in contour.default(topo.mar$x, topo.mar$y, topo.lo$fit,
> levels = seq(700, :
> no proper `z' matrix specified
>
> I've checked the sizes of topo.mar$x, topo.mar$y and topo.lo$fit, and
> they should all line up, so I can't see why "no proper `z' matrix
> specified". I notice that topo.lo$fit has NAs (but "NA's are allowed"
> according to "?contour") and wonder if this may be causing a problem
> (options("na.action")->[1] "na.omit").
Nope, it's an R/S difference in contour/loess (I forget which). You need
to check the R scripts (library/MASS/scripts3 in your R installation)
which give
topo.loess <- loess(z ~ x * y, topo, degree=2, span = 0.25, normalize=F)
topo.mar <- list(x = seq(0, 6.5, dif), y=seq(0, 6.5, dif))
topo.lo <- predict(topo.loess, expand.grid(topo.mar), se=T)
topo.lo$fit <- matrix(topo.lo$fit, length(topo.mar$x), length(topo.mar$y))
contour(topo.mar$x,topo.mar$y,topo.lo$fit, levels = seq(700,1000,25),
xlab="fit", ylab="")
--
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