Simplified Output for Matchit package

Have been attending a seminar on propensity score matching this week, when I was asked if I could write a function to reduce the complexity of the matchit package output. I produced two functions.

First I wrote a function to produce a histogram of the matched mean differences which gives a nice summary of how well the matching procedure has achieved balance (note you need to install the package ggplot2 to use this function):

meandiffplot <- function (x) {
	diffplot<-ggplot(mdiff, aes(m_mean_diff) )
	diffplot<- diffplot+ geom_histogram (fill="grey")
	diffplot<- diffplot+ geom_density (colour="red")

Next I produced a function the reports only those matched mean differences with a standardized difference of over .1 (sorted by absolute size).

meandifftable<- function (x){
	matchID <- as.vector (row.names (post) )
	post$absolute<- abs(post[1])
	total2<-post[order (-post$absolute, na.last=NA) ,]
	meandiffover1<- subset(total2[1], total2[1]> .1 | total2[1]< -.1)

If you use the matchit package I think these functions are really useful.



About Philip Parker

I am a post doc in developmental and educational psychology at a Germany university. I did my PhD at the university of Sydney in stress and well-being. Most days I am hunched over a computer yelling at statistical software or responding to journal editors who seem to always want twice the amount of content but with half the words. For fun I like to read up on the latest developments in R and programming various functions.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s