ctACF | R Documentation |
This function computes an approximate continuous time autocorrelation function (ACF) for data containing multiple subjects and/or variables.
ctACF(
dat,
varnames = "auto",
ccfnames = "all",
idcol = "id",
timecol = "time",
plot = TRUE,
timestep = "auto",
time.max = "auto",
nboot = 100,
scale = FALSE,
center = FALSE,
...
)
dat |
The input data in data frame or data table format. |
varnames |
Character vector of variable names in the data to compute the ACF for. 'auto' uses all columns that are not time / id. |
ccfnames |
Character vector of variable names in the data to compute cross correlation for. 'all' uses all variables in varnames, NA uses none. |
idcol |
The name of the column containing subject IDs (default is 'id'). |
timecol |
The name of the column containing time values (default is 'time'). |
plot |
A logical value indicating whether to create a plot (default is TRUE). |
timestep |
The time step for discretizing data. 'auto' to automatically determine the timestep based on data distribution (default is 'auto'). In this case the timestep is computed as half of the median for time intervals in the data. |
time.max |
The maximum time lag to compute the ACF (default is 10). If 'auto', is set to 10 times the 90th percentile interval in the data. |
nboot |
The number of bootstrap samples for confidence interva1l estimation (default is 100). |
scale |
if TRUE, scale variables based on within-subject standard deviation. |
center |
if TRUE, center variables based on within-subject mean. |
... |
additional arguments (such as demean=FALSE) to pass to the |
This function computes the continuous time ACF by discretizing the data and then performing bootstrapped ACF calculations to estimate the confidence intervals. It can create ACF plots with confidence intervals if 'plot' is set to TRUE.
If 'plot' is TRUE, the function returns a ggplot object of the ACF plot. If 'plot' is FALSE, it returns a data table with ACF estimates and confidence intervals.
ctDiscretiseData
data.table::setDTthreads(1) #ignore this line
# Example usage:
head(ctstantestdat)
ctACF(ctstantestdat,varnames=c('Y1'),idcol='id',timecol='time',nboot=5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.