You can create a matrix of appropriate dimensions as follows:
> lo.2 <- array(lo.1$fit, dim=sapply(topo.mar, length))
It's also probably worth changing topo.mar so that the x and y elements have different lengths, to provide a quick check that the x and y dimensions were not swapped somewhere along the way.
hope this helps,
Tony Plate
At Monday 01:45 PM 7/21/2003 -0400, john lewis wrote:
R- Users:
Can someone indicate what I am during wrong? This is a script essentially from
Venerable & Ripley's text on interpolating a surface with loess function but I can not get it to run.
Thanks.
John Lewis
Professor
McGill University
Montreal
library(MASS)
library(modreg)
data(topo)
par(mfcol=c(2,2), pty="s")
topo.loess <- loess(z ~ x * y, topo, degree=2, span = 0.25, normalize=F)
topo.mar <- list(x = seq(0, 6.5, 0.1), y=seq(0, 6.5, 0.1))
topo.lo <- predict(topo.loess, expand.grid(topo.mar), se=T)
lo.1 <- as.data.frame(topo.lo)
lo.2 <- as.matrix(lo.1$fit)
lo.3 <- as.matrix(lo.1$se.fit)
contour(topo.mar$x,topo.mar$y,lo.2, levels = seq(700,1000,25),
xlab="fit", ylab="")
points(topo)
contour(topo.mar$x,topo.mar$y,lo.3, levels = seq(5, 25, 5),
xlab="standard error", ylab="")
title("Loess degree = 2")
points(topo)
This is the error I keep getting.
"Error in contour.default(topo.mar$x, topo.mar$y, lo.2, levels = seq(700, : no proper `z' matrix specified"
I received this same message when I ran the script first without changing topo.lo
from a list to data.frame etc. as seen below.
contour(topo.mar$x,topo.mar$y,topo.lo$fit, levels = seq(700,1000,25),
xlab="fit", ylab="")
I checked the length of each variable and they are correct. [[alternative HTML version deleted]]
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Tony Plate [EMAIL PROTECTED]
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help