library(MatchIt) library(cobalt) data_psm_control_treat <- data %>% select_if(~ !all(is.na(.))) %>% select(Treatment_A, Z_Mean_NR, Age, Uni_degree, Kids_Dummy, Gender_female, Naturalness_SQ) %>% filter(Treatment_A != "Vol_Treated") %>% mutate(Dummy_Treat = case_when(Treatment_A == "Treated" ~1, TRUE~0)) psm_model <- matchit(Dummy_Treat ~ Z_Mean_NR + Age + Uni_degree + Kids_Dummy + Gender_female + Naturalness_SQ, data=data_psm_control_treat, method="full", distance="glm", ratio=1) psm_summary <- summary(psm_model) print(psm_summary) matched_data <- match.data(psm_model) love.plot(psm_model, stats = "mean.diffs", abs = FALSE, drop.distance = FALSE, thresholds = c(m = 0.1)) bal.plot(psm_model, var.name = "distance", which = "both", type = "density")