Skip to main content

Extract/Replace Measurement Scale

Description

Generic functions for extracting and replacing the measurement scale from an object.

Usage

  mscale(object, ...)
  mscale(object) <- value

Arguments

object an object.
… arguments passed to methods.
value an object describing the measurement scale.

Examples

library("psychotools")

## methods for "paircomp" data
pc <- paircomp(rbind(
  c(2,  1,  0),
  c(1,  1, -1),
  c(1, -2, -1),
  c(0,  0,  0)))
pc
[1] {a >> b, a > c, b = c} {a > b, a > c, b < c}  {a > b, a << c, b < c}
[4] {a = b, a = c, b = c} 
## extract
mscale(pc)
[1] -2 -1  0  1  2
## replace (collapse to >/=/< scale)
mscale(pc) <- sign(mscale(pc))
pc
[1] {a > b, a > c, b = c} {a > b, a > c, b < c} {a > b, a < c, b < c}
[4] {a = b, a = c, b = c}
## similar for "itemresp" data
ir <- itemresp(cbind(
  c(-1, 0, 1, 1, 0),
  c(0, 1, 2, 1, 2),
  c(1, 2, 1, 1, 3)))
ir
[1] {-1,0,1} {0,1,2}  {1,2,1}  {1,1,1}  {0,2,3} 
## extract
mscale(ir)
$item1
[1] -1  0  1

$item2
[1] 0 1 2

$item3
[1] 1 2 3
## replace (single scale for all items)
mscale(ir) <- 1:3
ir
[1] {1,1,1} {2,2,2} {3,3,1} {3,2,1} {2,3,3}