longitudinalccf: longitudinalccf

Description Usage Arguments Value Examples

Description

A conceptual extension to the ccf() function. Computes corrleation coeffeicients for various leads and lags between an x and y variable, for longitudinal data were observations are nested within an 'id' variable.

Usage

1
2
3
longitudinalccf(n, y, x, id, data, outputdata = FALSE, singlecor = FALSE,
  plot = TRUE, onlylead = FALSE, main = NULL, sub = NULL, xlab = NULL,
  ylab = NULL, yscale = FALSE)

Arguments

n

Number of lead/lags to compute up to

y

Y variable

x

X variable

id

id variable, unique across pts.

data

data.frame containing all data

outputdata

If TRUE, a data.frame containing all lead and lag variables appended to the right

singlecor

If TRUE, will output the lead/lag correlations for the specified n separately

plot

If TRUE, a plot of all correlations will be drawn

onlylead

If TRUE, only leads will be estimated, no lags

main

Main title for plot, if plot==TRUE

sub

Sub title for plot, if plot==TRUE

xlab

X-axis label for plot, if plot==TRUE

ylab

Y-axis label for plot, if plot==TRUE

yscale

Y scale for plot, if plot==TRUE

Value

data.frame with new data and/or a plot of correllation coefficients.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#get<-function(){
#id<-sort(rep(1:200, 50))
#time<-rep(1:50,200)
#main<-(rnorm(10000, 7.4,2.2))
#effect<-time*.85
#y<-main + effect
#return(data.frame(id,time,y))
#}
#df <- get()
#longitudinalccf(n = 15,
#                y = y,
#                 x = time,
#                 id = id,
#                 data = df,
#                 plot=TRUE,
#                 outputdata=TRUE,
#                 singlecor=FALSE,
#                 onlylead=FALSE)

TaylorAndrew/atPlot documentation built on May 9, 2019, 4:23 p.m.