regression plane in spinning 3D scatterplot

140 views
Skip to first unread message

ekbrown77

unread,
Aug 11, 2016, 4:54:47 PM8/11/16
to StatForLing with R
Has anyone put a regression plane in a spinning 3D scatterplot, akin to a regression line in a 2D scatterplot? While the scatterplot3d package can put a plane in a 3D scatterplot, it's not spinning (spinable, able to spin) and is difficult to interpret.

I have a significant interaction term between two gradient independent variables, with a gradient dependent variable, in a mixed effects model. I don't know how to interpret the negative coefficient estimate.

I tried using the cut function to drop the speakers' ages (one of the two variables in the interaction term) into a factor and then plotted 2D scatterplots by age group, but I'm having trouble seeing a consistent effect after trying several number of bins as well as cutoff points between them.

Thanks in advance for any help.

Matías Guzmán Naranjo

unread,
Aug 11, 2016, 4:59:28 PM8/11/16
to statforli...@googlegroups.com
Have you tried contour plots?

--
You received this message because you are subscribed to the Google Groups "StatForLing with R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to statforling-with-r+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stefan Th. Gries

unread,
Aug 13, 2016, 12:38:11 PM8/13/16
to StatForLing with R
> Has anyone put a regression plane in a spinning 3D scatterplot, akin to a regression line in a 2D scatterplot? While the scatterplot3d package can put a plane in a 3D scatterplot, it's not spinning (spinable, able to spin) and is difficult to interpret.
Don't I discuss this in SFLWR2, Section 5.26 and 5.36?

Stefan Th. Gries

unread,
Aug 13, 2016, 12:57:24 PM8/13/16
to StatForLing with R
# isn't this what you want?
library(rgl)
RTs <- read.delim(file.choose(), row.names=1) #
</_inputfiles/05-2_reactiontimes.csv>
RTs$FAMILIARITY <- factor(RTs$FAMILIARITY,
levels=levels(RTs$FAMILIARITY)[c(2, 3, 1)])
RTs$IMAGEABILITY <- factor(RTs$IMAGEABILITY,
levels=levels(RTs$IMAGEABILITY)[c(2, 1)])

model.01 <- lm(RT ~ MEANINGFULNESS * FREQUENCY, data=RTs)
preds.hyp.for.plot <-
expand.grid(MEANINGFULNESS=seq(min(MEANINGFULNESS, na.rm=TRUE),
max(MEANINGFULNESS, na.rm=TRUE), length.out=100),
FREQUENCY=seq(floor(min(FREQUENCY)), ceiling(max(FREQUENCY)),
length.out=100)); preds.hyp.for.plot[c("PREDICTIONS", "LOWER",
"UPPER")] <- predict(model.01, newdata=preds.hyp.for.plot,
interval="confidence")

plot3d(preds.hyp.for.plot$MEANINGFULNESS,
preds.hyp.for.plot$FREQUENCY, preds.hyp.for.plot$PREDICTIONS,
xlab="Meaningfulness", ylab="Frequency", zlab="Predicted interaction
from model", main="Meaningfulness x Frequency in model.01",
col=grey(as.numeric(cut(preds.hyp.for.plot$PREDICTIONS, 100))/100))

ekbrown77

unread,
Aug 16, 2016, 7:58:38 PM8/16/16
to StatForLing with R
Thanks Matías and Stefan. Yes, these are what I needed.
Reply all
Reply to author
Forward
0 new messages