Learn R Programming

QualityMeasure (version 2.0.1)

calcAOV: Calculate reliability using one-way ANOVA method

Description

This function estimates reliability using the one-way ANOVA method.

Usage

calcAOV(
  df,
  entity = "entity",
  y = "y",
  df.aggregate = FALSE,
  n = "n",
  mean = "mean",
  std.dev = "sd",
  ctrPerf = controlPerf()
)

Value

A list containing:

  • MSB: mean squares between entities

  • MSW: mean squares within entities

  • F.stat: F-statistic from one-way ANOVA

  • entity: list of entities

  • n: sample sizes for each entity

  • n0: aggregate sample size used in reliability calculation

  • var.b.aov: between-entity variance

  • var.w.aov: within-entity variance

  • est.aov: entity-level reliability estimates

Arguments

df

dataframe (assumed to be observation-level unless df.aggregate is changed below)

entity

data column containing the accountable entity identifier

y

data column containing the outcome variable

df.aggregate

set this to TRUE if the data have already been aggregated to include only summary data (sample size, means, and standard deviations) for each entity; default is FALSE.

n

if using aggregated data, data column containing the sample sizes for each entity; default is n.

mean

if using aggregated data, data column containing the sample means for each entity; default is mean.

std.dev

if using aggregated data, data column containing the sample standard deviations for each entity entity; default is sd.

ctrPerf

parameters to control performance measure calculation

Author

Kenneth Nieser (nieser@stanford.edu)

Details

This function uses the aov() function from the stats package to calculate mean squares between and mean squares within entities.

References

Nieser KJ, Harris AH. Comparing methods for assessing the reliability of health care quality measures. Statistics in Medicine. 2024 Oct 15;43(23):4575-94.

Examples

Run this code
# Simulate data
df <- simulateData(n.entity = 50, n.obs = 100, mu = 25, r = .7, data.type = 'normal')

# Calculate reliability
out <- calcAOV(df = df, entity = 'entity', y = 'y')
summary(out$est.aov)

# Plot reliability by entity sample size
plot(out$n, out$est.aov)


## Reliability can also be calculated with data aggregated by entity
df.agg <- data.frame(
          entity = aggregate(y ~ entity, data = df, length)$entity,
          n = aggregate(y ~ entity, data = df, length)$y,
          mean = aggregate(y ~ entity, data = df, mean)$y,
          sd = aggregate(y ~ entity, data = df, sd)$y
          )

out2 <- calcAOV(df = df.agg, df.aggregate = TRUE, n = 'n', mean = 'mean', std.dev = 'sd')
summary(out2$est.aov)

Run the code above in your browser using DataLab