Learn R Programming

itsadug (version 2.0)

start_value_rho: Extract the Lag 1 value from the ACF of the residuals of a gam, bam, lm, lmer model, ...

Description

Wrapper around acf_plot for regression models.

Usage

start_value_rho(model, plot = FALSE, lag = 2, main = NULL, ...)

Arguments

model
A regression model generated by lm, glm, lmer, glmer, gam, or bam. (See examples for how to avoid errors
plot
Logical: whether or not to produce plot. Default is TRUE.
lag
Numeric value, indicating the lag. Default is 2.
main
Text string, title of ACF plot.
...
Other arguments for plotting the acf, see acf.

Value

  • The autocorrelation value of data points with the data points at lag lag.

See Also

Use acf for the original ACF function, and acf_plot, or acf_resid.

Other functions for model criticism: acf_n_plots, acf_plot, acf_resid, derive_timeseries, resid_gam, start_event

Examples

Run this code
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)

# No plotting:
start_value_rho(m1)
# With plot:
rhom1 <- start_value_rho(m1, plot=TRUE)
# see the vignette for examples:
vignette("acf", package="itsadug")

Run the code above in your browser using DataLab