Learn R Programming

sdcMicro (version 4.0.2)

pram_strata: Post Randomization

Description

To be used on categorical data. It randomly change the values of variables on selected records (usually the risky ones) according to an invariant probability transition matrix.

Usage

pram_strata(obj,variables,...)#,  strata_variables = NULL, weights = NULL,
  #seed = NULL, missing = -999, pd = 0.8,alpha = 0.5)
## S3 method for class 'pram_strata':
print(x, ...)

Arguments

obj
Input data or object of class sdcMicroObj
variables
Names of variables for Post Randomization
...
see arguments below
strata_variables
Names of variables for stratification
weights
a weight for each variable
seed
Integer value for the random seed
missing
A integer value to be used as missing value in the C++ routine
x
Output of pram_strata
pd
minimum diagonal entries for the generated transition matrix P. Either a vector of length 1 or a vector of length ( number of categories ).
alpha
amount of perturbation for the invariant Pram method

Value

  • a modified sdcMicroObj object or new variables with the suffix "_pram" will be created.

References

http://www.gnu.org/software/glpk http://www.ccsr.ac.uk/sars/guide/2001/pram.pdf

See Also

pram

Examples

Run this code
data(testdata)
  res <- pram_strata(testdata,variables="roof",strata_variables=c("urbrur","sex"))
  print.pram_strata(res)
  res1 <- pram_strata(testdata,variables=c("roof","walls","water"),strata_variables=c("urbrur","sex"))
  print.pram_strata(res1)
  res2 <- pram_strata(testdata,variables=c("roof","walls","water"),strata_variables=NULL)
  print.pram_strata(res2)
  
  ## for objects of class sdcMicro:
  data(testdata2)
  sdc <- createSdcObj(testdata2, keyVars=c('urbrur','roof','walls','water','electcon','relat','sex'), 
           numVars=c('expend','income','savings'), w='sampling_weight')
  sdc <- pram_strata(sdc, variables=c("urbrur"))

Run the code above in your browser using DataLab