gstudy: Generalizability and Decision Studies

View source: R/gstudy.R

gstudyR Documentation

Generalizability and Decision Studies

Description

Functions for running generalizability (G) and decision (D) studies for estimating reliability in multi-faceted designs.

Usage

gstudy(x, ...)

## Default S3 method:
gstudy(x, data = NULL, ...)

## S3 method for class 'formula'
gstudy(x, data = NULL, id = "person", ...)

## S3 method for class 'data.frame'
gstudy(x, random = TRUE, column_label = "rater", id = "person", ...)

## S3 method for class 'merMod'
gstudy(x, n, id = "person", ...)

Arguments

x

for the default method, a formula object sent to the lme4 package. Otherwise, an object of class merMod, output by the lmer function. x can also be a data frame, where a model with a single facet is assumed, with people in rows and the facet in columns.

...

further arguments passed to or from other methods.

data

a data frame containing the variables named in formula. Required when x is not a data frame.

id

character string naming the id variable for the unit of observation, defaulting to "person".

random

logical indicating whether the facet given in columns when x is data frame should be treated as a random (default) or fixed effect.

column_label

string for labeling the column facet when x is data frame.

n

vector of counts used in adjusting the g coefficient. Not currently used.

Value

Returns a list containing the original call, model formula, reliabilities, variance components, and n counts by facet.

Methods (by class)

  • gstudy(default): Method defaults to formula interface.

  • gstudy(formula): Method for formula objects.

  • gstudy(data.frame): Method for wide data frames with people as rows and a single facet as columns

  • gstudy(merMod): Method for objects of class merMod.

Examples

# Reading items
ritems <- c("r414q02", "r414q11", "r414q06", "r414q09",
  "r452q03", "r452q04", "r452q06", "r452q07", "r458q01",
  "r458q07", "r458q04")
rsitems <- paste0(ritems, "s")

# Subset of PISA09 data for Belgium
pisa <- subset(PISA09, cnt == "BEL")[, rsitems]

# Convert to long format
np <- nrow(pisa)
ni <- ncol(pisa)
pisal <- data.frame(person = factor(rep(1:np, ni)),
  item = rep(rsitems, each = np),
  score = unlist(pisa), row.names = 1:(np * ni))

# Compare coefficient alpha using rstudy and gstudy
rout <- rstudy(pisa, use = "complete.obs")
gout <- gstudy(pisa, column_label = "item")
rout$alpha
gout$g

# Alternatively, find g using long data and formula method
# Results differ slightly because missing data are excluded with the
# data frame method but included by default with the formula method
goutl <- gstudy(score ~ (1 | person) + (1 | item), data = pisal)
goutl$g


talbano/epmr documentation built on Aug. 25, 2023, 1:35 p.m.