## data on quality of life
data(stu1)
## estimate relative effects for covariates 'tgr' and 'age' regarding
## the effect of treatment 'therapie' on response 'pst'
rel.eff <- relative.effect(data    = stu1,
                           formula = pst~therapie+tgr+age)
## estimate the propensity score
ps <- pscore(data    = stu1,
             formula = therapie~tgr+age)
## stratify data
strata <- ps.makestrata(object = ps)
## match data in a ratio of 1:1 with a caliper size of 0.5
match <- ps.match(object  = ps,
                  ratio   = 1,
                  caliper = 0.5,
                  givenTmatchingC = FALSE)
## graphical check of distribution of both covariates between
## treatment groups in the matched data
bal.plot1 <- dist.plot(object = strata,
                      sel     = c("tmass"))
bal.plot2 <- dist.plot(object    = match,
                       sel       = c("alter"),
                       plot.type = 2,
                       compare   = TRUE)      
## calculate standardized differences of both covariates
## in case of matched data
bal.table <- ps.balance(object  = match,
                        sel     = c("tgr","age"),
                        method  = "stand.diff",
                        alpha   =  20)
## estimate propensity score based effects and in comparion the
## regression based treatment effect on response
ps.est <- ps.estimate(object = strata,
                      resp   = "pst",
                      regr   = pst~therapie+tgr+age)
Run the code above in your browser using DataLab