addquantile function

Cut a Covariate at Quantiles and Add a Penalty for Different Quantile Categories

Cut a Covariate at Quantiles and Add a Penalty for Different Quantile Categories

addquantile(costmatrix, z, p, pct = c(0.2, 0.4, 0.6, 0.8), penalty = 1000)

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.
  • p: A vector of length equal to length(z). Quantiles of p will penalize the distance.
  • pct: A vector of numbers strictly between 0 and 1. These determine the quantiles of p. For instance, c(.25,.5,.75) uses the quartiles of p.
  • penalty: One positive number used as a penalty.

Details

The vector p is cut at its quantiles defined by pct, and the integer difference in quantile categories is multiplied by penalty and added to the distance matrix. The function is similar to addinteger(), except the integer values are not specified, but rather are deduced from the quantiles.

If you cannot match for the quantile category of p, then addquantile() prefers to match from an adjacent quantile category.

Returns

A penalized distance matrix.

Author(s)

Paul R. Rosenbaum

Examples

data(binge) d<-binge[binge$AlcGroup!="N",] attach(d) z<-1*(AlcGroup=="B") names(z)<-SEQN dist<-startcost(z) quantile(age,pct=c(1/4,1/2,3/4)) rbind(z,age)[,1:20] addquantile(dist,z,d$age,pct=c(1/4,1/2,3/4),penalty=5)[1:5,1:7] detach(d) rm(z,dist,d)
  • Maintainer: Paul R. Rosenbaum
  • License: GPL-2
  • Last published: 2024-09-05

Useful links