PTBdefault {accuracy}R Documentation

Returns a default perturbation function for a given vector.

Description

This function returns a function that can be used to repeatedly peturb the vector given to it.

Usage

PTBdefaultfn(vec, q = 0.99)
PTBdefault(vec, q=0.99)

Arguments

vec the vector which will be subject to perturbation
q for discrete vectors, the reclassification probability. For continuous vectors, perturbations will have 1-q relative uniform noise added.

Details

For numeric discrete values, and ordered factors, reclass.mat.diag will be used to generate the default reclassification matrix. For character vectors, unordered factors, and logicals, relass.mat.random is used.

Value

A function that can be used to perturb the vector.

Author(s)

Micah Altman Micah_Altman@harvard.edu http://www.hmdc.harvard.edu/micah_altman/

References

Altman, M., J. Gill and M. P. McDonald. 2003. Numerical Issues in Statistical Computing for the Social Scientist. John Wiley & Sons. http://www.hmdc.harvard.edu/numerical_issues/

See Also

perturb, PTBdiscrete, PTBus, reclass.mat.random

Examples


x=1:100
rpx=replicate(100,x,simplify=FALSE) # perturb using the default method
# This produces equivalent results, but is faster, since reclass matrices are not recalculated on each
# replication
#fx=PTBdefault(x,q=.95) 
#rpx=replicate(100,fx(x),simplify=FALSE) 
matches = sapply(rpx,function(y)(sum(y==x)))    # how many matches to original vector
summary(matches)                                # mean should be close to .95


[Package accuracy version 1.14 Index]