Skip to contents

opa is used to fit ordinal pattern analysis models by computing the percentage of pair orderings in each row of data which are matched by corresponding pair orderings in an hypothesis, in addition the chance of a permutation of the data producing a percentage match as great.

Usage

opa(
  dat,
  hypothesis,
  group = NULL,
  pairing_type = "pairwise",
  diff_threshold = 0,
  nreps = 1000L,
  shuffle_across_individuals = FALSE
)

Arguments

dat

a data frame

hypothesis

a numeric vector

group

an optional factor vector

pairing_type

a string

diff_threshold

a positive integer or floating point number

nreps

an integer, ignored if cval_method = "exact"

shuffle_across_individuals

a boolean indicating whether to randomize data across individuals in c-value computation.

Value

opa returns an object of class "opafit".

An object of class "opafit" is a list containing the folllowing components:

group_pcc

the percentage of pairwise orderings from all pooled data rows which were correctly classified by the hypothesis.

individual_pccs

a vector containing the percentage of pairwise orderings that were correctly classified by the hypothesis for each data row.

correct_pairs

an integer representing the number of pairwise orderings pooled across all data rows that were correctly classified by the hypothesis.

total_pairs

an integer, the number of pair orderings contained in the data.

group_cval

the group-level chance value.

individual_cvals

a vector containing chance values for each data row

rand_pccs

A vector of PCCS calculated from each random ordering with length equal to nreps, a list of vectors if a group vector was passed to opa().

call

The matched call

hypothesis

The hypothesis vector passed to opa()

pairing_type

A string indicating the method of pairing passed to opa().

diff_threshold

The numeric difference threshold used to calculate PCCs. If no value was passed in the diff_threshold, the default of 0 is used.

data

The data.frame passed to opa().

groups

The vector of groups passed to opa. If no group vector was passed to opa() the default of NULL is used.

nreps

an integer, the number of random re-orderings of the data used to compute chance values.

Details

Data is expected in wide format with 1 row per individual and 1 column per measurement condition. Data must contain only columns consisting of numerical values of the dependent variable.

The length of the hypothesis must be equal to the number of columns in the dependent variable data.frame dat.

Any independent variable must be passed separately as a vector with the group keyword. The grouping vector must be a factor.

pairing_type must be either "pairwise" or "adjacent". The "pairwise" option considered the relative ordering of every pair of observations in the data and every pair of elements of the hypothesis. The "adjacent" option considers the ordering of adjacent pairs only. If unspecified, the default is "pairwise".

diff_threshold may be a positive integer or double. If unspecified a default zero threshold is used. The diff_threshold is never applied to the hypothesis.

nreps specifies the number of random reorderigs to use in the calculation of chance-values.

References

Grice, J. W., Craig, D. P. A., & Abramson, C. I. (2015). A Simple and Transparent Alternative to Repeated Measures ANOVA. SAGE Open, 5(3), 215824401560419. <https://doi.org/10.1177/2158244015604192>

Thorngate, W. (1987). Ordinal Pattern Analysis: A Method for Assessing Theory-Data Fit. Advances in Psychology, 40, 345–364. <https://doi.org/10.1016/S0166-4115(08)60083-7>

Examples

dat <- data.frame(group = c("a", "b", "a", "b"),
                  t1 = c(9, 4, 8, 10),
                  t2 = c(8, 8, 12, 10),
                  t3 = c(8, 5, 10, 11))
dat$group <- factor(dat$group, levels = c("a", "b"))
h <- hypothesis(1:3)
opamod <- opa(dat[,2:4], h, group = dat$group)