I am doing Propensity Score Matching and want to subset the data for treatment and control but by using weights. I have 5 variables: ID, treatment(yes/No), Outcome(Yes/No), Age and "Weights". I was trying to write a programme in R. But unable to do according to weights. I used survey package. But I'm not getting the correct results.
** `head(dat2)` **
** `dput(dat2)`
structure(list(ID = c(1, 2, 3, 4, 6, 7), Weight = c(2.4740626,
2.4740626, 2.4740626, 2.4740626, 1.9548149, 1.9548149), Age = c("35-44",
"<15-24", "25-34", "35-44", ">45", "25-34"), Treatment = c(1,
0, 0, 1, 0, 0), Outcome = c(1, 1, 1, 0, 1, 1)), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame")) **
data<-svydesign(ids = ~dat2$Id,
weights = ~dat2$Weight,
data = dat2)
treat<-subset(dat, dat2$treatment==1)
cont<-subset(dat, dat2$treatment==0)
Please help me. Thanks in Advance.