# NOT RUN {
data(eeg)
# }
# NOT RUN {
# simple GAMM model:
m1 <- gam(Ampl ~ te(Time, X, Y, k=c(10,5,5),
d=c(1,2)), data=eeg)
# topo plot, by default uses fvisgam
# and automatically selects a timestamp (270ms):
plot_topo(m1, view=c('X', 'Y'))
# or:
plot_topo(m1, view=c('X', 'Y'), setmargins=FALSE, size=1)
# add electrodes:
electrodes <- eeg[,c('X','Y','Electrode')]
electrodes <- as.list( electrodes[!duplicated(electrodes),] )
plot_topo(m1, view=c('X', 'Y'), el.pos=electrodes)
# some formatting options:
plot_topo(m1, view=c('X', 'Y'), el.pos=electrodes,
main='Topo plot', zlim=c(-.5,.5),
pch=15, col='red', color='terrain')
# plotting more than one panel only works if
# each figure region is a square:
dev.new(width=12, height=4)
par(mfrow=c(1,3))
for(i in c(100, 200, 300)){
# make sure to keep zlim constant:
\t plot_topo(m1, view=c('X', 'Y'), zlim=c(-.5, .5),
cond=list(Time=i), el.pos=electrodes,
main=i)
}
dev.new(width=12, height=4)
par(mfrow=c(1,3), cex=1.1)
# The three different functions for plotting:
plot_topo(m1, view=c('X', 'Y'), zlim=c(-.5, .5),
el.pos=electrodes,
fun='fvisgam', main='fvisgam',
cond=list(Time=200), rm.ranef=TRUE)
plot_topo(m1, view=c('X', 'Y'), zlim=c(-.5, .5),
el.pos=electrodes, select=1,
fun='pvisgam', main='pvisgam',
cond=list(Time=200))
plot_topo(m1, view=c('X', 'Y'), zlim=c(-.5, .5),
el.pos=electrodes, comp=list(Time=c(300,100)),
fun='plot_diff2', main='plot_diff2',
plotCI=TRUE)
# Add labels:
plot_topo(m1, view=c('X', 'Y'), zlim=c(-.5, .5),
fun='fvisgam', main='',
cond=list(Time=200), add.color.legend=FALSE)
text(electrodes[['X']], electrodes[['Y']],
labels=electrodes[['Electrode']], cex=.75,
xpd=TRUE)
# }
Run the code above in your browser using DataLab