partition.replacement {sgr}R Documentation

Internal function.

Description

This function allows to set different replacement distributions for different subsets of cells in the data matrix.

Usage

partition.replacement(Dx, PM, Q = NULL, Pparm = NULL,
        fake.model = NULL,p = NULL)

Arguments

Dx

Data frame or matrix to be replaced.

PM

Partition matrix with size dim(Dx). See details.

Q

Max value in the discrete r.v. range: 1, \ldots, Q.

Pparm

List of replacement parameters for each class in the replacement partition. See details.

fake.model

A character string indicating the model for the conditional replacement distribution, see model.fake.par.

p

Overall probability of replacement. Must be a matrix with P rows and two columns. See details.

Details

PM has size dim(Dx) and contains a numeric code for each distinct class in the partition. If a cell of the partition matrix PM contains 0, then the corresponding Dx cell value is not modified (no replacements condition class).

Pparm is a list containing three elements. Each element is a P\times 2 matrix where P is the total number of classes in the partition (see examples for further details).

p: Overall probability of replacement: p[,1] indicates the faking good probability, p[,2] indicates the faking bad probability.

gam: Gamma parameter: gam[,1] and gam[,2] indicate the faking good and the faking bad parameters for the lower bound a.

del: Delta parameter: del[,1] and del[,2] indicate the faking good and the faking bad parameters for the upper bound b.

Note that it is possible to define a faking model using the fake.model assignment. In such cases the user must specify also the overall probability of replacement using parameter p.

Value

Returns the fake data matrix.

Author(s)

Massimiliano Pastore

See Also

rdatarepl, replacement.matrix

Examples

require(MASS)
set.seed(20130207)
R <- matrix(c(1,.3,.3,1),2,2)
Dx <- rdatagen(n=20,R=R,Q=5)$data

## partition matrix
PM <- matrix(0,nrow(Dx),ncol(Dx))
PM[3:10,2] <- 1
PM[3:10,1] <- 1
partition.replacement(Dx,PM) # warning! zero replacements

## using fake.model
partition.replacement(Dx,PM,fake.model="uninformative",p=matrix(c(.3,.2),ncol=2))

###
p <- c(.5,0)
gam <- c(1,1)
del <- c(1,1)
Pparm <- list(p=p,gam=gam,del=del)
partition.replacement(Dx,PM,Pparm=Pparm) 

### another partition
PM[11:15,2] <- 2
(Pparm <- list(p=matrix(c(0,.5,.5,0),2,2),
      gam=matrix(c(1,4,1,4),2,2),del=matrix(c(1,2,1,2),2,2)))
partition.replacement(Dx,PM,Pparm=Pparm) 



[Package sgr version 1.3.1 Index]