Calculates the percentage exceeding the median (PEM) index (Ma, 2006).

PEM(
A_data,
B_data,
condition,
outcome,
baseline_phase = NULL,
intervention_phase = NULL,
improvement = "increase"
)

## Arguments

A_data

vector of numeric data for A phase. Missing values are dropped.

B_data

vector of numeric data for B phase. Missing values are dropped.

condition

vector identifying the treatment condition for each observation in the series.

outcome

vector of outcome data for the entire series.

baseline_phase

character string specifying which value of condition corresponds to the baseline phase. Defaults to first observed value of condition.

intervention_phase

character string specifying which value of condition corresponds to the intervention phase. Defaults to second unique value of condition.

improvement

character string indicating direction of improvement. Default is "increase".

Numeric value

## Details

For an outcome where increase is desirable, PEM is calculated as the proportion of observations in the B phase that exceed the median observation from the A phase. For an outcome where decrease is desirable, PEM is calculated as the proportion of observations in the B phase that are less than the median observation from the A phase. Ties are counted with a weight of 0.5. The range of PEM is [0,1].

## References

Ma, H.-H. (2006). An alternative method for quantitative synthesis of single-subject researches: Percentage of data points exceeding the median. Behavior Modification, 30(5), 598--617. doi:doi:10.1177/0145445504272974

## Examples

A <- c(20, 20, 26, 25, 22, 23)
B <- c(28, 25, 24, 27, 30, 30, 29)
PEM(A_data = A, B_data = B)
#>    ES Est
#> 1 PEM   1