data(simdat)
# add missing values to simdat:
simdat[sample(nrow(simdat), 15),]$Y <- NA
# Run GAMM model:
m1 <- bam(Y ~ te(Time, Trial)+s(Subject, bs='re'), data=simdat)
# This will generate an error (see examples in acf_plot):
acf_resid(m1, split_pred=list(simdat$Subject, simdat$Trial))
# However, this will work:
acf_resid(m1, split_pred=c("Subject", "Trial"))
# Calling acf_n_plots:
acf_resid(m1, split_pred=c("Subject", "Trial"), n=4)
# add some arguments:
acf_resid(m1, split_pred=c("Subject", "Trial"), n=4, max_lag=10)
# This does not work...
m2 <- lm(Y ~ Time, data=simdat)
acf_resid(m2, split_pred=c("Subject", "Trial"))
# ... and this also doesn't work (because of the NA's)
acf_resid(m2, split_pred=list(simdat$Subject, simdat$Trial))
# ... but this is ok:
el.na <- missing_est(m2)
acf_resid(m2, split_pred=list(simdat$Subject[-el.na], simdat$Trial[-el.na]))
# See acf_plot for how to deal wit missing data
# see also the vignette for an example:
vignette(topic="plotfunctions", package="itsadug")
Run the code above in your browser using DataLab