# NOT RUN {
data(simdat)
# }
# NOT RUN {
# Add start event column:
simdat <- start_event(simdat, event=c('Subject', 'Trial'))
head(simdat)
# bam model with AR1 model (toy example, not serious model):
m1 <- bam(Y ~ Group + te(Time, Trial, by=Group),
data=simdat, rho=.5, AR.start=simdat$start.event)
# Warning, no time series specified:
check_resid(m1)
# Time series specified, results in a 'standard' ACF plot,
# treating all residuals as single time seriesand,
# and an ACF plot with the average ACF over time series:
check_resid(m1, split_pred=list(Subject=simdat$Subject, Trial=simdat$Trial))
# Note: residuals do not look very good.
# Alternative (results in the same, see help(acf_resid) ):
check_resid(m1, split_pred='AR.start')
# Define larger plot window (choose which line you need):
dev.new(width=8, height=8) # on windows or mac
quartz(,8,8) # on mac
x11(width=8, height=8) # on linux or mac
par(mfrow=c(2,2), cex=1.1)
check_resid(m1, split_pred='AR.start', ask=FALSE)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab