if (FALSE) {
library(MASS)
data("nh0506Homocysteine")
attach(nh0506Homocysteine)
# Select covariates
X<-cbind(female, age, black, education, povertyr, bmi)
#Propensity score
p<-glm(z ~ female + age + black + education + povertyr + bmi,
family=binomial)$fitted.values
d<-cbind(nh0506Homocysteine, p)
detach(nh0506Homocysteine)
dist<-maha_dense(d$z, X)
head(dist$d)
# Impose a penalty when a treated individual has a higher propensity
# score than a control
dist<-addMagnitudePenalty(dist, d$z, d$p, positive=TRUE, multiplier = 20)
head(dist$d)
}
Run the code above in your browser using DataLab