[R] interaction term and scatterplot3d

Patrick Giraudoux patrick.giraudoux at univ-fcomte.fr
Tue Feb 20 18:49:06 CET 2007


Sorry to answer to myself. A solution was trivial with lattice... (as 
often !)

library(lattice)

modbusetmp<-lm(IKA_buse ~ Ct *Cc,data=dtbuse)

G1<-cloud(IKA_buse~Ct*Cc,type="h",data=dtbuse)
G2<-cloud(IKA_buse~Ct*Cc,data=dtbuse)

seqCc<-seq(min(dtbuse$Cc),max(dtbuse$Cc),l=20)
seqCt<-seq(min(dtbuse$Ct),max(dtbuse$Ct),l=20)
grille<-expand.grid(Cc=seqCc,Ct=seqCt)
zbuse<-predict(modbusetmp,newdata=grille,type=response)
G3<-wireframe(zbuse~grille$Ct*grille$Cc)

print(G3,more=T)
print(G1,more=T)
print(G2)

Some obvious improvements can be done with labels and differencial 
colors (above or below the surface) can be attributed comparing 
observations to predicted values at the same x y values...


Patrick Giraudoux a écrit :
> Dear Listers,
>
> I would be interested in representing a trend surface including an 
> interaction term z = f(x,y,x.y) - eg the type of chart obtained with 
> persp() or wireframe(), then adding datapoints as a cloud, ideally 
> with dots which are under the surface in a color, and those who are 
> above in another color. An other option would be to draw segments 
> between the dots and the ground of the chart.
>
> scatterplot3d looks like being close to do such things except it does 
> not to include (to my knowledge) a coefficient for the interaction 
> term (thus just model z = f(x,y).
>
> Does anybody has an idea where to start with this and the main steps? 
> Or a place/website where some script examples can be found?
>
> Patrick
>
>



More information about the R-help mailing list