repeatAnalysis: Derive the proportion of similarities in the shape of event...

Description Usage Arguments Details Examples

View source: R/repeatAnalysis.r

Description

Derive the proportion of similarities in the shape of event traces between sensors within two sessions.

Usage

1
2
3
repeatAnalysis(x, sensorToMatch = 4, sensorToMatchAgainst = 3:5,
  whichJSONLabel = "pfmc3x5s_rest30s", sessionOrder = NULL, B = 1000,
  toPlot = FALSE)

Arguments

x

An "FemFit" object.

sensorToMatch

A numeric vector which denotes sensors to use in the comparison from sessionOrder[1].

sensorToMatchAgainst

A numeric vector which denotes sensors to use in the comparison from sessionOrder[2].

whichJSONLabel

A character argument specifying part of the protocol to extract the event traces from.

sessionOrder

A character vector of length two specifying the sessions to compare. Defaults to unique(x$df$sessionID)[1:2].

B

A numeric argument specifying the number of bootstraps to run to estimate the variability of the propotion of similarities.

toPlot

A logical argument as to whether repeatAnalysis() produces ggplot2 objects visualising where the Hidden Markov Model detected dissimilarities in the shape of the pressure trace.

Details

repeatAnalysis() first standardises the event traces against themselves, procuring the raw shape of the event trace. Then, it uses loess regression to get a smooth approximation of the shape for each event trace. A total of (n_1 + n_2)/2 observations are drawn sequentially over time from each loess regression to construct the smooth approximation, where n_x is the number of observations that make up the xth event trace. A vector of differences is constructed and then squared. A Hidden Markov Model is fitted to the vector of differences assuming two states which adhere to a Normal distribution. Finally, the proportion of similarity is derived by using the output of the Viterbi algorithm, and the assessment of the variability is done with a parametric bootstrap based on the Viterbi algorithm's delta probabilities.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
AS005 = read_FemFit(c(
        "Datasets_AukRepeat/61aa0782289af385_283_csv.zip",
        "Datasets_AukRepeat/61aa0782289af385_284_csv.zip"
    ),
    remove.NAs = TRUE
  ) %>%
  # Segment the FemFit data
  segment(
    cp. = 0.001,
    numOfNodesToLabel = list(c(3, 1, 3, 4), c(4, 1, 5, 3))
  ) %>%
  # Calculate the zeroed out pressures
  deriveZero(method = "lmm")

# Produce the proportions of similarities for Sensor four against Sensor four with the ggplot2 objects.
AS005_RepeatOutput = repeatAnalysis(AS005, 4, 4, "pfmc3x5s_rest30s", toPlot = TRUE)

# View the proportion of similarities for the three events, with the bootstrapped standard errors and CIs
AS005_RepeatOutput %>%
   select(eventID, classProb, classProb_stderr, classProb_lwrbnd, classProb_uprbnd)

# View the ggplot2 objects generated by `repeatAnalysis()`
AS005_RepeatOutput$plotObj[1]
AS005_RepeatOutput$plotObj[2]
AS005_RepeatOutput$plotObj[3]

TheGreatGospel/IVPSA documentation built on May 19, 2019, 1:47 a.m.