Dataset <- readXL("C:/../SupplementaryMaterial1.xls", rownames=FALSE, header=TRUE, na="", sheet="Sheet 1", stringsAsFactors=TRUE) library(MatchIt) #create a new dataset from our sheet and loads MatchIt package #Important: GROUP have to be named "0" (for LMAb) and "1" (for LMAa) KJAlogit<-glm(GROUP~AGE+BMI+SURGERYLENGHT, data=Dataset, family="binomial") summary(KJAlogit) exp(cbind(OR=coef(KJAlogit),confint(KJAlogit))) #It returns logistic regression model with odds ration and 95% confidence intervals Pscore<-data.frame(ps=predict(KJAlogit,type="response"),GROUP=KJAlogit$model$GROUP) summary(Pscore) #It returns a new dataset with propensity score calculated for each subject final<-matchit(GROUP~AGE+BMI+SURGERYLENGHT,method="nearest",caliper=0.1,data=Dataset) finalDataset<-match.data(final) summary(finalDataset) #It returns a new dataset with the matched populations