Skip to content
Back to formatted view

Raw Message

Message-ID: <23580512.post@talk.nabble.com>
Date: 2009-05-17T06:16:42Z
From: Ben Bolker
Subject: wireframe 3-D problems
In-Reply-To: <651a75b50905162045n399f82b8mc2571e77dc422ae8@mail.gmail.com>

Xu Jun wrote:
> 
> I am trying to graph a 3-D graph of simulated data for logit models using
> the powerful wireframe command, but I got stuck. Here are the codes:
> 
> x <- seq(-4, 4, by=0.01)
>  y <- seq(-4, 4, by=0.01)
>  p <- 1/(1+exp(-0.12*x + 0.35*y))
>  mydata <- cbind(x, y, p)
>  require(lattice)
>  wireframe(p~x*y, data=mydata)
> 
>  and I received the following message:
> 
> Error in eval(substitute(groups), data, environment(formula)) :
>   numeric 'envir' arg not of length one
> 
> Can anyone here point me to the right direction? Thanks!
> 
> 

Your x and y variables were only evaluated along a single line,
not over the entire grid (other solutions are possible using
outer() and rep() ...)

x <- seq(-4, 4, by=0.25)
y <- seq(-4, 4, by=0.25)
mydata <- expand.grid(x=x,y=y)
p <- 1/(1+exp(-0.12*mydata$x + 0.35*mydata$y))
mydata <- data.frame(x=mydata$x,y=mydata$y,p)
require(lattice)
wireframe(p~x*y, data=mydata)
## should play with "screen" argument, see ?panel.wireframe

-- 
View this message in context: http://www.nabble.com/wireframe-3-D-problems-tp23579998p23580512.html
Sent from the R help mailing list archive at Nabble.com.