perturbate: Perturbate grid ratings

View source: R/perturbate.R

perturbateR Documentation

Perturbate grid ratings

Description

Randomly subtract or add an amount to a proportion of the grid ratings. This emulates randomness during the rating process, producing a grid which might also have resulted.

Usage

perturbate(x, prop = 0.1, amount = c(-1, 1), prob = c(0.5, 0.5))

grids_perturbate(x, n = 10, prop = 0.1, amount = c(-1, 1), prob = c(0.5, 0.5))

Arguments

x

A repgrid object.

prop

The proportion of ratings to be perturbated.

amount

The amount set of possible perturbations. Will depend on scale range. Usually ⁠{-1, 1}⁠ are reasonable settings.

prob

Probability for each amount to occur.

n

Number of perturbated grid to generate.

Examples

## All results for PVAFF index when ratings are slightly perturbated
p <- indexPvaff(boeker)
l <- grids_perturbate(boeker, n = 100, prop = .1)
pp <- sapply(l, indexPvaff)  # apply indexPvaff function to all perturbated grids
range(pp)   # min and max PVAFF
hist(pp, xlab = "PVAFF values")    # visualize
abline(v = p, col = "blue", lty = 2)

markheckmann/OpenRepGrid documentation built on April 14, 2024, 8:15 a.m.