Inspect residuals of regression models.
check_resid( model, AR_start = NULL, split_pred = NULL, ask = TRUE, select = 1:4 )
A regression model, resulting from the functions
Defaults to NULL.
Only use this when the model was run in an old versions of package
A names list indicating time series in the data.
Logical: whether or not to show the plots one by one.
Defaults to TRUE. When set to FALSE, make sure to have specified
sufficient rows and columns to show the X plots. Alternatively,
Vector or numeric value indicating which plots to return (see Notes). Defaults to 1:4 (all).
Plot 1: distribution of residuals with QQ norm plot.
Plot 2: distribution of residuals with density plot.
Plot 3: ACF plot of residuals. In case an AR1 model is included, the gray lines indicate standard residuals, and the thick black lines indicate AR1 corrected residuals.
Plot 4 (optional): In case the
split_pred predictors are
specified an ACF plot averaged over the time series is produced. dashed
lines indicate the maximum and minimum time series (w.r.t. lag 2), the
solid lines the 25
mean of all time series.
See the examples on how to specify a selection of these plots.
Jacolien van Rij
Other Model evaluation:
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) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.