[R] Plotting Prediction Surface with persp()

From: Rory Winston <rory.winston_at_gmail.com>
Date: Thu, 03 Jul 2008 01:47:51 +0100

Hi all

I have a question about correct usage of persp(). I have a simple neural net-based XOR example, as follows:

xor.data <- data.frame(cbind(expand.grid(c(0,1),c(0,1)), c(0,1,1,0))) names(xor.data) <- c("x","y","o")
xor.nn <- nnet(o ~ x + y, data=xor.data, linout=FALSE, size=1)

# Create an (x.y) surface and predict over all points d <- data.frame(expand.grid(seq(0,1,.1), seq(0,1,.1))) names(d) <- c("x","y")
p <- predict(xor.nn, d)
zmat <- as.matrix(cbind(d,p))

Now my z matrix consists of x and y points, and the corresponding prediction value for each (x,y) tuple. What would be the best way to plot these? I tried persp(), but it didnt like the z matrix. Is there an alternative plot function that I could use (I am presuming I need one of the 3d variants)? Thanks

        [[alternative HTML version deleted]]

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. Received on Thu 03 Jul 2008 - 00:50:29 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 03 Jul 2008 - 05:30:56 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive