runACF: run functions to create acf matrix and plot the results

View source: R/runACF.R

runACFR Documentation

run functions to create acf matrix and plot the results

Description

run functions to create acf matrix and plot the results

Usage

runACF(
  block,
  model,
  store = FALSE,
  save = F,
  suppress.printout = TRUE,
  maxlag = NULL,
  printplot = TRUE
)

Arguments

block

Vector of blocks that identify data points that are correlated

model

Fitted model object (glm or gam)

store

(default=FALSE). Logical stating whether a list of the matrix of correlations is stored (output from acffunc.)

save

(default=FALSE). Logical stating whether plot should be saved into working directory.

suppress.printout

(default=TRUE. Logical stating whether to show a printout of block numbers to assess progress. FALSE will show printout.

maxlag

(default=NULL). Numeric entry to allow the restriction of the maximum lag on the plots. If NULL then the length of the longest panel is used as the maximum plotted lag.

Value

Plot of lag vs correlation. Each grey line is the correlation for each individual block in block. The red line is the mean values for each lag.

If store=TRUE then the matrix of correlations (nblocks x length_max_block) is returned and plotacf may be used to plot the acf.

Author(s)

LAS Scott-Hayward, University of St Andrews

Examples

# load data
data(ns.data.re)

model<-gamMRSea(birds ~ observationhour + as.factor(floodebb) + as.factor(impact), 
           family='quasipoisson', data=ns.data.re)

ns.data.re$blockid<-paste(ns.data.re$GridCode, ns.data.re$Year, ns.data.re$MonthOfYear, 
                    ns.data.re$DayOfMonth, sep='')
ns.data.re$blockid<-as.factor(ns.data.re$blockid)

runACF(ns.data.re$blockid, model, suppress.printout=TRUE)

# storing the output and then plotting
acfoutput <- runACF(ns.data.re$blockid, model, suppress.printout=TRUE, store=TRUE)
plotacf(acfoutput$acfmat)


lindesaysh/MRSea documentation built on May 11, 2024, 11:30 p.m.