Learn R Programming

iTOS (version 1.0.3)

addinteger: Add an Integer Penalty to an Existing Distance Matrix

Description

Takes an integer valued covariate, and adds a penalty proportional to the difference in the integer values, with proportionality constant penalty.

Usage

addinteger(costmatrix, z, iscore, penalty = 1000)

Value

A penalized distance matrix.

Arguments

costmatrix

An existing cost matrix with sum(z) rows and sum(1-z) columns. The function checks the compatability of costmatrix, z and p; so, it may stop with an error if these are not of appropriate dimensions. In particular, costmatrix may come from startcost().

z

A vector with z[i]=1 if individual i is treated or z[i]=0 if individual i is control. The rows of costmatrix refer to treated individuals and the columns refer to controls.

iscore

An vector of integers with length equal to length(z).

penalty

One positive number used to penalize mismatches for iscore.

Author

Paul R. Rosenbaum

Details

If a treated and control individual differ on iscore in absolute value by dif, then the distance between them is increased by adding dif*penalty.

Examples

Run this code
data(binge)
# Select two treated and four controls from binge
d<-binge[is.element(binge$SEQN,c(109315,109365,109266,109273,109290,109332)),]
attach(d)
z<-1*(AlcGroup=="B")
names(z)<-d$SEQN
rbind(z,education)
dist<-startcost(z)
addinteger(dist,z,education,penalty=3)
detach(d)
rm(d,dist,z)

Run the code above in your browser using DataLab