Skip to contents

This function generates observation times of a measurement-burst design: bursts bursts of days days, separated by gap days without measurement, with beeps occasions a day within the waking window. The window is split into beeps equal blocks, and each occasion is drawn uniformly within its block (stratified random sampling, as in most ecological momentary assessment protocols).

Usage

ScheduleBurst(
  n,
  bursts = 3,
  days = 7,
  beeps = 5,
  gap = 28,
  window = c(9, 21),
  day_length = 24,
  grid = NULL
)

Arguments

n

Positive integer. Number of individuals.

bursts

Positive integer. Number of bursts.

days

Positive integer. Number of days in each burst.

beeps

Positive integer. Number of occasions a day.

gap

Non-negative integer. Number of days between the end of one burst and the start of the next.

window

Numeric vector of length 2. Start and end of the daily measurement window, in the units of day_length.

day_length

Positive number. Length of a day in the time unit.

grid

Optional positive number. Spacing of the grid of a discrete-time model.

Value

Returns a list of length n. Each element is a numeric vector of the observation times. The attribute delta_t is a list of length n; each element is a numeric vector of the intervals. With grid, the attribute index is a list of length n; each element is an integer vector of the grid occasions measured (1 is time 0).

Details

Times are in the units of day_length (hours with the default day_length = 24). The times of each person are shifted to start at 0, and each person has bursts * days * beeps occasions. The attribute delta_t holds the intervals for the delta_t argument of the continuous-time simulators, for example, SimSSMOUFixed() and SimSSMLinSDEIVary().

For discrete-time models, give grid: each occasion is drawn from the grid points (multiples of grid) within its block, and the attribute index holds, for each person, the grid occasions measured. Simulate the model on the grid (time = max(unlist(attr(x, "index")))) and keep the measured occasions with SimMissing(x, keep = attr(schedule, "index")).

See also

Other Measurement Design Functions: ScheduleExp(), ScheduleRandom(), SimMissing()

Author

Ivan Jacob Agaloos Pesigan

Examples

set.seed(42)
# two bursts of three days, four beeps a day from 9 to 21 hours
schedule <- ScheduleBurst(
  n = 2,
  bursts = 2,
  days = 3,
  beeps = 4,
  gap = 7,
  window = c(9, 21),
  day_length = 24,
  grid = 1
)
schedule[[1]]
#>  [1]   0   3   4   9  23  26  30  31  47  51  53  57 240 241 245 249 264 265 269
#> [20] 272 288 289 294 297
attr(schedule, "index")[[1]]
#>  [1]   1   4   5  10  24  27  31  32  48  52  54  58 241 242 246 250 265 266 270
#> [20] 273 289 290 295 298