[R] logistic regression 3D-plot

Lorenz.Gygax@fat.admin.ch Lorenz.Gygax at fat.admin.ch
Thu Feb 3 12:10:38 CET 2005


> I tried to create a 3D surface showing the interaction between two
> continuous explanatory variables; the response variable is 
> binary (0/1).
> 
> The model is:
> 
> model<-glm(incidence~sun*trees,binomial)
> 
> then I used "wireframe" to create a 3D plot:
> 
> xyz<-expand.grid(sun=seq(30,180,1),trees=seq(0,4000,10))
> 
> xyz$incidence<-as.vector(predict(model,xyz))

xyz$incidence<-as.vector(predict(model,xyz, type= "response")) 
should work

> wireframe(incidence~sun*trees,xyz,scales=list(arrows=FALSE))

Cheers, Lorenz




More information about the R-help mailing list