start_value_rho: Extract the Lag 1 value from the ACF of the residuals of a...

View source: R/acf.R

start_value_rhoR Documentation

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 due to missing values.)

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.

Author(s)

Jacolien van Rij

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

data(simdat)

# add missing values to simdat:
simdat[sample(nrow(simdat), 15),]$Y <- NA

## Not run: 
# 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)


## End(Not run)
# see the vignette for examples:
vignette('acf', package='itsadug')

itsadug documentation built on June 17, 2022, 5:05 p.m.