# NOT RUN {
data(simdat)
# }
# NOT RUN {
# Model with random effect and interactions:
m1 <- bam(Y ~ te(Time, Trial)+s(Time, Subject, bs='fs', m=1),
data=simdat, discrete=TRUE)
# Plot summed effects:
vis.gam(m1, view=c('Time', 'Trial'), plot.type='contour', color='topo')
# Same plot:
fvisgam(m1, view=c('Time', 'Trial'), rm.ranef=FALSE)
# Without random effects included:
fvisgam(m1, view=c('Time', 'Trial'), rm.ranef=TRUE)
# Notes on the color legend:
# Labels can easily fall off the plot, therefore the numbers can be
# automatically rounded.
# To do the rounding, set dec=-1:
fvisgam(m1, view=c('Time', 'Trial'), rm.ranef=TRUE,
dec=-1)
# For custom rounding, set dec to a value:
fvisgam(m1, view=c('Time', 'Trial'), rm.ranef=TRUE,
dec=0)
# To increase the left marging of the plot (so that the numbers fit):
oldmar <- par()$mar
par(mar=oldmar + c(0,0,0,1) ) # add one line to the right
fvisgam(m1, view=c('Time', 'Trial'), rm.ranef=TRUE,
dec=3)
par(mar=oldmar) # restore to default settings
# changing the color palette:
fvisgam(m1, view=c('Time', 'Trial'), rm.ranef=TRUE,
color='terrain')
fvisgam(m1, view=c('Time', 'Trial'), rm.ranef=TRUE,
color=c('blue', 'white', 'red'), col=1)
# Using transform
# Plot log-transformed dependent predictor on measurement scale:
fvisgam(m1, view=c('Time', 'Trial'), rm.ranef=TRUE, transform=exp)
# Notes on transform.view:
# This will generate an error, because x-values <= 0 will result in NaN:
fvisgam(m1, view=c('Time', 'Trial'), rm.ranef=TRUE,
transform.view=list(log, NULL))
# adjusting the x-axis helps:
fvisgam(m1, view=c('Time', 'Trial'), rm.ranef=TRUE,
xlim=c(1,2000), transform.view=list(log, NULL))
# too.far:
n <- which(simdat$Time > 1500 & simdat$Trial > 5)
simdat[n,]$Y <- NA
simdat[simdat$Trial == -3,]$Y <- NA
m1 <- bam(Y ~ te(Time, Trial)+s(Time, Subject, bs='fs', m=1),
data=simdat, discrete=TRUE)
fvisgam(m1, view=c('Time', 'Trial'), rm.ranef=TRUE, too.far=.03)
# }
# NOT RUN {
# see the vignette for examples:
vignette('inspect', package='itsadug')
# }
Run the code above in your browser using DataLab