# NOT RUN {
data(simdat)
# add missing values to simdat:
simdat[sample(nrow(simdat), 15),]$Y <- NA
simdat <- start_event(simdat, event=c('Subject', 'Trial'))
# }
# NOT RUN {
# Run GAMM model:
m1 <- bam(Y ~ te(Time, Trial)+s(Subject, bs='re'), data=simdat,
rho=.5, AR.start=simdat$start.event)
simdat$Event <- NA
simdat[!is.na(simdat$Y),]$Event <- derive_timeseries(m1)
acf_resid(m1, split_pred=list(Event=simdat$Event))
# And this works too:
simdat$Event <- derive_timeseries(simdat$start.event)
acf_resid(m1, split_pred=list(Event=simdat$Event))
# Note that acf_resid automatically makes use of derive_timeseries:
acf_resid(m1, split_pred='AR.start')
# }
Run the code above in your browser using DataLab