LagESM: Function to compute lagged n variables in ESM data and add it...

Description Usage Arguments Value Examples

Description

Function to compute lagged n variables in ESM data and add it to data

Usage

1
2
3
4
5
6
7
8
lagESM(
  data,
  subjnr = "subjnr",
  level2 = NULL,
  level1 = "beepnr",
  lagn = 1,
  varnames = NULL
)

Arguments

data

data frame

subjnr

variable, indicating subjects

level2

variable, indicating level 2 variable, e.g. days. Can be left empty.

level1

variable, indicating level 1 variable, e.g. beeps. Must be specified.

lagn

number of lags

varnames

vector with the names of the variables for which lagged versions are computed

Value

data frame with lagged variables added, with suffix L1, L2, L3, respectively

Examples

1
2
3
4
data("news")
vars <- c("Fearful","Hopeful","Anxious","Down","Inspiring","Irritated","Relaxed","Insecure")
res <- lagESM(data = news, subjnr="subjnr", level2= "daynr",
       level1 = "beepnr", lagn = 1, varnames = vars)

PeterVerboon/lagnetw documentation built on Aug. 4, 2020, 5:16 p.m.