acf_n_plots | R Documentation |

Generate N ACF plots of individual or aggregated time series.

acf_n_plots( x, n = 5, split_by = NULL, cond = NULL, max_lag = NULL, fun = mean, plot = TRUE, random = F, mfrow = NULL, add = FALSE, print.summary = getOption("itsadug_print"), ... )

`x` |
A vector with time series data, typically residuals of a regression model. |

`n` |
The number of plots to generate. |

`split_by` |
List of vectors (each with equal length as |

`cond` |
Named list with a selection of the time series events
specified in |

`max_lag` |
Maximum lag at which to calculate the acf. Default is the maximum for the longest time series. |

`fun` |
The function used when aggregating over time series
(depending on the value of |

`plot` |
Logical: whether or not to produce plot. Default is TRUE. |

`random` |
Logical: determine randomly which |

`mfrow` |
A vector of the form c(nr, nc). The figures will be drawn in an nr-by-nc array on the device by rows. |

`add` |
Logical: whether to add the plots to an exiting plot window or not. Default is FALSE. |

`print.summary` |
Logical: whether or not to print summary.
Default set to the print info messages option
(see |

`...` |
Other arguments for plotting, see |

`n`

ACF plots providing information about the autocorrelation
in `x`

.

Jacolien van Rij, R. Harald Baayen

Use `acf`

for the original ACF function,
and `acf_plot`

for an ACF that takes into account time series
in the data.

Other functions for model criticism:
`acf_plot()`

,
`acf_resid()`

,
`derive_timeseries()`

,
`resid_gam()`

,
`start_event()`

,
`start_value_rho()`

data(simdat) # Separate ACF for each time series: acf_n_plots(simdat$Y, split_by=list(simdat$Subject, simdat$Trial)) # Average ACF per participant: acf_n_plots(simdat$Y, split_by=list(simdat$Subject)) ## Not run: # Data treated as single time series. Plot is added to current window. # Note: 1 time series results in 1 plot. acf_n_plots(simdat$Y, add=TRUE) # Plot 4 ACF plots doesn't work without splitting data: acf_n_plots(simdat$Y, add=TRUE, n=4) # Plot ACFs of 4 randomly selected time series: acf_n_plots(simdat$Y, random=TRUE, n=4, add=TRUE, split_by=list(simdat$Subject, simdat$Trial)) ## End(Not run) #--------------------------------------------- # When using model residuals #--------------------------------------------- ## Not run: # add missing values to simdat: simdat[sample(nrow(simdat), 15),]$Y <- NA # simple linear model: m1 <- lm(Y ~ Time, data=simdat) # This will generate an error: # acf_n_plots(resid(m1), split_by=list(simdat$Subject, simdat$Trial)) # This should work: el.na <- missing_est(m1) acf_n_plots(resid(m1), split_by=list(simdat[-el.na,]$Subject, simdat[-el.na,]$Trial)) # This should also work: simdat$res <- NA simdat[!is.na(simdat$Y),]$res <- resid(m1) acf_n_plots(simdat$res, split_by=list(simdat$Subject, simdat$Trial)) ## End(Not run) # see the vignette for examples: vignette('acf', package='itsadug')

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.